
The Brief
Turn a phone into a live public-address relay: speak into a Bluetooth microphone, hear it come out of a Bluetooth speaker across the room, with latency low enough that a speaker's own voice does not distract them and without the howling that normally ends this experiment in about four seconds.
This is a deceptively hard product. Every part of the mobile audio stack (Bluetooth codecs, buffer sizes, routing APIs, background execution policy) is designed for phone calls and media playback, not for a low-latency live loop between two wireless devices in the same room.

Architecture: a Portable Core, Thin Platform Shells
All the signal processing lives in a platform-independent C++ core, so the DSP is written and tested once and each platform only contributes its audio I/O and routing. The chain runs echo control, then noise suppression, gain, feedback suppression, and a limiter, and reports its own algorithmic latency.
- Lock-free ring buffer between input and output callbacks. No allocation, no locks, no logging on the audio thread, which is where most real-time audio bugs are actually born.
- Look-ahead brickwall limiter at -1 dBFS and a smoothed 20 ms gain ramp, so nothing clips and nothing zippers.
- Feedback suppressor: 2048-point FFT, a howl detected by narrowness and persistence rather than loudness alone, answered with a narrow notch that auto-releases after five seconds instead of permanently dulling the sound.
- Noise suppressor: STFT spectral gating with a minimum-statistics floor, adding about 5 ms of latency, cheap enough to keep in the live path.
The Hard Problem: Echo the Platform Cannot Cancel
Field testing produced heavy echo and howling whenever the microphone and the PA speaker shared a room. The platform's built-in echo canceller is designed for handset-length echo paths, a few tens of milliseconds. A Bluetooth speaker on the far side of a room is 150 to 400 ms away. An order of magnitude outside what it handles.
The relay knows exactly what it sent to the speaker, so the echo is that known signal, delayed and coloured. I built a three-stage canceller around that fact:
- Delay estimation with GCC-PHAT. Plain cross-correlation smears periodic audio into a ridge of false peaks; phase-transform whitening produces a sharp impulse at the true lag. It locks onto an exact delay even under heavy double talk, and is guarded by sharpness gating and a two-agreeing-estimates rule before it accepts anything.
- An NLMS adaptive filter anchored so most of its coverage sits on the reverb tail, with leaky norm-capped weights and a freeze-and-decay rule: if the filter ever adds energy, adaptation stops. It cannot make things worse than doing nothing.
- A residual suppressor that ducks only what survives, only in echo-dominated moments, gated by a double-talk detector, so someone speaking near the mic is never chopped up.
Every stage has a failure-safe rule attached. In real-time audio, an adaptive component without a guard rail does not degrade gracefully; it screams.
Making the Platform Cooperate
The Android engine opens a full-duplex low-latency path, requesting exclusive mode with automatic fallback, and adapts its buffer at runtime: it grows after repeated underruns and shrinks again after clean minutes, so a bad device gets stability and a good device keeps its latency. Excess buffering above the target is dropped rather than accumulated into drift.
Routing covers LE Audio, Bluetooth SCO, A2DP, wired and USB, with codec badges so the user can see what they are actually connected on, verified route confirmation with retry, and a graceful path when a device silently falls back to classic Bluetooth. Disconnects pause and auto-resume within a minute; an unstable link raises a banner instead of failing silently. A foreground service, audio focus, wake lock, phone-call pause and resume, and sticky session restore keep a long session alive against Android's power management.
Verification
The DSP core is covered by automated tests that assert behaviour, not just execution: the limiter never exceeds its ceiling, gain stays monotonic with no zipper, the feedback detector fires on howls and ignores bursts and then releases, noise suppression clears a measurable margin on stationary noise while preserving transients, and the delay estimator locks the correct lag under double talk. The app also ships an in-app round-trip latency test using normalised cross-correlation.
Honest status: the DSP and engine are verified in automated tests and on emulator, with an in-app latency estimator in the field. The definitive hardware round-trip benchmark across real Bluetooth devices is in progress. That number will be published when it is measured, not before.
Why It Matters Commercially
The same portable core is the asset. The signal processing is not tied to Android, so an iOS build reuses the tested DSP and adds only its own audio I/O layer, and the identical architecture applies to hearing assistance, tour-guide systems, live translation relays, and any product where audio has to move between devices in real time.