music.adsr_stereo

music.adsr_stereo(duration=2, attack_duration=20, decay_duration=20, sustain_level=-5, release_duration=50, transition='exp', alpha=1, db_dev=-80, to_zero=1, number_of_samples=0, sonic_vector=0, sample_rate=44100)[source]

A shorthand to make an ADSR envelope for a stereo sound.

adsr() is applied to each channel with the same arguments, so the two channels keep their relative level through the envelope rather than being shaped independently.

Parameters:
durationscalar

The duration of the envelope in seconds. Passed to adsr() as envelope_duration.

attack_durationscalar

The duration of the Attack in milliseconds.

decay_durationscalar

The duration of the Decay in milliseconds.

sustain_levelscalar

The Sustain level after the Decay in decibels. Usually negative.

release_durationscalar

The duration of the Release in milliseconds.

transitionstr

“exp” for exponential transitions of amplitude (linear loudness), “linear” for linear transitions of amplitude.

alphascalar or array_like

An index to make the exponential fade slower or faster. Ignored if transition="linear" or alpha=1. An array_like should hold three values, for Attack, Decay and Release.

db_devscalar or array_like

The decibels deviation to reach before using a linear fade to reach zero amplitude. An array_like should hold two values, for Attack and Release. Ignored if transition="linear".

to_zeroscalar or array_like

The duration in milliseconds for linearly departing from zero in the Attack and reaching zero at the end of the Release. An array_like should hold two values, for Attack and Release. Ignored if transition="linear".

number_of_samplesinteger

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

sonic_vectorarray_like

A (2, nsamples) stereo sound for the envelope to be applied to. If supplied, duration and number_of_samples are ignored.

sample_rateinteger

The sample rate.

Returns:
ndarray

A (2, nsamples) array: the envelope itself if sonic_vector is 0, or the sound with the envelope applied.

See also

adsr

the mono envelope, and the meaning of every argument here.

Examples

>>> envelope = adsr_stereo(duration=1)
>>> envelope.shape[0]
2