Discussion:
Selecting the correct output device using MCI
(too old to reply)
peter
2007-07-04 12:22:03 UTC
Permalink
I'm trying to build a program using the mciSendString() command in Visual C++
that plays mp3 audio files on a Windows system with two sound cards. One
thing I want to do is let the user choose which sound card the audio output
is directed to.

I can get as far as showing which devices are capable of output by using
this code :

-------------------------
iNumDevs = waveOutGetNumDevs(); // Get number of devices

for (int i = 0; (i < iNumDevs) && (i < 10); i++)
{
if (!waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS)))
_tprintf(_T("Device ID #%i: %s\n"), i, woc.szPname);
}
-------------------------


But I'm not sure how to build the MCI string to select the proper device
once I have the device id. I've tried using strings like :

open "c:\music\music.mp3" type mpegvideo alias mysong

which works for the primary device that you set in the Windows control panel
- but if I insert the device number in the string like :

open "c:\music\music.mp3" type mpegvideo 1 alias mysong

or

open "c:\music\music.mp3" type mpegvideo 1 alias mysong

Where 1 is the device id, I get this "The specified device is not open or is
not recognized by MCI." as an error message. So there is definetely something
wrong with the way I'm sending out the command. I've tried searching the MSDN
pages in the MCI section but I still am having no luck.

Can someone help use the MCI to select any soundcard on a computer with more
than one soundcard installed ?
Alessandro Angeli
2007-07-04 14:48:08 UTC
Permalink
From: "peter"
Post by peter
I'm trying to build a program using the mciSendString()
command in Visual C++ that plays mp3 audio files on a
Windows system with two sound cards. One thing I want to
do is let the user choose which sound card the audio
output is directed to.
Unless you want to support Win3.x, I'd give up on MCI and
use DirectShow, since MCI uses DirectShow anyway to play
MP3s. If you use DirectShow, you can easily enumerate the
audio renderers (as both waveOut and DirectSound devices),
select which one you want and insert it in your empty graph,
then render the file and it will be played through the
chosen device. You will also get support for whatever other
format WindowsMediaPlayer supports for free and better MP3
support if you manually choose the source filter.

http://msdn2.microsoft.com/en-us/library/ms783787.aspx
http://msdn2.microsoft.com/en-us/library/ms779732.aspx
http://msdn2.microsoft.com/en-us/library/ms787871.aspx
http://groups.google.com/group/microsoft.public.win32.programmer.directx.audio/msg/e1f5ac84ec6e439a
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
peter
2007-07-04 16:36:01 UTC
Permalink
Thanks ! I'll definitely look into DirectShow. I'm pretty new to all of this
so I wasn't sure how to start off.

Just another question - can the DirectShow stuff be run through the console
or do I have to build a dialog window for it ?

Thanks again for the links.
peter
2007-07-04 17:54:01 UTC
Permalink
Never mind, I got it in the first example.
Post by peter
Thanks ! I'll definitely look into DirectShow. I'm pretty new to all of this
so I wasn't sure how to start off.
Just another question - can the DirectShow stuff be run through the console
or do I have to build a dialog window for it ?
Thanks again for the links.
Aaron
2007-08-21 01:54:01 UTC
Permalink
Post by Alessandro Angeli
If you use DirectShow, you can easily enumerate the
audio renderers (as both waveOut and DirectSound devices),
select which one you want and insert it in your empty graph,
then render the file and it will be played through the
chosen device.
http://msdn2.microsoft.com/en-us/library/ms783787.aspx
http://msdn2.microsoft.com/en-us/library/ms779732.aspx
http://msdn2.microsoft.com/en-us/library/ms787871.aspx
http://groups.google.com/group/microsoft.public.win32.programmer.directx.audio/msg/e1f5ac84ec6e439a
Hi Alessandro,

Is there a way to associate the default Audio Renderer with another sound
device, or would each audio device driver implement its own Audio Renderer
filter? I'm working on Win CE 5.0, and it seems there is only one audio
renderer available on my platform (the default Audio Renderer). Is there a
way to tell it to output to a different device?

I've noticed some posts from Chris P. that mention some techniques using
DirectSound, but I'm not clear on how these work. Again, I'm working on Win
CE 5.0, so would this require more work from our OS designer or device driver
vendors? I think there's only one audio renderer - there are no other
similarly named filters in the registry, and I don't have the device enum
built into my platform.

It is possible that different devices on the system may be trying to output
to different devices at the same time. Does the audio renderer would
directly with the audio devices, or is there some layer in between, like a
kernel mixer? If there is a kernel mixer, is there a way to determine
whether it can actually handle multiple inputs going to multiple outputs?

Thanks for all of your help in the past.

Aaron

Loading...