music.note

music.note(freq=220, duration=2, waveform_table=array([-1., -0.99975586, -0.99951172, ..., -0.99926758, -0.99951172, -0.99975586], shape=(16384,)), number_of_samples=0, sample_rate=44100)[source]

Synthesize a basic musical note.

Parameters:
freqscalar

The frequency of the note in Hertz.

durationscalar

The duration of the note in seconds.

waveform_tablearray_like

The table with the waveform to synthesize the sound.

number_of_samplesinteger

The number of samples in the sound. If not 0, d is ignored.

sample_rateinteger

The sample rate.

Returns:
resultndarray

A numpy array where each value is a PCM sample of the note.

See also

V

A note with vibrato.

T

A tremolo envelope.

Notes

In the MASS framework implementation, for a sound with a vibrato (or FM) to be synthesized using LUT, the vibrato pattern is considered when performing the lookup calculations.

The tremolo and AM patterns are implemented as separate amplitude envelopes.

Cite the following article whenever you use this function.

References

[1]

Fabbri, Renato, et al. “Musical elements in the discrete-time representation of sound.” arXiv preprint arXiv:abs/1412.6853 (2017)

Examples

>>> write_wav_mono(note())  # writes a WAV file of a note
>>> s = H([note(i, j) for i, j in zip([200, 500, 100], [2, 1, 2])])
>>> s2 = note(440, 1.5, waveform_table=WAVEFORM_SAWTOOTH)