DEV Community

困困困
困困困

Posted on Edited on

How Windows per-app audio routing actually works — and the tool I built around it

I got tired of alt-tabbing out of a game just to move music to my speakers.

Windows can do per-app audio. That's not the problem. The problem is actually using it. You open Settings, scroll, find the app, change the output, go back to the game, and then when you quit, nothing switches back. Do that a few nights in a row and you start thinking there has to be a less annoying way.

So I built SonicRoute. It's a free, GPL-3.0-licensed tray app for Windows 10/11, and honestly it started as me scratching my own itch.

The basic idea is simple. Game goes to my headset, music goes to my speakers, voice chat gets its own thing. I can scroll on the tray icon to change the volume of whatever's playing, and when the app exits, Windows returns to the previous output automatically. It also remembers which output each app used last time, so the next time it opens, it goes straight to the right device.

First-run setup

  1. Pick the devices you actually use. In Settings → Audio Devices, uncheck any device you never route to. They'll disappear from the UI and tray menu, which is most of the point. Leave the input devices you need, or you'll have nothing to talk into.
  2. Decide your volume behaviour. Settings → Interface → "Smooth volume changes" is on by default — volume jumps in 1% steps to avoid the pop of a sudden 10% jump. It also slows down volume changes for Bluetooth and other slow devices. Turn it off if you want instant jumps. Note that smooth volume can make device volume changes during transitions feel a bit laggy — that's the smoothing doing its job, not a bug.
  3. Volume key control. If you use keyboard volume keys, enable "Use keyboard volume key". But careful: in the Full edition, if your keyboard uses a nonstandard layout, the Windows media key detection can get confused. If volume stops working after enabling this, turn it off again.

How it actually works

I figured the interesting part is how Windows does it, because the API is less documented than you'd expect.

At the core, each app has an IAudioSessionControl — that's the per-app audio session. You enumerate them through IAudioSessionManager2 on the default render endpoint. Each session has a GetProcessId, a display name, and — critically — a session identifier that's a GUID, not a process ID. This is what makes per-app routing possible at all: the same app can have several sessions, and you need to target the right one.

Routing itself uses IPolicyConfig — the undocumented COM interface that Settings uses under the hood. The key call is SetPersistedDefaultAudioEndpoint, which takes a process ID, a device ID, and an ERole. Windows then persists that preference, so the next time the app starts, it goes to the same device. That's the whole "remember which output" mechanism — I don't store it, Windows does.

The tray volume wheel is IAudioEndpointVolume on the session's endpoint, and the smooth stepping is just interpolating the volume in small increments on a timer. Nothing clever, just less jarring.

Triggers and actions

The part I use most isn't the tray wheel, though. It's the automation. Six triggers, 39 actions. Minimize Spotify to the tray when it starts, switch the output when I launch a game, that kind of thing. It saves me opening the app at all most days.

What's new in v2.00

v2.00 was released on 2026-11-28.

  • Native desktop and portable executables: Full and Lite move to .NET 10 Native AOT; each x64 or Arm64 build starts fast and runs without a separate .NET install. The desktop .msix installs a Start entry and updates through the Microsoft Store, and the portable .zip runs from a folder or USB stick. I use the portable edition myself.
  • Per-app routing canvas: drag the solid line to change the primary output, click + to forward an app to another output, and drag an app from the left panel onto the canvas to add it.
  • Quick Panel: Ctrl-click to add or remove a forwarded output; Ctrl+Shift-click to switch the Windows default device. You can now also launch the Quick Panel from the system tray icon, which opens it at the mouse position.
  • SonicRoute Android app (Full only): pair on the same local network by comparing an eight-digit code on the phone with the one on the PC; then you can adjust volume, switch output and change device presets from the phone. The Android app does not currently support Bluetooth audio.
  • ADB (Full only): interactive app virtual displays, file transfer and text clipboard sync.
  • AirPlay (Full only): receive audio and screen mirroring from compatible Apple devices.

One thing I was careful about: the routing itself is saved by Windows, not by my app. Close SonicRoute and the routing stays. Uninstall it and it still stays, until you change it in Settings. That's deliberate — your audio setup shouldn't depend on my app running.

First-run setup is still the fiddliest bit, I'll admit that. Picking which devices to keep, then figuring out which output goes where. The first-run wizard helps, but it's the one part I'd still like to make smoother.

GitHub is here: https://github.com/kunkunkunQoQ/SonicRoute — v2.00, released 2026-11-28. There's a portable zip if you don't want the installer, and the source is there if you want to see how the IPolicyConfig calls actually work.

If anything feels off, or a preset's missing, pop it on GitHub — that's where I'll actually see it.

Top comments (0)