pub enum AudioEffect {
Eq {
bands: Vec<EqBand>,
},
Compressor {
threshold_db: Animated<f32>,
ratio: Animated<f32>,
knee_db: Animated<f32>,
makeup_db: Animated<f32>,
attack_ms: f32,
release_ms: f32,
lookahead_ms: f32,
detector: Detector,
detector_filter: Option<DetectorFilter>,
sidechain: Option<AudioNodeRef>,
},
Expander {
threshold_db: Animated<f32>,
ratio: Animated<f32>,
range_db: Animated<f32>,
attack_ms: f32,
hold_ms: f32,
release_ms: f32,
lookahead_ms: f32,
detector_filter: Option<DetectorFilter>,
sidechain: Option<AudioNodeRef>,
},
Delay {
time_ms: f32,
feedback: Animated<f32>,
mix: Animated<f32>,
},
Matrix {
left: [Animated<f32>; 2],
right: [Animated<f32>; 2],
},
Ducker {
sidechain: AudioNodeRef,
threshold: Animated<f32>,
depth_db: Animated<f32>,
attack_ms: f32,
release_ms: f32,
},
Reverb {
room_size: f32,
damping: f32,
mix: Animated<f32>,
},
}Expand description
A serializable audio effect applied to a clip, a track, a bus or the master.
An effect with a sidechain follows the level of that track or bus instead of its own
input: its signal after its effects and before its fader and pan. A clip’s effects take
none.
A parameter documented as animated is keyed in timeline time and evaluated at every 32nd sample of the effect’s own input, counted from timeline zero; the effect moves in a straight line between two such points. A constant parameter keeps its exact value.
Variants§
Eq
Cascaded biquad sections.
Fields
bands: Vec<EqBand>Ordered filter sections, 1 to MAX_EQ_BANDS of them.
Compressor
Lookahead dynamic range compression with linked channels.
With the level x, the threshold T, the ratio R and the knee W in decibels, the
gain is 0 dB while 2 (x - T) < -W, (1/R - 1) (x - T + W/2)^2 / (2 W) while
2 |x - T| <= W, and T + (x - T) / R - x above; the makeup gain is added to it.
Fields
threshold_db: Animated<f32>Animated level above which gain reduction begins, in decibels from MIN_LEVEL_DB
to 0.
ratio: Animated<f32>Animated downward ratio, from one (unity) to MAX_COMPRESSOR_RATIO.
knee_db: Animated<f32>Animated width of the knee centred on the threshold, in decibels from 0 (a hard
knee) to MAX_KNEE_DB.
makeup_db: Animated<f32>Animated gain applied after the reduction, in decibels, at most MAX_MAKEUP_DB
either way.
attack_ms: f32Attack time in milliseconds, positive and at most MAX_ENVELOPE_MS.
release_ms: f32Release time in milliseconds, positive and at most MAX_ENVELOPE_MS.
lookahead_ms: f32Lookahead in milliseconds, at most MAX_LOOKAHEAD_MS. Reported as graph latency.
detector_filter: Option<DetectorFilter>A filter before the detector.
sidechain: Option<AudioNodeRef>The track or bus whose level drives the reduction; absent, the effect’s own input.
Expander
Downward expansion with linked channels; with a high ratio, a gate.
The level is a peak follower with the attack and release times. Under the threshold
T a level x in decibels asks for min((T - x) (R - 1), range_db) decibels of
attenuation. The gain opens with the attack time; before it closes it holds for
hold_ms, then closes with the release time.
Fields
threshold_db: Animated<f32>Animated level below which attenuation begins, in decibels from MIN_LEVEL_DB
to 0.
ratio: Animated<f32>Animated ratio, from one (unity) to MAX_COMPRESSOR_RATIO: under the threshold
the output falls this many decibels for each decibel the level falls.
range_db: Animated<f32>Animated limit of the attenuation, in decibels from 0 to
MAX_EXPANDER_RANGE_DB, which is the default.
attack_ms: f32Attack time in milliseconds, positive and at most MAX_ENVELOPE_MS.
hold_ms: f32Hold time in milliseconds, at most MAX_HOLD_MS.
release_ms: f32Release time in milliseconds, positive and at most MAX_ENVELOPE_MS.
lookahead_ms: f32Lookahead in milliseconds, at most MAX_LOOKAHEAD_MS. Reported as graph latency.
detector_filter: Option<DetectorFilter>A filter before the detector.
sidechain: Option<AudioNodeRef>The track or bus whose level drives the gain; absent, the effect’s own input.
Delay
A feedback delay line: each channel repeats after time_ms. With the sample x and
the line’s oldest sample d, the line takes x + feedback * d and the output is
x * (1 - mix) + d * mix. It adds no latency.
Fields
time_ms: f32Delay time in milliseconds, from 1 to MAX_DELAY_MS.
feedback: Animated<f32>Animated share of the delayed signal fed back into the line, from 0 to
MAX_DELAY_FEEDBACK.
Matrix
A two-by-two gain matrix over the stereo pair: the left output is
left[0] * L + left[1] * R and the right right[0] * L + right[1] * R. Width, swap,
mono, polarity and balance are settings of it. A mono mix takes
((left[0] + left[1]) + (right[0] + right[1])) / 2 times the sample.
Fields
left: [Animated<f32>; 2]The animated gains the left output takes from left and right, each at most
MAX_MATRIX_GAIN either way.
right: [Animated<f32>; 2]The animated gains the right output takes from left and right, each at most
MAX_MATRIX_GAIN either way.
Ducker
Lowers the signal while its key sounds.
Fields
sidechain: AudioNodeRefThe track or bus whose level drives the attenuation.
depth_db: Animated<f32>Animated maximum attenuation in decibels, from MIN_LEVEL_DB to 0.
attack_ms: f32Attack time in milliseconds, positive and at most MAX_ENVELOPE_MS.
release_ms: f32Release time in milliseconds, positive and at most MAX_ENVELOPE_MS.
Reverb
Schroeder reverberation.
Implementations§
Source§impl AudioEffect
impl AudioEffect
Sourcepub fn delay_ticks(&self) -> u64
pub fn delay_ticks(&self) -> u64
What this effect counts toward MAX_AUDIO_DELAY_MS, in ticks (120 per millisecond),
rounded up. Tick counts are exact, so a project’s effects sum the same in any order.
Sourcepub fn lookahead_ticks(&self) -> u64
pub fn lookahead_ticks(&self) -> u64
How early a mixer reads this effect’s input, in ticks, rounded up: a compressor’s or
expander’s lookahead_ms.
Sourcepub const fn sidechain(&self) -> Option<&AudioNodeRef>
pub const fn sidechain(&self) -> Option<&AudioNodeRef>
The track or bus this effect is keyed by, if any.
Sourcepub fn for_each_param<'a>(
&'a self,
visit: &mut dyn FnMut(AudioEffectParam<&'a Animated<f32>>),
)
pub fn for_each_param<'a>( &'a self, visit: &mut dyn FnMut(AudioEffectParam<&'a Animated<f32>>), )
Calls visit with each parameter that animates, in the effect’s field order, band by
band for an equalizer.
Sourcepub fn for_each_param_mut<'a>(
&'a mut self,
visit: &mut dyn FnMut(AudioEffectParam<&'a mut Animated<f32>>),
)
pub fn for_each_param_mut<'a>( &'a mut self, visit: &mut dyn FnMut(AudioEffectParam<&'a mut Animated<f32>>), )
Self::for_each_param, to change the values.