How to set StockAudioPlayer to specific device?

Posted:
March 19th, 2013, 8:06 pm
by abh
The device property of StockAudioPlayer is read only. Is there a way to direct it to an audio output device other than the Windows default device (as set in Control Panel)?
Re: How to set StockAudioPlayer to specific device?

Posted:
March 20th, 2013, 6:53 pm
by Kambiz
The DeviceID is a read/write property.
Please check out the attached code.
Re: How to set StockAudioPlayer to specific device?

Posted:
March 21st, 2013, 11:32 am
by abh
Thank you! I knew I had to be missing something.

Re: How to set StockAudioPlayer to specific device?

Posted:
March 21st, 2013, 1:04 pm
by abh
The sample program doesn't seem to work for certain WAV files, in particular, GSM 6.10. It allows me to change the device ID, but when I attempt to play one of these files, I get an exception: "The specified format is not supported or cannot be translated. Use the Capabilities function to determine the supported formats."
In fact, the only device that plays these files is "Microsoft Sound Mapper" -- and it works correctly regardless of which physical device Microsoft Sound Mapper is currently pointing to. In other words, if I use Control Panel to set my default device to my USB Headset, then point the sample program at Microsoft Sound Mapper, it plays. If I set the sample program to "USB Headset Device", I get the above error. The same thing happens if I select my laptop's built in speakers -- they work if they're set as the default device, but throw this error if I select them from the output device list.
If I select a PCM format wave file, then I can select any of the devices from the device list, and they play without error.
Do you have any ideas why this is happening and what could be done to work around it? I can send a sample GSM 6.10 file if you'd like.
Thanks.
Re: How to set StockAudioPlayer to specific device?

Posted:
March 21st, 2013, 7:03 pm
by Kambiz
Most audio devices support only uncompressed audio data and of course only a subset of PCM formats. Windows sound mapper converts audio data before sending them to an audio device.
There is a "Live Convert" demo that you can use it as a guide line to convert GSM audio format to PCM on the fly.