文档

​
​

Development

User Acquisition

Monetization

工业

Vivox Core SDK

Vivox Core SDK

此页面不支持所选语言。
Vivox
​
​
Vivox Core SDK
  • Overview
  • Before you begin
  • Get started
  • Release notes
  • Developer Guide
    • Client SDK basics
    • Channels
    • Presence management
    • Messaging
    • Manage audio
      • Direct voice audio access
        • Callback APIs
        • Callback usage
        • Read and alter audio data for each participant
      • In-game audio control
      • Muting
    • Couch co-op
    • Android app development
    • iOS app development
    • macOS app development
    • Windows app development
    • Real-time recording
    • Speech-to-text audio transcription
    • Text-to-speech
    • Troubleshooting
  • Reference
  • Privacy overview
  1. Vivox Core SDK documentation

Callback usage

Review information on each callback and it's usage.
阅读时间3 分钟
最后更新于 8 个月前

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.
注意
All resampling or other audio conditioning of injected data is the developer's responsibility. The buffer must always be filled. If there is no audio data, then represent this by entering 0s in that portion of the buffer.

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.

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • pf_on_audio_unit_after_capture_audio_read

    • pf_on_audio_unit_before_capture_audio_sent

    • pf_on_audio_unit_before_recv_audio_mixed

    • pf_on_audio_unit_before_recv_audio_rendered


报告此页面的问题