Music dipping while turn-by-turn directions play, or background music sinking under a radio DJ's voice — both are ducking. It comes from sidechain compression in broadcast and music mixing, where one track's (voice) level is detected and used to push down another track's (music) gain in real time. In Web Audio, you implement it by ramping a GainNode's gain down briefly (roughly 100-200ms) and back up.
Dropping the gain in a hard step sounds like a click, so always ramp down and back up smoothly over tens of milliseconds. A reduction of -6 to -12dB is usually enough to let the foreground cut through without burying the background completely — duck too hard and the music feels like it cut out. If the foreground sound (announcements, alerts) repeats often, ducking kicks in often too and the background warbles, so cutting the foreground's frequency is the first fix, not deeper ducking.
Used in navigation voice guidance, podcast app notification banners, and video call apps that duck background noise when someone else is detected speaking.
When to use
Use it only when a foreground sound overlaps background audio. Ramp gain down and back up smoothly — never a hard step.