Switching audio device with a /command?

I regularly want to switch back and forth between using speakers for audio output and a USB headset. Navigating through the menus to do this each time is a little cumbersome.

I see that the following cvars exist:

  • Sound_OutputDriverIndex - the index of the entry in the Game Sound Output menu
  • Sound_OutputDriverName - the text label of the entry, e.g. “System Default”, "Speakers (2- High Definition Audio Device)

I can modify the Sound_OutputDriverIndex value with a /console command, and the Sound_OutputDriverName value changes as well, but the changes don’t take effect and audio output remains unchanged.

Is there another command that can be run that makes these cvar changes take effect?

Clicking ESC / System / Sound is cumbersome, but looking for hidden commands is chilly and relaxing? I wonder though, why you need to toggle these settings so often that manually doing so is tiring.

Once I know the commands, they can go in a macro and be a single icon click away.

(Changed forum avatar - I’m the OP)

Bit of a tricky thing here! Globally speaking it is intentionally not possible to alter most hardware-level settings via script commands, the option to do so is deliberately blocked (“tainted”) to avoid malicious (or just badly coded) addons messing with settings that could potentially cause direct performance/stability issues for players. I fear there is no option to switch audio device via script as a result, much as I can understand the desire to do so.

That said: literally unplugging the headset should usually switch the audio to the speakers, if the headset was defined as the primary audio device in Windows and the speakers are functional at that moment in time.

1 Like

Thanks for the advice. Setting Windows’ primary audio device to the headset worked. When the headset is unplugged, it reverts to speakers, then back to headset when it’s plugged in again.

WoW is just left set to ‘System Default’.

Was pretty sure I used a script via macro for this before, and I sure did. Took me 3 minutes to find it posted by another user in the US forums. copy paste:

Quickly toggle between USB headset and speakers plugged into the audio jacks-

I have speakers plugged into my sound card, and I use USB headphones when I’m on vent with friends. I made a macro to toggle game sound between the two outputs:

/run if GetCVar (“Sound_OutputDriverIndex”) == “1” then SetCVar(“Sound_OutputDriverIndex”, “2”) else SetCVar(“Sound_OutputDriverIndex”, “1”) end; Sound_GameSystem_RestartSoundSystem()

If you go to your Sound section of the game preferences, and look at the Game Sound Output pop up menu, it will show your options. count from the beginning, starting with 0, to find the number of each of your ouputs.
Mine lists 4 things: System default, USB Headset, Speakers, Digital audio out.
So System default is 0, headset is 1, speakers is 2, and digital is 3.

Replace the ‘1’ and ‘2’ in my macro with whatever numbers correspond with your outputs, and you can quickly toggle between 2 sound outputs.

In my case, I changed the 2 to 4 and works like a charm.