Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio Multiple audio listeners targeting different audio devices

Discussion in 'Audio & Video' started by Iron-Warrior, May 2, 2019.

  1. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    I'm currently developing a VR title where one player plays as a character on the desktop (either using mouse and keyboard or controller) and the other plays inside VR. This is all done locally on the same PC. I've run into a limitation, in that Unity does not seem capable of:
    1. Having multiple AudioListeners (one for the desktop player, one for the VR player)
    2. Outputting audio to different devices (primary speakers and headphones, for the desktop player and the VR one, respectively).
    Solving 1 isn't super hard, since it seems like there are some solutions out there. Solving 2 is a bit more challenging. I'm investigating if AudioStream would work, but I wanted to ask here to see if anyone had encountered this issue before and whether there was a solution. As this game is desktop VR, it would only be targeting Windows. Below you can see an example of the audio devices I would want to target.

    upload_2019-5-2_14-27-30.png

    Basically just "play the desktop player's audio from the default speakers, play the VR player's through the default headphones."

    Thanks for any help,
    Roystan
     
  2. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    For posterity: I managed to achieve the above by modifying the MultiAudioListener package to work with AudioStream's AudioSourceOutputDevice component, which allows individual AudioSources to target specific devices. As long as audio mirroring is disabled on the VR device, this works correctly.

    I haven't tested this at length beyond making a proof of concept, so take it all with a grain of salt.
     
    yaelm631 and Resonantmango like this.
  3. jezschaj

    jezschaj

    Joined:
    Aug 2, 2019
    Posts:
    1
    Hi, @Iron-Warrior I am working on a project where we are thinking to connect 2x 5.1 audio device to our system. So we would be able to accomplish 10.2 surround system. Do you think it might be possible to set two 5.1 listeners pointing to 180 degrees on opposite direction and each to be streamed to separate audio device? The reason is to be able to have sound direction from left/right, front/back, up/down. Also, it would be great if we could define the direction of each speaker box individually. Do you think it is even possible in Unity? Or could you point me to any other software which might be able to do this? Would be thankful for any help, Jakub
     
    yaelm631 likes this.