setting audio "default device"

Hi there,

I am trying to set the "default device" for sound playback and recording, ie the one that you see in the combo box if you look at the Audio tab under Control Panel->Sounds and Audio. I can get the current default device by using mixerGetID but I don't know how to change it. Does anyone know how?  
Who is Participating?
If you are using directSound then you can just enumerate the devices to choose which one you want to use:

Of course, this won't solve the setting of the default device, but unless the recent agreement with the EU changes the situation, Microsoft is keeping that technique secret.
If I remember correctly, it can be set using the waveOutOpen function, but the change does not propogate properly.  In other words, to make Windows genuinely switch is an undocumented (as of a year ago) function.

If all you need to do is control where playback ocurrs, you can use mciSendString to specify an output device.

Hope this helps.
wilsonianAuthor Commented:
Sorry, are you saying that you can't change the default devices, but you can change the devices used inside your program for both playback and recording?  Or are you saying it will work for playback but not recording?

How do you use mciSendString to specify an output device?
Thank you.
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

I'm saying that you cannot change the default device, but you can change the playback and recording devices that your program uses.  Actually, you can change the default device (after all, the control panel does it) but the interface is undocumented and even forcing the change requires a reboot without that undocumented interface.

If you know the device number you can specify the output device in mciSendString using the output command.  For example, to play the system "ding" sound to device 6:

mciSendString(_T("open \"c:\\winnt\\media\\ding.wav\" type waveaudio alias mywav wait"), 0, 0, 0);
mciSendString(_T("set mywav output 6 wait"), 0, 0, 0);
mciSendString(_T("play mywav wait"), 0, 0, 0);

You can use the waveOutOpen function to get device characteristics or to find a device by number:
wilsonianAuthor Commented:
Oh ok. We are using directSound to play and record our sound.  I guess that doesn't work then?
wilsonianAuthor Commented:
Thanks, that looks like it should work.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.