Watch the video:
0:00 - Intro
1:08 - Install PowerShell Audio Plugin
2:17 - List audio devices
2:56 - Find device names
3:27 - Set default audio device with ONE COMMAND
3:50 - Creating audio device changing script
5:30 - Quick swapping Audio Device settings
6:00 - Change volume automatically
Quickly Switch Audio In/Output Devices on Windows
Using PCVR (Such as an Oculus Quest) is great, but having to switch both the audio input and output devices for both normal and communication takes more than a few clicks - and on my Windows 11 setup it can take some time while Windows thinks about it’s actions before continuing.
Why not automate it? Well, there’s a few ways. The first I’d recommend, and the second is if you hate PowerShell for some reason…
TL;DR
Step 1: Install
|
|
Step 2: Get device list
|
|
Step 3: Change audio devices
Use the following command, swapping <NAME>
for your device(s) name. If multiple devices share the text you enter (input or output) all will be set as default.
|
|
So, in my case I can swap to my Oculus using
|
|
Then back to normal audio using:
|
|
Heck, change the volume of your current output device with:
|
|
Step 4: Time saved
While not “simpler” than opening settings and changing things, it should save you some time after it’s set up.
If you’d like to learn more about everything above, scroll down and see the rest of this admittedly bloated article in full to learn more about how this works.
Switch Audio Devices with PowerShell
By default this isn’t something built-in, so we need to install a Module. This is incredibly simple to do, and basically just contains more PowerShell code, but simplified into a few commands.
Install AudioDeviceCmdlets from an Administrative PowerShell window using the following command [The link above takes you to the project’s GitHub page]:
|
|
Breakdown of commands
Now, before we start switching let’s learn about what commands we have access to:
Full documentation can be found on the project’s GitHub Page. Here’s a few snippets of the commands we can use:
|
|
There are tons of commands from controlling and viewing Volume
to the Mute
state as well. See the GitHub Page linked above.
What does this all mean?
Running a command like: Get-AudioDevice -PlaybackCommunication
or Get-AudioDevice -List
can result in something like:
|
|
Let’s simplify this by getting just what we want. As this is a PowerShell object you can surround it with $(
and )
, such as: $(Get-AudioDevice -PlaybackCommunication).Name
. This command returns:
|
|
Quickly swapping inputs and outputs
Step 1: Get names
To get the names for all your I/O devices, you can run:
|
|
This returns something like:
|
|
To get your currently default devices you can use:
|
|
This should return something like:
|
|
Step 2: Change Audio Devices
Collect the names of the devices we’ll be using, either by setting defaults yourself and running the last command, or just collecting them from the list.
I am specifically interested in swapping between these groups:
|
|
While you can change audio devices with specific device IDs, these can change over time and the only thing that shouldn’t change should be the device name. That’s why when changing devices we’ll search the list for that device’s name, but you could get and use the IDs instead.
Step 3: Create Device Change Script/Commands
To change audio devices use one of these commands:
|
|
To change devices we can search the list for the devices names. Including *
s in the quotes searches for anything that includes the text between.
Use the command in the following way, where <NAME>
is the device’s name(s) you want to search for.
|
|
So for me, I can swap to my Oculus using:
|
|
Then back to normal audio using:
|
|
Notice that the commands only have one line to change both input and output devices, that’s because I’ve used a bit of text that’s included in both the input and output device, but you may not be so lucky. In that case use 2 seperate lines such as:
|
|
I am lucky because my normal audio has the same name for input and output (Analogue 1/2 (5- Audient iD14)
), so I search for Analogue 1/2
, and my PCVR device shares Oculus Virtual Audio Device
between it’s input (Headset Microphone (Oculus Virtual Audio Device)
) and output (Headphones (Oculus Virtual Audio Device)
).
Simply create your own groups as above, and save them into .ps1
files. These are PowerShell Script files. You should be able to Double-Click on them, such as running Oculus Sound.ps1
and Desktop Sound.ps1
.
Make sure you save them as .ps1
and not .ps1.txt
. Enable show Hidden File Extensions, and save them with a plain text editor such as Notepad. Make sure when saving with Notepad, for example, All files (*.*)
- This allows you to save with file extensions other than .txt.
Step 4: Using the sound device changing scripts
It’s simple: Just run the ps1 files with PowerShell.
If double-clicking opens them with something like Notepad, then use the Open With
dialog to select PowerShell. It should be located somewhere in Windows such as C:\Windows\System32\WindowsPowerShell\powershell
.
Now multiple audio devices should change with a simple double-click saving you minutes, and over the course of however often you change audio devices probably hours of your time - especially if the Sound dialog is slow for you on Windows.
This may not seem worth the effort in the short-term, but in the long term it’s nice to quickly swap audio devices without even thinking about it!
Alternate method
Don’t like PowerShell? This StackExchange article is what inspired this post and the accompanying video.
The most upvoted post involves downloading a Nirsoft tool known as Nircmd. With this downloaded, and placed in a PATH folder (a directory listed in your system’s %PATH% variable) – or in the same folder you’re using CMD/PowerShell from, you can change audio devices in a similar fashion using the following commands:
|
|
1
means default device, and 2
means default communication device.
While this may seem simpler, I would say running one line to install and another line to swap devices is easier, as it doesn’t involve anything about knowing what PATH
is, but that’s just me.
You can, however, install using Choco or WinGet using one of the following commands:
|
|
Feel free to use whichever method you prefer.