logo
On this page

Headphone Monitor and Sound Channel Settings

2024-02-26

Feature Overview

ZEGO Express SDK provides headphone monitor and dual channel functions, which developers can set as needed.

  • Headphone monitor refers to headphone collection monitoring. After inserting headphones (ordinary headphones or Bluetooth headphones) into the device, you can hear the sound collected by the device's microphone from the local headphone side.
  • Dual channel refers to two sound channels. When hearing sound, you can judge the specific position of the sound source based on the phase difference of the sound between the left and right ears. ZEGO Express SDK defaults to mono audio collection. When developers have high audio quality requirements, they can enable the dual channel collection function. Through dedicated dual channel collection devices, they can collect dual channel audio data and publish streams.

Prerequisites

Before setting headphone monitor and sound channels, please ensure:

Usage Steps

Set Headphone Monitor

Enable Headphone Monitor

After enabling preview or starting publishing stream, call the enableHeadphoneMonitor interface to enable headphone monitor (i.e., enable collection monitoring). After connecting headphones, when the user makes a sound, they can hear their own voice.

Note

After enabling the headphone monitor function, it will only take effect after headphones are connected.

engine->enableHeadphoneMonitor(true);

Set Headphone Monitor Volume

After enabling preview or starting publishing stream, call the setHeadphoneMonitorVolume interface to adjust the headphone monitor volume.

The parameter "volume" is the collection headphone monitor volume, ranging from [0, 200], default is 60.

engine->setHeadphoneMonitorVolume(60);

Set Sound Channels

Set Audio Dual Channel Encoding

Before publishing stream, call the setAudioConfig method to set audio quality related configurations. The audio encoding channel parameter channel needs to be set to dual channel encoding (default is mono channel encoding), and other parameters can use default values.

ZegoAudioConfig audioConfig = ZegoAudioConfig(ZEGO_AUDIO_CONFIG_PRESET_HIGH_QUALITY_STEREO);
ZegoExpressSDK::getEngine()->setAudioConfig(audioConfig);

Set Audio Collection Dual Channel Mode

Note

For audio collection dual channel mode, the publishing side needs to use a device that supports dual channel collection as the audio input source. Generally, mobile phone microphones do not support dual channel collection.

Call the setAudioCaptureStereoMode method, and set the "Mode" parameter (default is not enabling dual channel, i.e., mono channel collection) to "Always enable dual channel collection" according to the actual scenario to enable audio dual channel collection.

ZegoExpressSDK::getEngine()->setAudioCaptureStereoMode(ZEGO_AUDIO_CAPTURE_STEREO_MODE_ALWAYS);

Publish Stream

Refer to "Publish Stream" in Quick Start - Implementation Flow. At this time, the published audio is dual channel. The playing side does not need additional configuration and can directly play streams to play dual channel audio.

Previous

Sound Level and Spectrum

Next

Voice Changer/Reverb/Stereo

On this page

Back to top