Table of Contents

Class AutomaticGainControlEffect

Namespace
NAudio.Effects
Assembly
NAudio.Core.dll

Automatic gain control: a slow leveller that drives the signal towards a target loudness. Gain reduction (too loud) reacts faster than gain boost (too quiet) so it does not pump, and — with UseVoiceDetection — gain is frozen while no voice is present so background noise is not amplified in pauses. Pair with a LimiterEffect downstream for a brick-wall safety ceiling.

public sealed class AutomaticGainControlEffect : AudioEffect, IAudioEffect, IParameterized
Inheritance
AutomaticGainControlEffect
Implements
Inherited Members

Properties

AttackMs

Time (ms) to pull gain down when too loud. Default 50 ms.

public float AttackMs { get; set; }

Property Value

float

GainDb

The current applied gain in dB, for metering.

public float GainDb { get; }

Property Value

float

MaxGainDb

Maximum boost in dB. Default 30 dB.

public float MaxGainDb { get; set; }

Property Value

float

MinGainDb

Maximum attenuation in dB (negative). Default -20 dB.

public float MinGainDb { get; set; }

Property Value

float

Parameters

Generic parameter list (excludes Bypass/Mix, which are on the base).

public IReadOnlyList<EffectParameter> Parameters { get; }

Property Value

IReadOnlyList<EffectParameter>

ReleaseMs

Time (ms) to bring gain up when too quiet. Default 400 ms.

public float ReleaseMs { get; set; }

Property Value

float

RmsWindowMs

RMS detector window in milliseconds. Default 50 ms.

public float RmsWindowMs { get; set; }

Property Value

float

TargetDb

Target RMS level in dBFS. Default -18 dB.

public float TargetDb { get; set; }

Property Value

float

UseVoiceDetection

When true, gain is held while no voice is detected. Default true.

public bool UseVoiceDetection { get; set; }

Property Value

bool

Methods

OnConfigure(WaveFormat)

Called by Configure(WaveFormat) after the format is stored. Derived effects allocate and size their sample-rate-dependent state here.

protected override void OnConfigure(WaveFormat format)

Parameters

format WaveFormat

ProcessBlock(Span<float>)

Transforms buffer in place into the fully-wet signal. The base class handles dry/wet mixing and bypass around this call.

protected override void ProcessBlock(Span<float> buffer)

Parameters

buffer Span<float>

Reset()

Clears internal state (delay lines, envelopes, smoothers) so the next block starts as if from silence.

public override void Reset()