Documentation

Support

Vivox Unreal SDK

Vivox Unreal SDK

Create a dynamic voice energy meter

Learn how to create a visual meter showing voice activity.
Read time 2 minutesLast updated 2 days ago

Some application features might require a real-time visual representation of audio energy levels, sometimes called a Voice Unit (VU) meter. For example, this might be needed for a microphone check. By default, the Vivox SDK is set up to support a simple speaking or not-speaking indicator for channel participants that is based on whether voice activity is detected; for that use case, you can iterate over IChannelSession::Participants() and check for SpeechDetected() or handle IChannelSession.EventAfterParticipantUpdated events to be notified when a participant’s speaking state changes. Real-time capability requires one extra step.

Setting a "participant updated" event frequency for a speaking activity

To create a dynamic voice activity indicator, call ILoginSession::SetParticipantSpeakingUpdateRate() with a
ParticipantSpeakingUpdateRate
value of
Update1Hz
,
Update5Hz
, or
Update10Hz
. When set to one of these values, IChannelSession.EventAfterParticipantUpdated events are raised for each participant in each channel up to 1, 5, or 10 times per second, respectively, if the audio energy or other state has changed since the last event.
Due to the sensitivity on most microphones, audio energy fluctuates near continuously unless the participant has fully muted their microphone (by SDK, OS, or hardware), resulting in no audio energy or speaking state changes. Similarly,
SetParticipantSpeakingUpdateRate()
does not increase the
EventAfterParticipantUpdated
rate when joined to a channel text-only because energy and speaking state changes do not occur.
Important: It is not possible to increase participant updated event frequency only for specific participants or channels, because the setting controls all of the channels that are connected to by the
ILoginSession
.

Disabling a "participant updated" event frequency for a speaking activity

Calling ILoginSession::SetParticipantSpeakingUpdateRate() with a value of
ParticipantSpeakingUpdateRate::Never
prevents EventAfterParticipantUpdated events from getting raised due to changes in speech detection or changes in audio energy. If you are not displaying any UI related to speaking notifications or energy and do not need to track it for any other reason, this setting eliminates the minimal overhead that the
StateChange
setting involves. The separate events for a participant joining or leaving a channel continue to occur, and participants continue to get property change events when text or audio is enabled/disabled or when muted or unmuted, but events related to speaking activity do not occur, and the IParticipantProperties values for
SpeechDetected()
and
AudioEnergy()
are no longer updated and remain at their last known value.