meadow-dsp-essentials 0.1.4

Liberally-licensed essential audio DSP library used in the Meadowlark DAW project
Documentation
#[cfg(feature = "f32")]
pub mod f32;
#[cfg(feature = "f64")]
pub mod f64;

/// The algorithm used to map a normalized crossfade/panning value in the
/// range `[-1.0, 1.0]` to the corresponding gain values for two inputs.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
pub enum FadeCurve {
    /// This curve makes the combined signal appear to play at a constant volume
    /// across the entire fade range for most signals.
    ///
    /// More specifically this a circular curve with each input at -3dB at
    /// center.
    #[default]
    EqualPower3dB = 0,
    /// Same as [`FadeCurve::EqualPower3dB`], but each input will be at -6dB
    /// at center which may be better for some signals.
    EqualPower6dB,
    /// This is cheaper to compute than [`FadeCurve::EqualPower3dB`], but is less
    /// accurate in its perception of constant volume.
    SquareRoot,
    /// The cheapest to compute, but is the least accurate in its perception of
    /// constant volume for some signals (though if the signals are highly
    /// correlated such as a wet/dry mix, then this mode may actually provide
    /// better results.)
    Linear,
}

impl From<u32> for FadeCurve {
    fn from(value: u32) -> Self {
        match value {
            0 => Self::EqualPower3dB,
            1 => Self::EqualPower6dB,
            2 => Self::SquareRoot,
            _ => Self::Linear,
        }
    }
}

impl From<usize> for FadeCurve {
    fn from(value: usize) -> Self {
        match value {
            0 => Self::EqualPower3dB,
            1 => Self::EqualPower6dB,
            2 => Self::SquareRoot,
            _ => Self::Linear,
        }
    }
}