Table of Contents

Class AcousticEchoCancellationControl

Namespace
NAudio.CoreAudioApi
Assembly
NAudio.Wasapi.dll

Controls the acoustic echo cancellation (AEC) reference stream for a capture AudioClient. Wraps the Windows IAcousticEchoCancellationControl interface.

public class AcousticEchoCancellationControl : IDisposable
Inheritance
AcousticEchoCancellationControl
Implements
Inherited Members

Remarks

AEC itself is performed by an audio processing object (APO) in the capture pipeline (supplied by the device/driver or by Windows). NAudio does not implement echo cancellation — this class only lets you nominate which render endpoint provides the loopback reference signal that the AEC effect subtracts from the microphone input.

Obtain an instance from TryGetAcousticEchoCancellationControl() after the capture stream has been initialized. Requires Windows 11 build 22621 or later, and a capture endpoint whose AEC effect supports control over the loopback reference endpoint.

Methods

Dispose()

Dispose

public void Dispose()

SetReferenceEndpoint(MMDevice)

Sets the render device that should be used as the reference stream for AEC.

public void SetReferenceEndpoint(MMDevice renderDevice)

Parameters

renderDevice MMDevice

The render device to use as the reference stream.

Exceptions

ArgumentNullException

Thrown when renderDevice is null.

SetReferenceEndpoint(string)

Sets the render endpoint that should be used as the reference stream for AEC.

public void SetReferenceEndpoint(string renderEndpointId)

Parameters

renderEndpointId string

The endpoint ID of the render endpoint (see ID), or null to let Windows pick the reference device automatically.

Exceptions

CoreAudioException

Thrown when the endpoint ID is invalid (E_INVALIDARG).

UseDefaultReferenceEndpoint()

Resets the reference stream so Windows picks the loopback reference device itself, using its own algorithm (passes a null endpoint ID).

public void UseDefaultReferenceEndpoint()