Table of Contents

Class CompressorEffect

Namespace
NAudio.Effects
Assembly
NAudio.Core.dll

Feed-forward dynamic-range compressor with a soft knee, peak or RMS detection, and attack/release ballistics. Detection is channel-linked (one gain for all channels) so the stereo image is preserved. Exposes the live gain reduction for metering.

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

Properties

AttackMs

Attack time in milliseconds. Default 10 ms.

public float AttackMs { get; set; }

Property Value

float

Detector

Level detector mode. Default Peak.

public DetectorMode Detector { get; set; }

Property Value

DetectorMode

GainReductionDb

The most recent gain reduction in dB (≥ 0), for metering.

public float GainReductionDb { get; }

Property Value

float

KneeDb

Soft-knee width in dB (0 = hard knee). Default 6 dB.

public float KneeDb { get; set; }

Property Value

float

MakeUpGainDb

Make-up gain in dB applied after compression. Default 0 dB.

public float MakeUpGainDb { 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>

Ratio

Compression ratio (≥ 1). 4 means 4:1. Default 4.

public float Ratio { get; set; }

Property Value

float

ReleaseMs

Release time in milliseconds. Default 100 ms.

public float ReleaseMs { get; set; }

Property Value

float

RmsWindowMs

RMS averaging window in milliseconds (used when Detector is RMS). Default 10 ms.

public float RmsWindowMs { get; set; }

Property Value

float

ThresholdDb

Threshold in dBFS above which compression starts. Default -18 dB.

public float ThresholdDb { get; set; }

Property Value

float

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()