Documentation

Support

Vivox Unreal SDK

Vivox Unreal SDK

In-game audio device selection

Allow players to select audio input and output devices.
Read time 1 minuteLast updated 2 days ago

The Vivox SDK automatically uses the system default audio input and output devices. However, you can override this behavior and provide users with a choice of which audio device to use for group voice chat independent of the audio devices that are used for the game. To perform this override, build a user interface for the game that displays a list of available devices to users that they can select a device from. Build this user interface with the following requests, where audio output devices are called render devices, and audio input devices are called capture devices:
  • VivoxCoreError IAudioDevices::SetActiveDevice(const FString \&device, const FOnSetActiveDeviceCompletedDelegate \&theDelegate=FOnSetActiveDeviceCompletedDelegate())
  • const TMap<FString, IAudioDevice *> \&IAudioDevices::AvailableDevices()
  • const IAudioDevice IAudioDevices::CommunicationDevice()
  • const IAudioDevice IAudioDevices::SystemDevice()
  • const IAudioDevice IAudioDevices::NullDevice()
  • const IAudioDevice IAudioDevices::ActiveDevice()
  • const IAudioDevice IAudioDevices::EffectiveDevice()
IAudioDevices::AvailableDevices
returns a
TMap<FString, IAudioDevice \*>
map that contains a list of every device name and its corresponding Vivox
IAudioDevice
object. Use this request to populate a drop-down menu or to find an appropriate
IAudioDevice
instance to pass in to
IAudioDevices::SetActiveDevice
.
The following code is an example of how to activate the devices that the user selects:
void UMyClass::SetAudioDevice(const IAudioDevice &inputToSet, const IAudioDevice &outputToSet){ // IClient *VivoxVoiceClient; if (VivoxVoiceClient->AudioInputDevices().ActiveDevice().Id() != inputToSet.Id()) { VivoxVoiceClient->AudioInputDevices().SetActiveDevice(inputToSet); } if (VivoxVoiceClient->AudioOutputDevices().ActiveDevice().Id() != outputToSet.Id()) { VivoxVoiceClient->AudioOutputDevices().SetActiveDevice(outputToSet); }}
When a user selects a new device, the game passes the appropriate
IAudioDevice
in to
IAudioDevices::SetActiveDevice
.
Alternately, you can pass a virtual device, such as
IAudioDevices::SystemDevice()
or
IAudioDevices::CommunicationDevice()
, in to
IAudioDevices::SetActiveDevice
to set the
ActiveDevice
to the system's default device or the system's communication device, respectively.
Set
IAudioDevices::NullDevice()
explicitly to prevent input or output.
To alert the game to changes in the IAudioDevices setup, bind to the following events:
  • IAudioDevices::EventAfterDeviceAvailableAdded
  • IAudioDevices::EventBeforeAvailableDeviceRemoved
  • IAudioDevices::EventEffectiveDeviceChanged
Binding to these events helps you to build a responsive system that can handle device hotswapping.