Documentation

Support

Vivox Core SDK

Vivox Core SDK

Callback usage

Review information on each callback and it's usage.
Read time 2 minutesLast updated 20 hours ago

pf_on_audio_unit_after_capture_audio_read

This callback is the most appropriate approach to inject audio to replace the captured audio.
pf_on_audio_unit_after_capture_audio_read
returns the data as close to the audio capture device as possible based on the native device. For example, if the device performs hardware echo cancellation, this data is obtained after that step. If a user wants to inject audio to replace the captured audio, have this function overwrite the PCM frames with the data to inject. The data is then run through Vivox audio processing, such as Voice Activity Detection (VAD), Acoustic Echo Cancellation (AEC), and Automatic Gain Control (AGC).
The data must be in the following format to be written to the buffer that is pointed to by
pcm_frames
.
  • 16-bit signed integer
  • pcm_frame_count
    : The number of frames
  • channels_per_frame
    : The number of channels per frame
  • audio_frame_rate
    : The sample rate
pcm_frame_count
is the total number of frames for the period, where a frame consists of one sample for each channel. For 32 kHz, the number of frames in a 20 ms period would be 640, regardless of whether the audio is stereo or mono.

pf_on_audio_unit_before_capture_audio_sent

This callback is the most appropriate way for recording applications that are designed to capture a player’s speech.
pf_on_audio_unit_before_capture_audio_sent
is called after Vivox audio processing (such as Voice Activity Detection, Acoustic Echo Cancellation, and Automatic Gain Control) occurs, and before being transmitted to the Vivox server. It is not recommended that developers modify the media payload at this point because the metadata (for example,
is_speaking
) would no longer match the originally analyzed data.

pf_on_audio_unit_before_recv_audio_mixed

This callback is the most appropriate for adding Digital Signal Processing (DSP) effects to individual participants on the render side. This callback is called after receiving the audio from the Vivox server, and prior to mixing the audio down to a single stream. Use this callback to gain access to the per-participant audio data. If the audio frames are zeroed out in this callback, no events for remote participants in the session are generated because a zeroed-out frame plays silence for that participant.

pf_on_audio_unit_before_recv_audio_rendered

This callback is called to record applications that are designed to capture what a player hears. It is also suitable for applying effects to all voice audio, for example, when the listener is underwater or dazed.
pf_on_audio_unit_before_recv_audio_rendered
is called before rendering the audio to the render device. This action occurs after the per-participant mixdown and the application of any 3D audio effects.
This callback needs to be defined if a third-party audio package will be used to render all voice chat audio. Setting the audio frames to all zeros prevents the Vivox SDK from rendering audio to any device, but writes to the audio device will still occur. The proper way to disable Vivox’s access to a render audio device while continuing to process audio is to set the Vivox render device to 'No Device' with the
vx_req_aux_set_render_device
request.