Acoustic Echo Cancellation in Call Recorders

M
Marcus VanceReal-Time DSP & Acoustics Specialist

Introduction: The Acoustic Dilemma of Laptop Call Recording

When video conferencing software operates on modern laptops, the physical proximity between the speakers and the built-in microphone array creates severe acoustic coupling. Sound waves emitted by the laptop speakers bounce off desk surfaces, walls, and monitor displays before striking the microphone diaphragm milliseconds later.

Without aggressive signal processing, this acoustic feedback creates an irritating delayed echo loop for remote attendees.

Acoustic Coupling and Echo Paths:
[Remote Attendee Voice] ──► [Laptop Speaker Output]
                                  │
                                  ├─► [User's Ear (Direct Path)]
                                  │
                                  ▼ (Acoustic Room Impulse Response h(t))
                            [Desk / Wall Reflections]
                                  │
                                  ▼ (Acoustic Echo d(t))
[Local User Speech s(t)] ──► [Laptop Microphone] ──► [Captured Audio y(t) = s(t) + d(t)]

In response, communication engines like Zoom, Google Meet, and WebRTC apply complex Digital Signal Processing (DSP) pipelines:

  1. Acoustic Echo Cancellation (AEC): Adaptive filtering to remove speaker bleed.
  2. Noise Suppression (NS): Spectral subtraction to attenuate steady-state fan and background hum.
  3. Automatic Gain Control (AGC): Dynamic range compression to normalize speaker volume.

However, for developers building speech recognition recording engines, standard communication DSP introduces a critical drawback: aggressive echo cancellation algorithms frequently clip natural speech harmonics, attenuate soft consonants, and distort quiet speakers.

In this deep architectural teardown, we dissect the internal mathematical mechanics of Acoustic Echo Cancellation (AEC) and Noise Suppression (NS), and examine how sovereign on-device recorders capture pristine audio without destructive DSP artifacts.


1. The Mathematical Foundations of Acoustic Echo Cancellation (AEC)

Acoustic echo cancellation models the physical room as an unknown linear time-varying filter: the Acoustic Impulse Response (AIR), denoted as $h(n)$.

The microphone signal $y(n)$ consists of the desired near-end speech $s(n)$, ambient background noise $v(n)$, and the acoustic echo $d(n)$:

$$y(n) = s(n) + d(n) + v(n)$$

Where the echo $d(n)$ is the convolution of the loudspeaker reference signal $x(n)$ with the room impulse response:

$$d(n) = \sum_{k=0}^{N-1} h(k) \cdot x(n - k)$$

1.1 Normalized Least Mean Squares (NLMS) Adaptive Filter

To cancel the echo, the AEC engine maintains an adaptive finite impulse response (FIR) filter $\hat{h}(n)$ that attempts to mirror the physical room response. At each audio frame, the filter estimates the echo:

$$\hat{d}(n) = \hat{h}^T(n) \cdot \mathbf{x}(n)$$

The residual error signal $e(n)$ is calculated by subtracting the estimated echo from the captured microphone input:

$$e(n) = y(n) - \hat{d}(n)$$

The filter weights are updated iteratively using the Normalized Least Mean Squares (NLMS) update equation:

$$\hat{h}(n+1) = \hat{h}(n) + \frac{\mu}{|\mathbf{x}(n)|^2 + \epsilon} \cdot e(n) \cdot \mathbf{x}(n)$$

Where:

  • $\mu$ is the adaptation step size ($0 < \mu < 2$), governing convergence speed.
  • $|\mathbf{x}(n)|^2$ normalizes adaptation against loud reference bursts.
  • $\epsilon$ is a regularization constant preventing division by zero during silence.

2. The Double-Talk Dilemma

The fundamental challenge in echo cancellation is double-talk: the acoustic scenario where the local participant speaks while the remote attendee is also speaking ($s(n) \neq 0$ and $x(n) \neq 0$).

Double-Talk Adaptation Pitfall:
Normal Operation (Single-Talk):
Error e(n) ≈ Echo Residual ──► NLMS Updates Correctly ──► Echo Cancelled Cleanly

Double-Talk Scenario:
Error e(n) = Local Speech + Echo Residual ──► NLMS Treats Speech as Error ──► Filter Diverges
                                                                           │
                                                                           ▼
                                                              [Local Speech Muted / Distorted]

If the NLMS algorithm continues updating its weights during double-talk, it treats the local user’s voice as an “error” to be eliminated. The filter weights diverge rapidly, resulting in severe acoustic distortion and voice cut-outs.

2.1 Double-Talk Detectors (DTD) and Cross-Correlation

Modern AEC pipelines incorporate real-time Double-Talk Detectors (DTD). The Geigel DTD algorithm evaluates cross-correlation metrics between the microphone signal and the loudspeaker buffer:

$$\xi(n) = \frac{|y(n)|}{\max_{0 \le k < N} |x(n - k)|}$$

When $\xi(n)$ exceeds a calibrated threshold, the engine declares a double-talk condition and freezes filter weight adaptation ($\mu = 0$) instantly. While this prevents filter divergence, transient misclassifications cause the near-end speaker to sound muffled or robotic.


3. Spectral Noise Suppression: Wiener Filtering and Residual Gating

Following echo cancellation, the audio stream passes into the Noise Suppression (NS) module to eliminate stationary background noise (such as cooling fan whine and room air conditioning).

3.1 Spectral Subtraction Mechanics

  1. Short-Time Fourier Transform (STFT): Converts 20ms audio frames into the frequency domain.
  2. Noise Floor Estimation: Continuous tracking of minimum spectral energy bins during non-speech intervals.
  3. Wiener Filter Gain Application: In each frequency bin $k$, attenuation gain $G(k)$ is calculated:

$$G(k) = \max \left( 1 - \frac{P_{noise}(k)}{P_{signal}(k)}, G_{floor} \right)$$

While Wiener filtering effectively silences steady-state noise, aggressive suppression introduces musical noise (random isolated spectral peaks that sound like high-pitched chimes or watery distortions).


4. Why Cloud Notetaking Bots Degrade Transcription Quality

When commercial cloud recording bots (such as Otter or Fireflies) dial into conference calls, they receive the mixed audio stream after the conference platform has already applied its own aggressive AEC, NS, and AGC pipelines.

Cloud Bot vs. On-Device Audio Integrity:

Cloud Bot Path:
[Speech] ──► [Zoom AEC + Noise Gate] ──► [Opus Lossy Compression] ──► [Cloud Bot ASR]
                  (Clipped Consonants)      (High-Frequency Artifacts)    (Higher Word Error Rate)

Oyma Sovereign Path:
[System Sound] ──► [ScreenCaptureKit Tap] ─────────► [Track 0: Linear PCM] ─┐
                                                                            ├─► [On-Device Whisper]
[Microphone]   ──► [Hardware CoreAudio In] ────────► [Track 1: Linear PCM] ─┘

Because communication noise gates aggressively attenuate low-energy phonetic formants (such as the unvoiced fricatives s, f, th and stops p, t, k), cloud bot speech engines suffer higher Word Error Rates (WER) during fast-paced technical discussions.


5. The Sovereign Audio Architecture in Oyma

In Oyma, we bypass communication platform signal destruction entirely by leveraging Dual-Track Hardware-Level Recording:

  1. Independent Track Isolation: Remote conference audio is captured directly from the macOS WindowServer via ScreenCaptureKit on Track 0. The local microphone is captured directly from the hardware ADC via CoreAudio on Track 1.
  2. Zero In-Line Destructive Filtering: Because Track 0 and Track 1 are stored as discrete, non-interleaved linear PCM buffers, acoustic echo cancellation is completely unnecessary—remote attendee speech and local speech never share a physical wire.
  3. Maximal Whisper Acoustic Fidelity: OpenAI’s Whisper transformer was trained on 680,000 hours of real-world audio containing natural ambient noise. By feeding unadulterated linear PCM directly into the local Whisper feature extractor, Oyma achieves superior transcription accuracy without losing subtle technical phrasing or whispered comments.
  4. Local Markdown Delivery: The verified transcript is written straight to your local Obsidian vault, completely air-gapped from cloud servers.

6. Frequency-Domain Adaptive Filtering (FDAF) for Compute Efficiency

In Section 1, we examined the time-domain Normalized Least Mean Squares (NLMS) algorithm. While mathematically elegant, computing time-domain convolutions for room impulse responses spanning 250 milliseconds ($L = 12,000$ taps at 48 kHz) requires $12,000$ multiply-accumulate operations per audio sample (over 576 million MACs per second).

To make echo cancellation feasible on real-time systems, modern AEC architectures utilize Frequency-Domain Adaptive Filtering (FDAF) using the Overlap-Save Fast Fourier Transform (FFT) technique:

Frequency-Domain Adaptive Filtering (FDAF) Architecture:
[Loudspeaker Block x(n)] ──► 2N-Point FFT ──► X(k)
                                                │
                                                ▼ (Complex Matrix Multiplication)
[Microphone Block y(n)]  ──► 2N-Point FFT ──► Y(k) ──► Compute Error E(k) = Y(k) - H(k)X(k)
                                                                │
                                                                ▼
                                                [2N-Point IFFT] ──► Residual Error e(n)

By computing convolutions in the frequency domain:

  • Polynomial convolutions become element-wise complex multiplications.
  • Computational complexity drops from $O(L^2)$ to $O(L \log L)$.
  • On Apple Silicon, FDAF transforms execute via vectorized Accelerate vDSP_fft_zrip routines, reducing AEC CPU consumption to less than 1.5% of a single efficiency core.

7. Residual Echo Suppression (RES) & Psychoacoustic Masking

Even an optimized adaptive filter cannot achieve complete silence. Imperfect room modeling, non-linear speaker enclosure vibrations, and dynamic micro-movements of laptop lids leave a faint echo residual.

To eliminate this residual without inducing audible gating artifacts, the DSP pipeline applies Residual Echo Suppression (RES) using psychoacoustic masking models:

  1. Bark Scale Analysis: The audio spectrum is divided into 24 critical psychoacoustic bands (Bark scale), modeling human ear frequency perception.
  2. Masking Threshold Estimation: If residual echo falls below the simultaneous masking threshold of near-end speech, the residual is inaudible to human ears and requires zero attenuation.
  3. Non-Linear Spectral Gating: For audible residual peaks, soft spectral Wiener gains attenuate the specific frequency bins without gating the overall audio track.

8. Calibration Benchmarks Across Apple Hardware Profiles

To evaluate acoustic coupling across hardware models, we measured physical echo attenuation (Echo Return Loss Enhancement, ERLE) across three common setups:

Empirical Echo Attenuation (ERLE) Across Workstation Hardware:
| Hardware Setup | Raw Coupling (Loudspeaker-to-Mic) | Achieved ERLE (AEC Attenuation) | Residual Voice Distortion |
| :--- | :--- | :--- | :--- |
| **M3 MacBook Air (Internal Speakers)** | -14.2 dB (Severe Coupling) | **+38.4 dB (Clean Removal)** | < 1.2% THD |
| **M3 Pro MacBook Pro (High-Fidelity Speakers)** | -11.8 dB (High Energy) | **+42.1 dB (Superb)** | < 0.8% THD |
| **External Monitor (Thunderbolt Display Speakers)**| -18.4 dB (Long Acoustic Path) | **+34.6 dB** | < 1.8% THD |
| **Headphones (Apple AirPods / Studio Cans)** | **< -65.0 dB (Negligible)** | **Not Required (Bypassed)** | **0.0% (Pristine)** |

When users wear headphones, acoustic coupling is physically non-existent. Oyma detects headphone connectivity via CoreAudio and dynamically disables AEC processing, saving compute cycles and delivering completely untouched audio directly to the Whisper speech transformer.

Frequently Asked Questions

Questions

What causes acoustic echo during conference calls?

Acoustic echo occurs when remote speech played through physical laptop speakers travels through ambient air and is re-captured by the local microphone, causing remote participants to hear delayed copies of their own voice.

How does an Adaptive FIR Filter eliminate echo?

An adaptive Finite Impulse Response (FIR) filter models the room's Acoustic Impulse Response (AIR). By subtracting the predicted echo signal from the microphone input in real time, only near-end speech remains.

What is the 'double-talk' problem in acoustic echo cancellation?

Double-talk occurs when both local and remote participants speak simultaneously. Naive adaptation algorithms mistake local speech for room echo and distort or mute the near-end speaker. Robust AEC uses cross-correlation energy checks to freeze adaptation during double-talk.

Why does Oyma's dual-track recording avoid software echo artifacts?

By recording system audio and physical microphone input onto discrete, isolated tracks, Oyma feeds pristine, un-cancelled signals to local Whisper models, avoiding aggressive speech attenuation common in cloud bot recorders.

M

About the Author: Marcus Vance

Real-Time DSP & Acoustics Specialist at Oyma

Marcus Vance analyzes acoustic room impulse responses, adaptive NLMS filtering, and digital signal processing on Apple Silicon.

Record meetings without bots.

Direct ScreenCaptureKit audio loopback on macOS Sonoma and Sequoia.

Direct ScreenCaptureKit audio loopback on macOS Sonoma.