This page will describe how to use the new Virtual Audio Playback feature. Virtual Audio Playback refers to being able to playback multichannel audio streams (both stereo & 5.1) coming from the Millicast service.
If you don't know how to publish 5.1 audio to Millicast, then refer to this documentation on how to achieve that using OBS-WebRTC.
Starting with a new scene, instantiate a
Reference Sample Scenes > Resources. We can also change the scale factor within the
VirtualStreamPlayerPrefab 0.5, and bring the
MainCamera closer to it by setting the Z-axis of the transform to
-2 so that we are within the 5.1 Speaker setup when it is instantiated:
Next, let us fill in our stream name and credentials to point to a published 5.1 stream:
Now, when we hit play, the subscriber will detect that there is 5.1 audio incoming, and will spawn a Virtual 5.1 Audio Speaker setup anchored at the subscriber within the prefab:
If you move the camera to a different position, you will be able to hear the audio coming from a different direction, since each channel is playing on a separate
AudioSource, and every
AudioSource is 3D spatialized.
You do not need the
VirtualStreamPlayerPrefab to do all that. Instead, you attach the
McSubscriber script directly to any object, and customize it however you like. You could provide provide an
AudioConfiguration scriptable object to the subscriber to tell it the properties of the
AudioSources instantiated in Auto mode:
For example, you can change the minimum and maximum distance for attenuation, the spread as well as the volume.
Resources, you can find a
StereoSpeakers prefabs which you can instantiate and customize yourself:
The main driver of these prefabs is the
VirtualAudioSpeaker script, which you can also instantiate yourself and fill with your own
AudioSource. In the Subscriber, in order to supply Virtual Speakers, you need to select the
VirtualSpeakers option from the
Audio Output Type:
A 5.1 VirtualAudioSpeaker is also able to play incoming stereo content, where only the left and right speakers will be used. Also, a 5.1 VirtualAudioSpeaker is able to adapt to a dynamic (or runtime) change of the publisher channel count.
Updated 4 months ago