Link to home
Start Free TrialLog in
Avatar of wilsonian
wilsonian

asked on

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?  
 
 
Avatar of KurtVon
KurtVon

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.
Avatar of wilsonian

ASKER

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.
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_devices_and_data_types.asp
Oh ok. We are using directSound to play and record our sound.  I guess that doesn't work then?
ASKER CERTIFIED SOLUTION
Avatar of KurtVon
KurtVon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, that looks like it should work.