Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

setting audio "default device"

Posted on 2005-05-04
6
Medium Priority
?
535 Views
Last Modified: 2008-02-01
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?  
 
 
0
Comment
Question by:wilsonian
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:KurtVon
ID: 13936299
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.
0
 

Author Comment

by:wilsonian
ID: 13940887
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.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 13945104
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:wilsonian
ID: 13948321
Oh ok. We are using directSound to play and record our sound.  I guess that doesn't work then?
0
 
LVL 11

Accepted Solution

by:
KurtVon earned 1000 total points
ID: 13959432
If you are using directSound then you can just enumerate the devices to choose which one you want to use:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/DirectX/htm/directsounddevices.asp

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.
0
 

Author Comment

by:wilsonian
ID: 13962931
Thanks, that looks like it should work.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question