music.adsr_stereo¶
- music.adsr_stereo(duration=2, attack_ms=20, decay_ms=20, sustain_level=-5, release_ms=50, transition='exp', alpha=1, db_dev=-80, to_zero_ms=1, number_of_samples=None, sonic_vector=0, sample_rate=None, **renamed)[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.
- attack_msscalar
The duration of the Attack in milliseconds.
- decay_msscalar
The duration of the Decay in milliseconds.
- sustain_levelscalar
The Sustain level after the Decay in decibels. Usually negative.
- release_msscalar
The duration of the Release in milliseconds.
- transition
str “exp” or “exponential” for exponential transitions of amplitude (linear loudness), “lin” or “linear” for linear transitions of amplitude.
- alphascalar or array_like
An index to make the exponential fade slower or faster. Ignored if
transition="linear"oralpha=1. One value for every stage, or three: for the Attack, the Decay and the Release.- db_devscalar or array_like
The decibels deviation to reach before using a linear fade to reach zero amplitude. One value for both, or two: for the Attack and the Release. Ignored if
transition="linear".- to_zero_msscalar or array_like
The duration in milliseconds for linearly departing from zero in the Attack and reaching zero at the end of the Release. One value for both, or two: for the Attack and the Release. Longer than its stage, it is the whole stage. Ignored if
transition="linear".- number_of_samples
integerorNone The number of samples of the envelope. If given,
durationis ignored, and zero is an envelope of no samples.- sonic_vectorarray_like
A
(2, nsamples)stereo sound for the envelope to be applied to. If supplied,durationandnumber_of_samplesare ignored.- sample_rate
integerorNone The sample rate. None, the default, is the rate
music.get_sample_rate()returns.- **renamed
attack_duration,decay_duration,release_durationandto_zero, asadsr()takes them. Still accepted, with aDeprecationWarning.
- Returns:
ndarrayA
(2, nsamples)array: the envelope itself ifsonic_vectoris 0, or the sound with the envelope applied.
- Raises:
ValueErrorAs
adsr()raises it: a transition it does not know, a per-stage value with the wrong number of stages, a negative alpha for an exponential transition, or a negative duration.TypeErrorIf a keyword is neither a parameter nor one of the old names.
See also
adsrthe mono envelope, and the meaning of every argument here.
Examples
>>> envelope = adsr_stereo(duration=1) >>> envelope.shape[0] 2