This page shows you how to set audio recording, audio mixing, and audio playback volume.
The Agora RTC SDK enables you to manage the volume of the recorded audio or the audio playback according to your scenario. For example, you can set the audio playback volume as 0 to mute a remote user in a one-to-one call.
The following diagram shows the workflow for audio volume settings.
Playback is the process of playing the received audio signal on the local playback device.
Recording is the process of sampling audio by a recording device and transmitting the recorded signal to the sender.
Before adjusting the audio volume, ensure that you have implemented the basic real-time communication functions in your project. For details, see Start a Call or Start Interactive Live Streaming.
To adjust the volume of the audio playback signal, call adjustPlaybackSignalVolume
or adjustUserPlaybackSignalVolume
.
// Set the playback audio level of all local remote users to 50
int vol = 50;
m_rtcEngine->adjustPlaybackSignalVolume(vol);
// Set the playback audio level of the specified local remote user to 50
int vol = 50;
m_rtcEngine->adjustUserPlaybackSignalVolume(vol);
When recording, mixing, or playing the audio, the onAudioVolumeIndication
callback reports the user IDs and the corresponding volumes of the speakers that are currently the loudest (three maximum) in the channel. The returned uid
is 0 for the local user.
enableAudioVolumeIndication
to be able to receive this callback.// Get the user IDs and the corresponding volumes of the speakers that are currently the loudest (three maximum) in the channel, and whether the local user is speaking.
void CAudioVolumeEventHandler::onAudioVolumeIndication(const AudioVolumeInfo * speakers, unsigned int speakerNumber, int totalVolume){
}
To adjust the volume of the audio recording signal, call adjustRecordingSignalVolume
.
// Set the recording volume to 50
int vol = 50;
m_rtcEngine->adjustRecordingSignalVolume(vol);
This section includes in-depth information about the methods in this page and links to related pages.
Agora provides an open-source AudioVolume sample project on GitHub that implements adjusting the sampling, playback, and ear-monitoring volume. You can download the sample project and view the source code.
When adjusting the audio volume, you can also refer to the following article: