music.note_with_fm¶
- music.note_with_fm(freq=220, duration=2, fm=100, max_fm_deviation=2, waveform_table=array([-1., -0.99975586, -0.99951172, ..., -0.99926758, -0.99951172, -0.99975586], shape=(16384,)), fm_waveform_table=array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)), number_of_samples=0, sample_rate=44100)[source]¶
Synthesize a musical note with FM synthesis.
Set fm=0 or max_fm_deviation=0 (or use synth_note()) for a note without FM. A FM is a linear oscillatory pattern of frequency [1].
- Parameters:
- freqscalar
The frequency of the note in Hertz.
- durationscalar
The duration of the note in seconds.
- fmscalar
The frequency of the modulator in Hertz.
- max_fm_deviationscalar
The maximum deviation of frequency in the modulator in Hertz.
- waveform_tablearray_like
The table with the waveform for the carrier.
- fm_waveform_tablearray_like
The table with the waveform for the modulator.
- number_of_samples
integer The number of samples in the sound. If supplied, duration is ignored.
- sample_rate
integer The sample rate.
- Returns:
- result
ndarray A numpy array where each value is a PCM sample of the note.
- result
- Parameters:
- Return type:
NDArray[float64]
See also
noteA basic musical note without vibrato.
note_with_vibratoA musical note with an oscillation of pitch.
tremoloA tremolo, an oscillation of loudness.
amA linear oscillation of amplitude (not linear loudness).
Notes
In the MASS framework implementation, for a sound with a vibrato (or FM) to be synthesized using LUT, the vibrato (or FM) 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_with_fm()) # writes a WAV file of a note >>> sonic_vector = horizontal_stack( ... *[note_with_fm(i, j) for i, j in zip([200, 500, 100], ... [2, 1, 2])]) >>> s2 = note_with_fm(440, 1.5, 600, 10)