locked
Multiple audio output devices

    Question

  • Hi,

    It looks like we can ennumerate the audio devices available on the system, but is there any way to actually choose which audio device a MediaElement/MediaPlayer is rendering its output to? I cannot find any way to specify a device, and that is an absolute requirement for our app, since we need to play audio concurrently on multiple audio devices (could be one stream to USB headphones, another to normal speakers). Is this possible somehow, and if not, is it something you would consider adding before release?


    Thursday, October 20, 2011 12:56 AM

Answers

  • There is no high level audio way to do this.  Matthew van Eerde answer is correct.  Xaudio2 might also be a possibility however it is also low level.

    Best Wishes - Eric

    Tuesday, June 05, 2012 3:33 AM
    Moderator

All replies

  • Can you provide us more information on what you are trying to accomplish in your application?  Is this a dj type application?

    thanks

    Frank

    Thursday, October 20, 2011 5:41 PM
    Moderator
  • Exactly. We are essentially building an easy-to-use DJ application - one that is tailored for casual and semiprofessional users. I definitely see the value in providing simplified audio playback for the vast majority of apps, but for this type of application, there is no way it can work well without multiple audio outputs.

    While the music is playing for everyone else, our user must be able to listen to a preview of a song/mix through headphones, without interrupting the music for everyone else. As far as I can tell, there is currently no way to do this - even the available subset of Media Foundation seems to lag this functionality.

    There is such great device support everywhere else in this platform, so this limitation is really unfortunate, and as it stands right now, it pretty much blocks any further development for us. It may not be the most common scenario, but there is a whole class of really awesome apps that just cannot work without it, so I really hope it is something that can be resolved.

    Something as simple as a MediaElement constructor that takes a device ID could solve the whole problem for us, and I think that would be a really good place to begin. That said, if we could also, in addition to that, get back the Media Foundation support for selecting audio devices, then it would be just perfect.


    Thursday, October 20, 2011 11:35 PM
  • You can use WASAPI to play to a non-default audio device in a Metro app.

    Call Windows::Media::MediaDevice::GetAudioRenderSelector() to get a string that represents "all audio render devices"

    Pass this string to Windows::Devices::DeviceInformation::FindAllAsync(...) to get a collection of audio render devices

    Choose the audio device you want to use

    Extract the id for this device

    Call ActivateAudioInterface(id->Data, __uuidof(IAudioClient2), &pAudioClient2) to activate an IAudioClient2 on this interface

    EDIT: actually use ActivateAudioInterfaceAsync rather than ActivateAudioInterface.


    Matthew van Eerde
    Friday, October 21, 2011 5:23 PM
  • Ahh, thanks, that could work, although it seems to be a very low-level solution to something that we really do feel is missing in the higher-level API's.
    What if we want to support playing a video (eg. music videos) using a non-default audio device, could that be done, while still keeping everything in sync?

    After looking a little more into the options, we found that this might be a good solution for our scenario:

    http://msdn.microsoft.com/en-us/library/windows/apps/microsoft.directx_sdk.ixaudio2.ixaudio2.createmasteringvoice(v=VS.85).aspx

    However, we also found this comment hiding in one of the samples:

    http://code.msdn.microsoft.com/DirectX-Marble-Maze-Game-e4806345/sourcecode?fileId=43833&pathId=475252340

    // * CreateMasteringVoice now takes a device id string instead of index, requiring you to enumerate devices using
    // the new modern device enumeration APIs in Windows or the desktop MMDevice enumeration APIs
    // (Only the default device is supported for //BUILD.)

    So, would this API be a viable solution, that we can count on being available?
    And if so, can you say anything about when we might be able to actually start using it with multiple audio devices?

    Tuesday, October 25, 2011 10:23 PM
  • Hi, is there any news on this?
    Tuesday, November 08, 2011 11:39 PM
  • Is this still an issue for you?

    Best Wishes - Eric

    Saturday, March 17, 2012 2:18 AM
    Moderator
  • Have you looked into XAudio2?
    Wednesday, May 23, 2012 9:00 PM
    Moderator
  • There is no high level audio way to do this.  Matthew van Eerde answer is correct.  Xaudio2 might also be a possibility however it is also low level.

    Best Wishes - Eric

    Tuesday, June 05, 2012 3:33 AM
    Moderator