Files
peerspeak/src/dsp/mod.rs
T
molluskandClaude Opus 4.8 eeb725f996 feat(dsp): in-process NLMS echo canceller + headless AEC test loop
Stage A+B of the in-process AEC: a Normalized LMS adaptive-filter echo
canceller and a synthetic echo-path simulator, driven end-to-end by a new
`specview aec` command so cancellation can be measured fully headless on
conjured signals (no speakers/mic needed).

- src/dsp/echo_path.rs: EchoPath — synthetic acoustic echo (bulk delay +
  exponentially-decaying diffuse RIR, energy-normalized to a target
  attenuation) convolved over a far-end signal. Gives ground-truth echo.
- src/dsp/aec.rs: Nlms — sample-at-a-time NLMS adaptive FIR (ring-buffered
  reference history, energy-normalized update, freezable for double-talk).
  Cleaned output = mic minus the learned echo estimate.
- specview aec: far -> sim echo -> (+ optional near-end) -> cancel -> measure.
  ERLE via oracle residual (cleaned - near), broadband + early/late
  (convergence) + per voice band, optional before/after spectrograms.
- 6 new tests (path delay/attenuation, NLMS convergence >20 dB on a known
  path, frozen-filter no-op, near-end passthrough). 33 dsp tests total.

Verified: single-talk pink-noise echo cancels +14.5 -> +32.0 dB ERLE as the
filter converges; double-talk (no DTD yet) drives ERLE negative as the filter
diverges onto the near-end tone — the motivating result for Stage C (DTD).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 02:39:01 -04:00

21 lines
838 B
Rust

//! Signal-analysis toolkit: FFT, STFT spectrograms, reproducible test-signal
//! generators, objective metrics (RMS/dBFS/ERLE/per-band energy), a minimal WAV
//! reader/writer, and a 24-bit-colour terminal spectrogram renderer.
//!
//! This is a **measurement/developer aid**, not part of the real-time audio
//! path. It exists so audio work — especially echo-cancellation tuning — can be
//! evaluated with reproducible numbers and a visible spectrogram instead of
//! ear alone. The pure layers (`fft`, `window`, `stft`, `generators`, `metrics`,
//! `render`) have no I/O; `wav` is the only edge that touches the filesystem.
//! Driven from the `specview` binary (`src/bin/specview.rs`).
pub mod aec;
pub mod echo_path;
pub mod fft;
pub mod generators;
pub mod metrics;
pub mod render;
pub mod stft;
pub mod wav;
pub mod window;