apm

package
v2.16.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package apm provides Go bindings for the WebRTC Audio Processing Module (APM). It supports echo cancellation (AEC3), noise suppression, automatic gain control, and high-pass filtering. Audio must be 48kHz int16 PCM in 10ms frames (480 samples/channel).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APM

type APM struct {
	// contains filtered or unexported fields
}

func NewAPM

func NewAPM(config APMConfig) (*APM, error)

func (*APM) Close

func (a *APM) Close()

func (*APM) GetStats

func (a *APM) GetStats() Stats

GetStats returns the current AEC statistics.

func (*APM) ProcessCapture

func (a *APM) ProcessCapture(samples []int16) error

ProcessCapture processes a 10ms capture (microphone) frame in-place. samples must contain exactly 480 * numChannels int16 values.

func (*APM) ProcessRender

func (a *APM) ProcessRender(samples []int16) error

ProcessRender processes a 10ms render (speaker/far-end) frame in-place. This feeds the echo canceller with the signal being played back. samples must contain exactly 480 * numChannels int16 values.

func (*APM) SetStreamDelayMs

func (a *APM) SetStreamDelayMs(ms int)

SetStreamDelayMs sets the delay in milliseconds between the far-end signal being rendered and arriving at the near-end microphone.

func (*APM) StreamDelayMs

func (a *APM) StreamDelayMs() int

type APMConfig

type APMConfig struct {
	EchoCanceller   bool
	GainController  bool
	HighPassFilter  bool
	NoiseSuppressor bool
	CaptureChannels int
	RenderChannels  int
}

func DefaultConfig

func DefaultConfig() APMConfig

type Stats

type Stats struct {
	EchoReturnLoss            float64 // ERL in dB (higher = more echo removed)
	EchoReturnLossEnhancement float64 // ERLE in dB (higher = better cancellation)
	DivergentFilterFraction   float64 // 0-1, fraction of time filter is divergent
	DelayMs                   int     // Estimated echo path delay
	ResidualEchoLikelihood    float64 // 0-1, likelihood of residual echo
	HasERL                    bool
	HasERLE                   bool
	HasDelay                  bool
	HasResidualEcho           bool
	HasDivergent              bool
}

Stats holds AEC statistics from the WebRTC APM.

Directories

Path Synopsis
Package webrtc provides WebRTC audio processing module (APM) source compiled via CGo.
Package webrtc provides WebRTC audio processing module (APM) source compiled via CGo.
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL