logo
On this page

Ear Monitor and Channel Settings

2024-02-26

Introduction

ZEGO Express SDK provides ear monitor and dual channel functions. Developers can set them as needed.

  • Ear monitor refers to headphone capture monitoring. After inserting headphones (ordinary headphones or Bluetooth headphones) into the device, you can hear the sound captured by the device's microphone from the local headphone side.
  • Dual channel refers to two audio 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 single-channel audio capture. When developers have high sound quality requirements, they can enable dual-channel capture functionality. Through dedicated dual-channel capture devices, dual-channel audio data can be captured and published.

Download Sample Source Code

Please refer to Download Sample Source Code to obtain the source code.

For related source code, please check the files in the "/ZegoExpressExample/Examples/AdvancedAudioProcessing/EarReturnAndChannelSettings" directory.

Prerequisites

Before setting ear monitor and channel, ensure that:

Usage Steps

Set Ear Monitor

Enable Ear Monitor

After starting preview or starting publishing stream, call the enableHeadphoneMonitor interface to enable ear monitor (that is, enable capture monitoring). After connecting headphones, when the user makes a sound, they can hear their own voice.

Note

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

engine->enableHeadphoneMonitor(true);

Set Ear Monitor Volume

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

The parameter "volume" is the capture ear monitor volume, with a value range of [0, 200] and a default of 60.

engine->setHeadphoneMonitorVolume(60);

Set Channel

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 (the default is single 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 Capture Dual Channel Mode

Note

Audio capture dual channel mode requires the publishing stream end to use a device that supports dual channel capture as the audio input source. Generally, mobile phone microphones do not support dual channel capture.

Call the setAudioCaptureStereoMode method and set the "Mode" parameter (default is not enabling dual channel, that is, single channel capture) to "Always enable dual channel capture" according to the actual scenario to enable audio dual channel capture.

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

Publish Stream

Please refer to "Publish Stream" in Quick Start - Implementation Process. At this time, the published stream audio is dual channel. The playing stream end does not need additional configuration and can directly play stream to play dual channel audio.

Previous

Sound Level and Spectrum

Next

Audio 3A Processing

On this page

Back to top