Designing a Noise-Cancelling & Background Music System
A ground-up walkthrough of how Zoom, Google Meet, Microsoft Teams, Krisp, Discord, WhatsApp calls and every modern voice platform strip a barking dog, a coffee grinder and a wailing siren out of your microphone — and then let you layer soft lo-fi or a corporate on-hold loop underneath your voice — without ever making you sound robotic, delayed or off-key.
The Big Idea, in One Breath
A noise-cancelling & background music system is the pipeline that takes the raw sound picked up by a microphone, separates the human voice from the noise, and optionally mixes in a curated background track — all in a few tens of milliseconds, on a laptop, phone or embedded device — before that audio is packetised, sent across the internet and heard by a remote listener as if they were in a quiet studio with you.
The hard part is that voice and noise share the same air. A door slam, a crying baby, keyboard clicks, HVAC hum and a barking dog all arrive at the microphone as one waveform. The system has to reverse-engineer that mix in real time, keep the voice, drop the rest, and then very gently add music underneath — without letting the music itself get suppressed by its own noise cancelling.
Imagine a stage sound engineer with only 20 milliseconds to react to every word. Every time you open your mouth, the engineer must instantly identify your voice among a room full of clatter, mute everything that is not you, and quietly fade in the background music you asked for — without ever letting the audience hear the wand move. A noise-cancelling system is that engineer, running silently on your device, a thousand times per second, for every participant on the call.
audio latency
suppression
no chipmunk artefacts
What This System Really Is
Before we design it, we need to pin down what “noise cancelling” and “background music” actually mean in a real-time voice platform. They are two closely related but distinct problems, and the temptation to conflate them is what produces the most frustrating bugs.
2.1 A Working Definition
A noise-cancelling & background music system is a real-time audio pipeline that, for every capture buffer coming out of the microphone, guarantees:
- the human voice is preserved with high fidelity, correct timbre and no artefacts,
- non-voice sound (fans, keyboards, traffic, dogs, sirens, room reverb) is suppressed by a target amount,
- optional background music or ambient audio can be layered below the voice on the send stream without being suppressed itself,
- the whole chain adds only a few tens of milliseconds of extra latency — well inside the perception of “real-time,”
- the pipeline can be enabled per participant, per meeting or per device, with graceful fallback when compute budget is tight.
2.2 Where You Encounter It
Video Conferencing
Zoom, Meet, Teams, Webex, Jitsi — background suppression is a headline feature; music sharing keeps webinars alive during breaks.
Voice Chat & Calls
WhatsApp, Signal, Messenger, Discord voice channels — NC keeps calls audible on noisy commutes.
Contact Centres
Support and sales calls — suppresses agent home-office noise; music-on-hold and after-hours announcements are inserted into the send.
Live Streaming
Twitch, YouTube Live, TikTok Live — talk-radio-style hosts stream with background bed music and NC to filter fan clatter.
2.3 What It Is Not
It is not the codec, not the packetiser, and not the network jitter buffer. It sits upstream of all of those — on the audio-capture side of the client, and mirrored on the render side when needed. It also is not a mastering suite: broadcast production tools have quality and latency budgets orders of magnitude different from a real-time meeting.
Think of the audio pipeline as a small factory line. The microphone is the raw material. NC is the quality-control station that removes defects. The music mixer is the packaging station that adds a branded sleeve. The codec and network are the trucks that move the finished product. Each station has its own timing budget; a stall at any one breaks the whole line.
Why It Matters So Much
Audio quality is the single most under-rated driver of user retention on voice platforms. Video can pixellate and users forgive; audio drops or garbles and users leave. Noise cancelling and controlled background audio are what turn a “phone call” into a “meeting.”
3.1 The Business & Human Problem
- Meetings from anywhere. Cafes, cars, kitchens, open-plan offices — without NC, remote work is only possible in perfect rooms.
- Cognitive load. Every distracting noise eats a slice of the listener’s attention; ten minutes of a barking dog fatigues the whole call.
- Accessibility. Hearing-impaired participants rely on clean voice for lip-sync and transcription; noisy audio breaks captions and translation.
- Brand & presence. Contact centres, sales teams, teachers — the audio quality is the brand impression. Background music is part of that brand.
- Downstream ML. Speech-to-text, summarisation, meeting notes and translation all depend on clean voice; noise degrades every AI feature that follows.
3.2 What Makes It Uniquely Hard
Harder than post-production
- Everything is real-time; there is no second pass.
- Compute budget on-device is tiny compared to a mastering studio.
- Every artefact ships to the listener — no re-do.
Harder than static filters
- Noise types are unbounded; the system must generalise.
- Voice character (children, elderly, non-native speech) must survive intact.
- Background music must not be suppressed by the system built to suppress noise.
Every design decision serves one quiet promise: the listener should feel like they are in a still room with the speaker, even when the speaker is in a coffee shop. Every millisecond and every dB in the pipeline is spent buying more of that stillness.
The Audio Signal Chain, Start to Finish
Every design choice hangs off one boring but sacred timeline: how a sample enters the microphone and exits the speaker on the other end. Get the ordering wrong and echoes, robot voices and missing music are the inevitable result.
4.1 The Capture Path
- Microphone & driver — samples at 16, 32 or 48 kHz; hardware may add its own AGC/AEC/NR that the app must control.
- Framing — audio is grouped into 10 or 20 ms frames.
- AEC (acoustic echo cancellation) — removes what the local speaker is playing so it does not leak back to the far end.
- NC (noise cancelling) — suppresses non-voice content in each frame.
- Voice Activity Detection (VAD) — decides if a frame contains speech; drives DTX and mixer gates.
- Auto Gain Control (AGC) — normalises voice level.
- Background music mixer — ducks the music behind the voice, applies loudness normalisation.
- Encoder — Opus or platform codec at target bitrate.
- Packetiser + jitter-safe transport — ships frames over the network.
4.2 The Render Path
- De-packetiser + jitter buffer.
- Decoder.
- Optional receive-side NC for participants whose devices did not run send-side NC.
- Mixer — combines multiple participants; the local user hears everyone.
- AEC reference signal — fed back to the capture path’s AEC to cancel local echo.
- Speaker / driver.
4.3 The Timing Budget That Rules Everything
| Stage | Typical budget | Notes |
|---|---|---|
| Capture framing | 10–20 ms | Frame size dictates baseline latency |
| AEC + NC + AGC | 2–8 ms | All must fit in one frame; models pruned aggressively |
| Music mixer + ducking | < 1 ms | Cheap DSP; pre-decoded music buffer |
| Encode + packetise | 1–3 ms | Opus at low complexity for real time |
| Network transit | 10–60 ms | Not controllable by client; jitter matters more than absolute |
| Decode + render | 2–4 ms | Small buffers to preserve interactivity |
| Total mouth-to-ear | ~150–250 ms | Below the “annoying delay” threshold |
Every extra millisecond of algorithmic latency (bigger DL model, larger FFT, extra look-ahead) is paid twice: once by the speaker, once by everyone waiting for their turn. Cheaper models with slightly worse worst-case suppression usually win over heavier models with worse latency.
The Building Blocks
A production noise-cancelling & background-music system is a small constellation of focused components. Each has one narrow job; the leverage is in how they compose — and in the strict discipline of who owns which sample.
Audio Capture Engine
OS microphone access, device selection, format conversion, resampling to a canonical 16 or 48 kHz internal rate.
Acoustic Echo Canceller
Uses the render-path reference signal to subtract local speaker leakage from the mic. Must run before NC.
Noise Cancellation Engine
Classical spectral subtraction, RNNoise-style DNN, or transformer-based DL model. Frame-by-frame speech-vs-noise mask.
Voice Activity Detector
Small classifier that decides whether a frame contains voice; controls DTX (silence suppression) and mixer ducking.
Automatic Gain Control
Normalises voice level; keeps loud and quiet speakers within a comfortable range.
Music Library & Loader
Local or remote library of pre-licensed tracks; loads and caches at appropriate bitrate; handles gapless loops.
Background Music Mixer
Mixes music into the voice frame post-NC; applies ducking, loudness normalisation and hard clip protection.
Codec & Packetiser
Opus, SILK or platform codec; per-participant bitrate control; forward error correction and PLC.
Adaptive Controller
Watches CPU, thermal, battery, and packet loss; picks a lighter DL model or falls back to classical NC dynamically.
Server-side NC
Optional cloud-side pass for devices too weak to run local NC; also cleans participants who did not enable it.
Telemetry & QoE
Per-frame stats (noise suppressed, MOS estimate, dropouts) tied to session IDs; feeds product analytics and A/B tests.
Licence & Rights
Music library rights, per-region blocklists, live-stream royalty reporting; separated from the audio path itself.
Noise-Cancelling Models: From Spectral Gates to Neural Nets
Noise cancelling is one of the oldest problems in signal processing, and one of the most quietly transformed by deep learning. Understanding the three generations lets us pick the right one for the right device.
6.1 Classical Spectral Subtraction
Estimate a noise floor in the frequency domain during silence, and subtract it from every subsequent frame. Cheap, deterministic, well-understood — and terrible on non-stationary noise like a dog barking or a keyboard.
- Pros: Microseconds per frame, no ML dependency, easy to reason about.
- Cons: Musical noise artefacts, poor performance on transient sounds, hurts voice under aggressive settings.
- Fits: Embedded devices, fallback path when compute is starved.
6.2 Statistical / Wiener Filters
Model speech and noise as random processes; compute a Wiener filter per frame that minimises expected error. Better than spectral subtraction on stationary noise; still struggles with speech-shaped interference and transients.
6.3 Deep Learning: RNNoise, DTLN & Transformers
RNNoise / GRU-Based
Small recurrent nets producing per-band gain masks. Runs on almost any device in real time; the workhorse of many modern voice clients.
DTLN / Dual-Signal
Combines time-domain and frequency-domain branches. Better preservation of speech naturalness; slightly heavier compute.
Transformer-Based
Attention over recent frames; superior on tough noise types (babble, sirens) but expensive; usually reserved for server-side or top-tier devices.
Personal Voice Models
Optional voiceprint enrolled locally; the model specifically preserves your voice’s spectral profile even in tough noise.
6.4 A Simplified Frame-Level API
struct NCFrame {
float[] in; // 160 samples @ 16 kHz = 10 ms
float[] reference; // AEC reference from render path
float localSNR; // hint from VAD/AGC
};
Frame ncProcess(NCFrame f, NCModelHandle model) {
// returns cleaned frame + confidence + speech probability
auto spec = fft(f.in);
auto mask = model.infer(spec, f.reference); // gain per frequency band
auto out = ifft(apply(mask, spec));
return { samples: out, speechProb: model.vad(), suppressedDb: model.gainStats() };
}6.5 Choosing the Right Model at Runtime
| Device / condition | Preferred model | Why |
|---|---|---|
| Low-power phones, thermal-throttled laptops | Classical or tiny GRU | Deterministic, low CPU, safe fallback |
| Mid-range devices in typical noise | RNNoise / DTLN | Balance of quality and cost |
| Flagship / desktop, tough noise | Transformer or personal voice | Best suppression without artefacts |
| Server-side clean-up path | Larger transformer with look-ahead | More compute available; slightly higher latency acceptable |
Never trust a single model to run everywhere. Ship a family, pick per-device at startup, and swap dynamically when CPU, thermal or battery signals go red. The controller is as important as the model.
The Background Music Layer
Adding music to a voice stream sounds simple. It is not. The music must survive the noise canceller (which is trained to kill everything that is not voice), stay legally licensed, duck under speech automatically, and never introduce clicks, pops or drift across a long call.
7.1 Where the Music Enters the Chain
The most consequential decision is where the music is injected. There are three canonical options:
| Injection point | Pros | Cons |
|---|---|---|
| Pre-NC (before noise cancelling) | Simplest to wire up | The NC model will suppress the music as “noise” |
| Post-NC, pre-codec | Music survives; deterministic ducking | Needs an explicit mixer stage; must respect codec headroom |
| Separate media track | Server-side per-listener mix; cleanest quality | SFU / MCU must support multi-track mixing; higher complexity |
Most production systems inject music post-NC, pre-codec on the send path, and additionally support a separate track for high-fidelity broadcasts.
7.2 Voice-Aware Ducking
VAD-Driven Ducking
When speech probability crosses a threshold, gently attenuate music by 8–12 dB over 100–200 ms; restore when voice pauses.
Sidechain Compression
Classical broadcast trick: music level is driven inversely by voice level in real time.
Loudness Normalisation
Music is loudness-matched (LUFS) at load time to avoid harsh transitions between tracks.
Gapless Looping
Tracks pre-processed to loop seamlessly; crossfaded at boundaries to prevent audible clicks.
7.3 Music Library, Rights & Delivery
- Pre-licensed catalogue: royalty-free packs, licensed collections, or user-uploaded tracks with responsibility statements.
- Per-region blocklists to comply with jurisdictional rights.
- Pre-decoded and cached on the device to avoid on-the-fly decoding stalls.
- Live-stream royalty reporting when broadcasts include licensed music.
7.4 Music vs Voice: The Uncomfortable Truth
Voice-first
- Voice always wins; music is a backing bed.
- Duck aggressively when the primary speaker talks.
- Users forgive a quieter track; they do not forgive muddy speech.
Music-first (broadcast)
- DJ or streaming host wants music to be prominent.
- Separate track; disable send-side NC; use hi-fi codec.
- Rights & loudness controls are stricter.
Injecting music before the NC stage, then wondering why users complain that the music “keeps disappearing.” The NC model was doing exactly what it was trained to do. Always inject after NC unless you can retrain the model to explicitly preserve licensed music tracks.
End-to-End Flow: One 20-Millisecond Frame
Enough abstraction. Let us follow one audio frame — 20 ms of a video meeting with a barking dog in the background and a lo-fi track playing beneath the speaker’s voice — from microphone to remote listener.
Capture
Microphone hands a 320-sample buffer to the audio thread at 16 kHz. Format is converted, resampled if needed, and pushed into the frame queue.
AEC removes local playback
The render-path reference (what is coming out of the local speaker) is subtracted from the mic frame. The dog and the voice remain; any far-end voice that leaked back is gone.
NC model runs
A small GRU-based NC model produces a per-band gain mask. It preserves the human voice, attenuates the dog by 25 dB, and outputs a cleaned 320-sample frame plus a speech probability of 0.94.
VAD + AGC
VAD confirms speech. AGC applies a small gain because the speaker leaned back from the mic mid-sentence, keeping loudness consistent.
Music mixer with ducking
The lo-fi track’s next 20 ms of pre-decoded audio is fetched from the loop buffer. Because speech probability is high, the music is attenuated by 10 dB and mixed under the voice.
Encode + packetise
The mixed frame is passed to the Opus encoder at 32 kbps. FEC bits are set for the current packet-loss estimate. The packet is stamped and pushed to the network.
Network + SFU
The packet reaches the media server, is fanned out to all listeners on the meeting. Selective Forwarding Unit routes to each participant based on their subscription.
Remote render
Each listener’s jitter buffer schedules the packet, the decoder produces samples, the mixer combines it with other participants, and the audio plays back in the speaker — a clean voice with warm background music underneath, no dog in sight.
Telemetry & adaptation
QoE metrics for this frame (suppression dB, speech probability, encoder queue depth) are aggregated. If CPU is climbing, the controller queues a swap to the lighter classical NC path for the next second.
Quality Attributes: The “-ilities”
Real-time audio has a very particular set of non-functional targets. It must be simultaneously low-latency, high-quality, energy-efficient, and gracefully degrading — on hardware ranging from a flagship laptop to a cheap Android phone in an underground metro.
Algorithmic Latency
< 20 ms added by NC + mixer + AGC combined. Every extra ms is felt by every participant.
Mouth-to-Ear
Total < 250 ms on typical networks; still conversational under 300 ms.
Suppression
25–35 dB on typical noises without voice distortion or musical noise artefacts.
Voice Naturalness
Preserved timbre, timing, breathing; child, elderly and accented voices unharmed.
Reliability
NC or music failures fall back silently to raw voice; no glitches, no dropouts.
Scalability
Runs on a spectrum of devices; server-side path picks up the tail of weak clients.
Efficiency
< 5% CPU on modern devices; battery-aware model swap on mobile.
Observability
Per-frame telemetry: suppression dB, MOS estimate, model in use, mixer state, packet loss.
9.1 Voice-Quality Targets
| Condition | Target | How measured |
|---|---|---|
| Quiet room, 1 speaker | MOS ≥ 4.3 | ITU P.808 crowd-sourced listening test |
| Cafe / typing / dog | MOS ≥ 4.0 | Same |
| Loud siren transient | Voice intelligibility preserved | Objective STOI + subjective test |
| Background music enabled | Music LUFS −18, duck −10 dB on voice | Loudness meters + listening panels |
Common Pitfalls & Trade-offs
Every real deployment gets bitten by the same handful of subtle bugs. Knowing them turns weeks of firefighting into a paragraph in a design review.
10.1 Ten Traps We’ve All Fallen Into
Music injected before NC
The noise canceller happily kills the music. Always inject post-NC, pre-codec on the send side.
AEC after NC
Nonlinear NC distortions break AEC’s linear model; echoes leak back. AEC must come first.
Aggressive suppression on children’s voices
Models trained mostly on adult speech mistake high-pitched voices for noise. Ship diverse training data and voice-preserving variants.
Fixed model everywhere
Transformer NC melts a low-end phone; RNNoise wastes a flagship’s NPU. Adaptive selection is mandatory.
Music loops with a click
Non-gapless loops produce a clock-like pop every N seconds. Pre-process tracks for seamless looping and crossfade at boundaries.
Latency creeps under thermal
Device gets hot; DSP thread slips; buffers grow; users hear delay. Watch scheduling delay, not just CPU %.
Bluetooth codec surprise
SCO / HFP profile drops sample rate to 8 kHz; NC model designed for 16 kHz mis-fires. Detect and adapt.
Ducking that pumps
Ducking too fast or too slow produces obvious “breathing” artefacts. Time constants matter as much as level.
DTX kills music
Silence suppression on the send stream cuts audio while music is playing but nobody is talking. DTX must respect the mixer.
Server-side clean-up fights client-side clean-up
Two NC passes stack up and voice sounds robotic. Signal per-participant which path is active and skip on the server if the client is enabled.
10.2 The Trade-offs You Cannot Avoid
Suppression vs Naturalness
- Aggressive models suppress more noise but risk voice artefacts.
- Ship conservative defaults; expose “strong suppression” only in explicit user opt-in.
Latency vs Quality
- Larger models and look-ahead improve suppression but add latency.
- The right answer is the smallest model that clears the platform’s minimum quality bar.
Context
We must decide where in the send-side audio chain background music is injected.
Decision
Inject background music after the noise-cancelling stage and before the codec, driven by a VAD-aware ducking mixer. The NC model is trained on voice preservation, not music preservation; running music through it produces suppression artefacts and inconsistent behaviour across noise conditions. Broadcast-style scenarios that need music prominence use a separate media track with NC disabled on that track.
Consequences
Music quality on regular calls is deterministic and predictable; ducking behaviour is controllable via a small set of tunable time constants. High-fidelity broadcasts require SFU support for multi-track mixing, which adds complexity but is bounded to that feature. This is the choice that keeps the common case simple and the edge case powerful.
How These Systems Evolve
Real-time speech enhancement is one of the fastest-moving subfields in applied ML. The trajectory from spectral gates to personal voice models has taken a decade, and the next decade will keep raising the bar.
Wave 1 — Spectral Gates (pre-2015)
Simple noise-gate DSP; effective on stationary hum, useless on transients. Music injected without ducking; user experience uneven.
Wave 2 — RNNoise Era (2015–2019)
Small recurrent NC models on-device. Massive quality lift. Backing tracks standardised in conferencing tools with basic ducking.
Wave 3 — DL-First Pipelines (2019–2022)
Krisp, NVIDIA Broadcast, Zoom’s NC and Meet’s Cloud NC ship end-to-end learned pipelines. Real-time transformer variants appear.
Wave 4 — Personal Voice + Multi-Track (2022–2024)
Personal voiceprints preserve individual timbre. Separate music tracks with proper rights management ship in webinar and broadcast tools.
Wave 5 — Multimodal & Neural Codecs (2024+)
Video + audio joint models suppress noise better by lip-reading; neural codecs (SoundStream, Encodec) push voice quality up while cutting bandwidth in half.
11.1 Adjacent Systems That Plug In
Speech-to-Text & Translation
Cleaner voice feeds directly improve transcription and live translation accuracy.
Meeting Summaries
NC-clean recordings produce sharper summaries and action items downstream.
Voice Biometrics
Personal voiceprints used for NC can double as authentication signals with additional protection.
Broadcast & Live-Stream
Multi-track pipelines feed live streams with proper rights, loudness compliance and localised music beds.
Key Takeaways
Noise cancelling and background music are two of the most quietly transformative features in modern communication. Every design choice here serves one goal: make a remote conversation feel like a shared, calm room — without ever calling attention to the machinery that makes it possible.
Key Takeaways
- Order matters. Capture → AEC → NC → VAD/AGC → music mixer → codec → network. Getting this order wrong causes 80% of subtle audio bugs.
- Latency is a first-class user experience. Every ms added to the algorithmic chain is felt by every participant.
- One model does not fit every device. Ship a family; pick per-device; swap dynamically under thermal / battery / CPU pressure.
- Voice preservation beats maximum suppression. Artefacts, robot voice and child-voice damage hurt more than a slightly higher noise floor.
- Music enters post-NC. Anything before NC will be treated as noise and killed.
- Ducking is a craft. Right time constants, right depth, right VAD confidence — get it wrong and the mix pumps.
- Server-side NC is a safety net. For devices too weak to run local NC, do it in the cloud — and coordinate so both sides are never active at once.
- Bluetooth and OS surprises are frequent. Sample rate drops, hardware AEC/AGC toggling, and platform mode changes must be observed and adapted to.
- Telemetry is table stakes. MOS estimates, suppression stats, model in use per session — if you cannot measure it, you cannot improve it.
- Rights are part of the design. A music library without proper licensing is a lawsuit waiting to happen; treat it as first-class as the audio stack.
The best noise-cancelling and background-music system is the one users never mention. Voices arrive clean, music plays under speakers, and remote work stops feeling like remote work. That silent, well-engineered calm is the entire reason this system exists.