Documentation

Support

Vivox Unreal SDK

Vivox Unreal SDK

Audio injection

Broadcast audio from a file to all connected channels.
Read time 2 minutesLast updated 2 days ago

Note: There is a known issue with the Vivox SDK in which the local playback of the injected audio does not occur unless the file also has the same sample rate as the negotiated audio codec. Other players always hear the file correctly, regardless of sample rate. For Windows, this is normally 48kHz. Audio injection allows you to broadcast audio from a file to all connected
ChannelSessions
. Injected audio is treated like a second capture device that you are speaking into. This means that muting or disconnecting your input device does not stop others from hearing the file audio. However, muting yourself in a channel, stopping transmission to a channel, or disconnecting channel
AudioState
does stop others from hearing the file audio. Because the played file is treated as speech, it is heard by anyone that would normally hear the user, triggers speaking indicators and VU meters like speech does, and is heard by participants in accordance with the player's position and orientation in a 3D channel, or when in a 2D channel, from anywhere on the map.
Use cases for this feature include a player selecting pre-scripted audio clips in their character's voice saying things like "Enemy spotted!" or "Need healing!" to signal their situation, which is especially useful when the player does not have a microphone. Depending on your application, it might also be appropriate to let the user play music into the channel for everyone to listen to. The
EventAudioInjectionCompleted
event is raised when the file that you are injecting has reached its end, so you can use it to loop an audio track when complete, or move to the next track in a playlist. You can also use the method
IsAudioInjecting()
to check if you are currently injecting file audio.
You can broadcast only one file at a time. Calls of
BeginStartAudioInjection()
for which the completion delegate has a successful response code always begins playing the specified file from the beginning and replaces any file that was previously playing. You can stop file audio from playing at any time with
StopAudioInjection()
. Note that injecting file audio does not replace or otherwise prevent the user from speaking into their capture device and being heard as normal; it is considered to be an additional audio source.
To simulate the experience of file injection as a second spoken audio source, the file also plays locally for the user at the same time it is being transmitted to others. This means that a user playing a file into a non-positional or a positional channel hears the file slightly earlier than other participants, just like their own voice when speaking. In an echo channel, the file plays with an echo, just like your own voice. To review all methods and events that are related to audio injection, see the ILoginSession Class Reference in the Unreal API Reference Manual.