music.tremolos

music.tremolos(durations=((3, 4, 5), (2, 3, 7, 4)), tremolo_freqs=((2, 6, 20), (5, 6.2, 21, 5)), max_db_devs=((10, 20, 1), (5, 7, 9, 2)), alpha=((1, 1, 1), (1, 1, 1, 9)), waveform_tables=((array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)), array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)), array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,))), (array([-1., -0.99975586, -0.99951172, ..., -0.99926758, -0.99951172, -0.99975586], shape=(16384,)), array([-1., -0.99975586, -0.99951172, ..., -0.99926758, -0.99951172, -0.99975586], shape=(16384,)), array([-1., -0.99975586, -0.99951172, ..., -0.99926758, -0.99951172, -0.99975586], shape=(16384,)), array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)))), number_of_samples=None, sonic_vector=0, sample_rate=None)[source]

An envelope with multiple tremolos.

Parameters:
durationsiterable of iterable of scalars

The durations of each tremolo, in seconds, in lines: the tremolos of a line follow one another, and the lines are multiplied together.

tremolo_freqsiterable of iterable of scalars

The frequencies of each tremolo, laid out as durations is.

max_db_devsiterable of iterable of scalars

The maximum loudness variation of each tremolo, in decibels, laid out as durations is.

alphaiterable of iterable of scalars

Indexes for distortion of each tremolo [1], laid out as durations is.

waveform_tablesiterable of iterable of array_likes

Tables for lookup for each tremolo, laid out as durations is.

number_of_samplesiterable of iterable of scalars, or None

The number of samples of each tremolo. If given, durations is ignored.

sonic_vectorarray_like

The sound to apply the tremolos to. A line shorter than the longest, or than the sound, holds its last value to the end, and a sound shorter than the longest line is padded with silence. Mono, or of shape (nchannels, nsamples), every channel shaped alike.

sample_rateinteger or None

The sample rate. None, the default, is the rate music.get_sample_rate() returns.

Returns:
sndarray

A numpy array where each value is a value of the envelope for the PCM samples. If sonic_vector is supplied, s is the sonic vector with the envelope applied to it.

Raises:
ValueError

If tremolo_freqs, max_db_devs, alpha or waveform_tables has no entry for a segment that durations, or number_of_samples, has. Each default is laid out for two lines of three and four segments, so a layout with more needs them all given: the first default it outgrew failed as an IndexError that named no argument.

If durations, or number_of_samples, is not laid out in lines of segments: one number, or one line of them, failed as a TypeError that named nothing.

See also

loud

An envelope for a loudness transition.

louds

An envelope with an arbitrary number of transitions.

fade

Fade in and out.

adsr

An ADSR envelope.

tremolo

An oscillation of loudness.

Notes

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

>>> envelope = tremolos()     # lines of 12 and 16 seconds, multiplied
>>> len(envelope) / 44100
16.0
>>> write_wav_mono(tremolos(sonic_vector=note_with_vibrato(duration=16)))