Web Audio API Example: Sound That Follows the Ear You Pick

A Web Audio API example you can play: NOVA's UI sounds are synthesized live and panned to the ear you pick. The real audio graph, explained.

Written by
Ayoub Kada
Published on
November 27, 2026
Read time
6 min
Category

Here is a Web Audio API example you can actually play: NOVA, my hearing aid app experiment. When you switch the device from the left ear to the right ear, the confirmation sound moves with it: it plays almost fully in your left headphone for L and almost fully in your right for R. There is not a single audio file behind those UI sounds. Every tap, open and switch is synthesized live in the browser with oscillators, a noise burst, a stereo panner, a generated reverb and a compressor. Below I break down how that sound system really works, read straight from the live page, and why I think spatial feedback like this belongs in more product UI, not only in games.

What NOVA is, and why sound is the point

NOVA is a concept app for a hearing device. The live page greets the user, shows the battery, a listening mode picker (Everyday, Conversation, Outdoor, Focus), a sound environment timeline, a hearing profile for the left and right ear, and scores like speech clarity and noise exposure. The experiment card describes the idea in one line: the photo zooms into the ear, the listening modes open like petals, and the sound follows the ear you pick. The tools listed on it are Figma, Claude, the Figma MCP, Higgsfield, Kling video and Web Audio panning.

For a hearing product, sound is not decoration. It is the product. So the interface sounds had to say something about direction and space, the same way the device does. That is why I designed the audio as part of the interaction instead of adding it at the end.

How this Web Audio API example works

I opened the live page and instrumented the browser's audio API to see exactly which nodes it builds. Here is the real chain.

One audio context, built for interaction

The page creates a single AudioContext with latencyHint: 'interactive', which asks the browser for the lowest delay it can give. For UI sound that matters more than anything: a click that sounds late feels broken. Every sound goes through a master gain, then a filter, then a DynamicsCompressor with a fast 4 ms attack and a 250 ms release, so stacked sounds stay under control instead of clipping. The master gain is 0.95 when sound is on and 0 when it is off, and the on or off choice is saved in the browser so a user who mutes it stays muted.

Notes from one scale, so nothing clashes

All tones come from a fixed set of notes: D3, F#3, A3, B3, D4, E4, F#4, A4 and B4. That is a D major pentatonic set. Any two of those notes sound fine together, so fast taps never produce an ugly chord. Each sound is a sine oscillator on one of those notes plus two quieter, slightly detuned overtones (around twice and four times the base frequency) and a short filtered noise burst for the "attack". That recipe is what makes a pure sine sound like a soft glass pluck instead of a test tone.

A stereo panner on every sound

Each sound gets its own StereoPannerNode. Most UI sounds sit in the center at pan 0. The ear switch is different: picking the left ear plays an A3 at pan -0.9, picking the right ear plays it at +0.9. Not a full -1 or +1, on purpose, so it never feels like one headphone died. A separate pan sound places a D4 at up to 0.85 either side, and the open sound sweeps filtered noise from -0.35 to +0.35, so a panel opening feels like it moves across you. When the ear switches, the page also announces "Left ear" or "Right ear" in text, so the meaning does not depend on hearing the pan.

Reverb without a single audio file

The room sound comes from a ConvolverNode. Normally you load a recorded impulse response. Here the impulse is generated in code: a buffer filled with random noise that decays over time. Each sound sends a share of its signal (its "wet" amount) into that reverb, with the ear sounds at 50% wet. Zero downloads, and the space can be tuned with numbers.

UI event in NOVABase notePanWhat it tells the user
Pick left earA3 (220 Hz)-0.9The device now serves your left side
Pick right earA3 (220 Hz)+0.9The device now serves your right side
TapA4 (440 Hz)0Your touch registered
Change listening modeD4 (293.7 Hz)0The mode changed
Open a panelA3 plus a noise sweep-0.35 to +0.35Something opened and moved across the screen

Why I synthesize UI sound instead of using files

I use recorded and generated sound in other builds. Haribo Pick and Mix uses ElevenLabs, and some native experiments use real recorded sounds. For NOVA, synthesis won for three reasons.

Every sound can change with the state. The same function plays left or right depending on an argument. With files, that is two files per sound per direction.

Nothing to load. The first tap is instant because there is no file to fetch or decode.

One family. Because every tone uses the same scale, the same recipe and the same room, the whole interface sounds like one product. That is the same idea as a design system, applied to the ear. I wrote more about that thinking in UI sound design for product designers.

The limit: synthesized sound has a character. It is soft, clean and a bit musical. If your brand needs the sound of a real object, like a camera shutter or a coin, record it or generate it.

How it was built

The approach is the one I use across my AI design experiments. The screens were designed in Figma first, as the brief. Claude wrote the code from those frames through the Figma MCP. The head turn when you change ear is a pair of short videos, one turning left to right and one right to left, so the photo can turn in either direction (the experiment lists Higgsfield and Kling for its AI video). The sound layer was designed as its own small system: a scale, a recipe per event, and rules for where each sound sits in space. Other sound-first builds on the site follow the same logic, like stdo., the keyboard landing page where every key plays a Web Audio synth and you can record a loop.

What product designers can reuse

  1. Use pan for meaning, not effect. Left and right are information when the product has a left and right: ears, split views, drawers, a swipe direction.
  2. Stay off the extremes. Pan around 0.85 to 0.9 reads clearly without feeling broken.
  3. Pick a scale once. Fast repeated taps will layer. A pentatonic set keeps them pleasant.
  4. Put a compressor on the master. It protects people's ears and your mix when many sounds fire at once.
  5. Never put meaning only in sound. NOVA also announces the ear in text. Many people browse muted, and some cannot hear the difference.
  6. Ship a mute and remember it. Respect the choice across visits.

FAQ

What is the Web Audio API?

It is a browser API for generating, processing and playing audio in real time. You connect nodes, like oscillators, filters, gain, panners and reverb, into a graph that ends at the speakers. The MDN Web Audio API documentation is the best reference.

How do you pan a sound left or right in the browser?

Create a StereoPannerNode and set its pan value between -1 (full left) and 1 (full right), then connect your sound through it. MDN's StereoPannerNode reference covers it. NOVA uses -0.9 and +0.9 for the ears.

Why does Web Audio not play until I click?

Browsers block audio until the user interacts with the page. Create or resume your audio context inside a click or tap handler, and design the first sound to be a response to that action.

Is the Web Audio API free to use?

Yes. It is built into modern browsers. There is nothing to install or license, though any audio files you load still need the right license.

Try it, then design your own sound map

Open the NOVA hearing app experiment with headphones and switch ears. Then list the five events in your own product that most need feedback, and give each a note, a pan and a reason. If you want a product designer who designs the motion, interaction and sound together and ships the code, work with me as your product designer, or see how I work on large products in the ViewStats case study.

If you have a web or mobile app idea in mind or you need some advice about product design, feel free to get in touch ✉️