Skip to main content

AudioEffect

Enum AudioEffect 

Source
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: f32

Attack time in milliseconds, positive and at most MAX_ENVELOPE_MS.

§release_ms: f32

Release time in milliseconds, positive and at most MAX_ENVELOPE_MS.

§lookahead_ms: f32

Lookahead in milliseconds, at most MAX_LOOKAHEAD_MS. Reported as graph latency.

§detector: Detector

How the level is measured.

§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: f32

Attack time in milliseconds, positive and at most MAX_ENVELOPE_MS.

§hold_ms: f32

Hold time in milliseconds, at most MAX_HOLD_MS.

§release_ms: f32

Release time in milliseconds, positive and at most MAX_ENVELOPE_MS.

§lookahead_ms: f32

Lookahead 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: f32

Delay 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.

§mix: Animated<f32>

Animated wet mix, in 0..=1.

§

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: AudioNodeRef

The track or bus whose level drives the attenuation.

§threshold: Animated<f32>

Animated linear key level above which attenuation begins. Positive.

§depth_db: Animated<f32>

Animated maximum attenuation in decibels, from MIN_LEVEL_DB to 0.

§attack_ms: f32

Attack time in milliseconds, positive and at most MAX_ENVELOPE_MS.

§release_ms: f32

Release time in milliseconds, positive and at most MAX_ENVELOPE_MS.

§

Reverb

Schroeder reverberation.

Fields

§room_size: f32

Room size, in 0..=1.

§damping: f32

High-frequency damping, in 0..=1.

§mix: Animated<f32>

Animated wet mix, in 0..=1.

Implementations§

Source§

impl AudioEffect

Source

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.

Source

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.

Source

pub const fn sidechain(&self) -> Option<&AudioNodeRef>

The track or bus this effect is keyed by, if any.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for AudioEffect

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AudioEffect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AudioEffect

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for AudioEffect

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AudioEffect

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AudioEffect

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.