Instrument.Instrument
- class Instrument.Instrument.Instrument(bit_rate: int = 44100, no_play: bool = False)
Can play any piano notes, you have to input the key number for corresponding frequencies.
- Parameters:
bit_rate – Generally value of bit rate is 44100 or 48000, it is proportional to wavelength of frequency generated.
no_play – Use this if you don’t want to play the sample but use it for other purposes.
- Attributes:
- graphing_sample:
Used for graphing see the usage page.
- total_time:
Numpy array representing time at split seconds.
- play_time:
Total time for which the sample has been recorded.
- clear_sample() None
Clears the sample.
- close() None
Terminates PyAudio.
- static get_hz(key_number: int) float
Get frequency of the key via its key number.
- Returns:
frequency of the key.
- play() None
Plays the sample.
- record_chord(chords: Iterable, duration: float) None
Adds the given chords in the sample.
- Parameters:
chords – The iterable of chords that you want to play at same time.
duration – Duration of each chord.
- record_key(key: int, duration: float) None
Adds the key in the sample.
- Parameters:
key – The key number of the key’s name.
duration – Time for which the key it to be played.
- Returns:
None
- property sample
Numpy array containing sample data.
- to_wav(path: str) None
Convert the sample to wav file format.
- Parameters:
path – Path of the file where it will be written.