pub fn envelope_follow(
x: &[f32],
attack: f32,
release: f32,
out: &mut [f32],
) -> Result<(), AudioError>Expand description
Track the amplitude envelope of x with an asymmetric one-pole filter.
attack and release are the smoothing coefficients in [0, 1) applied
when the rectified input is, respectively, rising above or falling below the
current envelope value. Small coefficient = fast response, large = slow.
A “fast attack / slow release” follower uses a small attack and a large
release. The per-sample recursion is:
r = |x[n]|
coeff = if r > env { attack } else { release }
env = coeff * env + (1 - coeff) * r
out[n] = envZero-heap: writes into caller-provided out (must be at least x.len()).
§Errors
AudioError::InvalidParameterifattack/releaseare non-finite or outside[0, 1).AudioError::OutputBufferTooSmallifout.len() < x.len().