2

I am looking for a way to set/change default input device inside my application. I have several different recording devices and it is very anoying to go into the control panel and change default recording device. I was looking around and I did not find anything that could help me with the problem. Application is written in c# and it is targeted for Windows Vista / Windows 7.

4 Answers 4

4

This can now (actually for quite some time already) be done very easily using the AudioSwitcher.AudioApi.CoreAudio NuGet package.

Simply create a new CoreAudioController:

var controller = new AudioSwitcher.AudioApi.CoreAudio.CoreAudioController();

Get hold of the desired device using its GUID:

var device = controller.GetDevice(Guid.Parse(...));

And lastly set it as the default playback device:

controller.DefaultPlaybackDevice = device;

Note: this answer was also posted under this question.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't really need this anymore but since you provided an answer after 13 years you do need a thumbs up. I also tried the package and it works as expected.
I tried that in my app. The very first line var controller = new AudioSwitcher.AudioApi.CoreAudio.CoreAudioController(); goes in and start throwing exceptions inside of it and ruturns a minute later but exceptions keep displaying: Exception thrown: 'System.NullReferenceException' in AudioSwitcher.AudioApi.CoreAudio.dll
1

There is no public API to do this in Vista/7 AFAIK.

For a media center launch thing I created, I had to open the control panel and send keys to the dialog, a big ugly hack, but it's the best you can do. (Or run .net reflector on media center (It is able to change it, using undocumented calls))

4 Comments

Opening control panel is not an option and I dont need it for media center, but tnx for suggestion.
Opening the control panel and automating the dialog is your only legal option
@Matthias Vance blogs.msdn.com/larryosterman/archive/2008/07/11/… see the last comment by Larry
You are right, I was confused by the answer giving in the other SO thread (user replying that it would work on Windows 7).
0

If you had Windows XP, apparently, you can do this by editing the registry. The key HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\Playback contains the name of the current default playback device.

Comments

0

Today, on. net 8's WPF, AudioSwitch AudioApi CoreAudio can no longer work, and I have found another answer. The author's method can be easily solved Use "CoreAudio" Modifying audio playback devices

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.