music.am

music.am(duration=2, fm=50, max_amplitude=0.4, waveform_table=array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)), number_of_samples=0, sonic_vector=0, sample_rate=44100)[source]

Synthesize an AM envelope or apply it to a sound.

Set fm=0 or max_amplitude=0 for a constant envelope with value 1. An AM is a linear oscillatory pattern of amplitude [1].

Parameters:
durationscalar

The duration of the envelope in seconds.

fmscalar

The frequency of the modulation in Hertz.

max_amplitudescalar

The maximum deviation of amplitude of the AM.

waveform_tablearray_like

The table with the waveform for the AM oscillatory pattern.

number_of_samplesinteger

The number of samples of the envelope. If supplied, duration is ignored.

sonic_vectorarray_like

Samples for the modulation to be applied to. If supplied, duration and number_of_samples are ignored.

sample_rateinteger

The sample rate.

Returns:
tndarray

A numpy array where each value is a PCM sample of the envelope. If sonic_vectoris input, T is the sonic vector with the AM applied to it.

See also

note_with_vibrato

A musical note with an oscillation of pitch.

note_with_fm

A linear oscillation of fundamental frequency.

tremolo

A tremolo, an oscillation of loudness.

Notes

In the MASS framework implementation, for obtaining a sound with a tremolo (or AM), the tremolo pattern is considered separately from a synthesis of the sound.

The AM is an oscillatory pattern of amplitude while the tremolo is an oscillatory pattern of loudness being: loudness ~ log(amplitude)

The vibrato and FM patterns are considered when synthesizing the sound.

One might want to run this function twice to obtain a stereo reverberation.

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_vibrato() * am())  # a note with AM
>>> s = horizontal_stack(
...     *[note_with_vibrato() * am(fm=i, max_amplitude=j)
...      for i, j in zip([60, 150, 100],
... [2, 1, 20])])
>>> s = horizontal_stack(
...     *[am(fm=i, max_amplitude=j, sonic_vector=note_with_vibrato())
...      for i, j in zip([60, 150, 100],
... [2, 1, 20])])
>>> envelope2 = am(440, 150, 60)  # a lengthy envelope