Class EnvelopeFollower
Attack/release envelope follower (one-pole peak detector). The envelope rises towards the input magnitude with the attack time constant and falls with the release time constant. A core building block for dynamics processors (compressor, limiter, gate) and for synthesiser amplitude tracking. Allocation-free and denormal-safe.
public sealed class EnvelopeFollower
- Inheritance
-
EnvelopeFollower
- Inherited Members
Constructors
EnvelopeFollower(float, float, int)
Creates an envelope follower.
public EnvelopeFollower(float attackMilliseconds, float releaseMilliseconds, int sampleRate)
Parameters
attackMillisecondsfloatAttack time constant in milliseconds. Must be positive.
releaseMillisecondsfloatRelease time constant in milliseconds. Must be positive.
sampleRateintSample rate in Hz. Must be positive.
Properties
AttackMilliseconds
Attack time constant in milliseconds.
public float AttackMilliseconds { get; set; }
Property Value
Envelope
The current envelope value.
public float Envelope { get; }
Property Value
ReleaseMilliseconds
Release time constant in milliseconds.
public float ReleaseMilliseconds { get; set; }
Property Value
SampleRate
Sample rate in Hz. Setting it recomputes the attack and release coefficients.
public int SampleRate { get; set; }
Property Value
Methods
ProcessRectified(float)
Feeds one already-rectified, non-negative magnitude and returns the updated envelope. Use this when the caller already has a detector signal (for example an RMS estimate or a precomputed gain key).
public float ProcessRectified(float magnitude)
Parameters
magnitudefloat
Returns
ProcessSample(float)
Feeds one sample (its absolute value is taken) and returns the updated envelope.
public float ProcessSample(float sample)
Parameters
samplefloat
Returns
Reset()
Resets the envelope to zero.
public void Reset()