Scott Hanselman

Programmatically change your system's mic and speakers with NirCmd and Elgato StreamDeck

November 20, '19 Comments [4] Posted in Tools
Sponsored By

Elgato Stream DeckI've got a lot of different sound devices like USB Headphones, a formal Conference Room Speakerphone for conference calls, and 5.1 Surround Sound speakers, as well as different mics like a nice Shure XLR connected to a PV6 USB Audio Mixer, as well as the built in mics in my webcams and other devices.

There's lots of great audio apps and applets that can improve the audio switching situation on Windows. I like Audio Switcher and the similarly named https://audioswit.ch/er, for example.

You can also automatically change your audio inputs automatically depending on the app. So if you always want to record your podcast with Audacity you can tell Windows 10 to always set (lie) the audio ins and outs on an app by app basis. The app will never know the difference.

But I need to change audio a lot when I'm moving from Teams calls, recording Podcasts, and watching shows. I've got this Elgato Stream Deck that has buttons I can assign to anything. Combine the Stream Deck with the lovely NirCmd utility from NirSoft and I've got one click audio changes!

The icons are just PNGs and there's lots available online. I created a bunch of batch files (*.bat) with contents like this:

nircmdc setdefaultsounddevice "Speakers" 0

and

nircmdc setdefaultsounddevice "Headphones" 0  

The last number is 0, 1, or 2 where that means Console, Multimedia, or Communications. You can have one sound device for apps like Netflix and another for apps like Skype that identify as Communications. I just change all defaults, myself.

You can also add in commands like "setsubunitvolumedb" and others to have preset volumes and levels for line-ins. It's ideal for getting reliable results.

Elgato Stream Deck

Then just use the Stream Deck utility to assign the icon and batch file using the "System | Open" widget. Drag it over and assign and you're set! If you can't figure out what the names of your sound devices are, you can call nircmd showsoundevices.

It just took a few minutes to set this up and it'll save me a bunch of clicks every day.


Sponsor: Like C#? We do too! That’s why we've developed a fast, smart, cross-platform .NET IDE which gives you even more coding power. Clever code analysis, rich code completion, instant search and navigation, an advanced debugger... With JetBrains Rider, everything you need is at your fingertips. Code C# at the speed of thought on Linux, Mac, or Windows. Try JetBrains Rider today!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Sunday, November 24, 2019 1:25:34 PM UTC
This is such an great website. Thanks for this beautiful post.
Sunday, November 24, 2019 1:27:10 PM UTC
SO BEAUTIFUL BLOG IS THIS. GREAT KEEP IT UP!
Sunday, November 24, 2019 1:28:11 PM UTC
AMAZING WORK
Sunday, November 24, 2019 9:45:39 PM UTC
Hallo Scott,
Please inform the Windows Defender and OneDrive teams not to flag the Nirsoft utilities as malware/viruses. Even if I exclude the map where they are downloaded I still get constant virus warnings. Remark: this folder is on OneDrive for Business.

Thanks!
Bavo Bostoen
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.