Table of Contents

Class EnvelopeFollower

Namespace
NAudio.Dsp
Assembly
NAudio.Core.dll

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

attackMilliseconds float

Attack time constant in milliseconds. Must be positive.

releaseMilliseconds float

Release time constant in milliseconds. Must be positive.

sampleRate int

Sample rate in Hz. Must be positive.

Properties

AttackMilliseconds

Attack time constant in milliseconds.

public float AttackMilliseconds { get; set; }

Property Value

float

Envelope

The current envelope value.

public float Envelope { get; }

Property Value

float

ReleaseMilliseconds

Release time constant in milliseconds.

public float ReleaseMilliseconds { get; set; }

Property Value

float

SampleRate

Sample rate in Hz. Setting it recomputes the attack and release coefficients.

public int SampleRate { get; set; }

Property Value

int

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

magnitude float

Returns

float

ProcessSample(float)

Feeds one sample (its absolute value is taken) and returns the updated envelope.

public float ProcessSample(float sample)

Parameters

sample float

Returns

float

Reset()

Resets the envelope to zero.

public void Reset()