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 tremolo oscillatory pattern.

number_of_samplesinteger

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

sonic_vectorarray_like

Samples for the tremolo to be applied to. If supplied, d and nsamples 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.

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 oscilattory pattern of amplitude while the tremolo is an oscilattory 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

>>> W(V()*am())  # writes a WAV file of a note with tremolo
>>> s = H([V()*am(fm=i, a=j) for i, j in zip([60, 150, 100],
                                             [2, 1, 20])])
>>> s = H([am(fm=i, a=j, sonic_vector=V()) for i, j in zip([60, 150, 100],
                                                           [2, 1, 20])])
>>> envelope2 = am(440, 150, 60)  # a lengthy envelope