Manage media and devices

Updated

Implement key workflow steps required to develop a fully functional video calling app

This page shows you how to configure volume settings for audio recording, audio playback, and for the playback of music files.

Understand the tech

Agora Video SDK supports adjusting the audio volume for both recording and playback to meet practical application use-cases. For example, during a two-person call, you can mute a remote user by adjusting the playback volume setting to 0.

The figure below shows the workflow of adjusting the volume.

Playback refers to transmitting an audio signal from a sender to a recipient, where it is played back through a playback device.

Recording refers to the process in which audio signals are captured by a recording device and then sent to the transmitter.

Caution

If you set the volume too high using the signal volume adjustment methods, it may lead to audio distortion on some devices.

Prerequisites

Ensure that you have implemented the SDK quickstart in your project.

Implement volume control

Adjust playback volume

This section shows you how to adjust the audio playback signal volume using AdjustPlaybackSignalVolume.

  1. Create UMG

    Create a Slider widget named Slider_PlaybackSignalVolume for users to drag the volume bar to adjust the playback volume. In this example, set the minimum value to 0 (mute) and the maximum value to 100 (original volume), as shown in the following figure:

  2. Bind UI Events

    Create a Bind Event to On Value Changed node and connect it to the Slider_PlaybackSignalVolume widget and the OnPlaybackSignalVolumeValChanged callback. When users drag the volume bar to adjust the audio playback signal, the OnPlaybackSignalVolumeValChanged callback is triggered, as shown in the following figure:

  3. Implement Callback Function

    Create OnPlaybackSignalVolumeValChanged callback function with the following parameters:

    Input parameterData typeParameter description
    valueFloatPlayback Volume

    When this callback is triggered, the specified playback volume is obtained and assigned to the Volume parameter of Adjust Playback Signal Volume. The AdjustPlaybackSignalVolume method is called to adjust the playback volume, as shown in the following figure:

Adjust recording volume

This section shows you how to adjust the audio recording signal volume using AdjustRecordingSignalVolume.

  1. Create UMG

    Create a Slider widget named Slider_RecordingSignalVolume to enable users to adjust the recording volume. For this example, set the minimum value to 0 (mute) and the maximum value to 100 (original volume), as shown in the following figure:

  2. Bind UI Events

    Create a Bind Event to On Value Changed node and connect it to the Slider_RecordingSignalVolume widget and the OnRecordingSignalVolumeValChanged callback. When users drag the volume bar to adjust the audio recording signal, the OnRecordingSignalVolumeValChanged callback is triggered, as shown in the following figure:

  3. Implement UI Events

    Create the OnRecordingSignalVolumeValChanged callback function with the following parameters:

    Input parameterData typeParameter description
    valueFloatRecording Volume

    When the callback is triggered, the specified recording volume is obtained and assigned to the Volume parameter of Adjust Recording Signal Volume. The AdjustRecordingSignalVolume method is called to adjust the recording volume, as shown in the following figure:

    When configuring audio settings, it's essential to understand the default behavior and the options available. Here are the key points to keep in mind:

    • The SDK defaults to a device volume of 85 when using the recording device to capture audio signals.
    • A volume of 0 means mute, and a volume of 255 represents the maximum volume of the device.
    • If the SDK detects that the recording volume is too low in the current environment, it automatically increases the volume of the recording device.
    • The volume of the recording device directly influences the global volume of the device.
    • If the default recording device volume does not meet your requirements, adjust it by regulating the signal amplitude captured by the microphone or sound card.

Get volume information of users

Throughout the process of audio recording, mixing, and playback, you can obtain the user IDs and volumes of the three users with the highest instant volumes in the channel using the FOnAudioVolumeIndication callback. A returned uid of 0 represents the local user. You need to call the EnableAudioVolumeIndication method to activate the voice detection function to receive this callback.

  1. Create UMG

    Create a Button widget named Btn_EnableAudioIndication for users to control whether to enable the volume indication. As shown in the following figure:

  2. Bind UI Events

    Create a Bind Event to On Clicked node and connect it to the Btn_EnableAudioIndication widget and the OnVolumeIndicationClick callback. When users press the button to enable the volume indication, the OnVolumeIndicationClick callback is triggered, as shown in the following figure:

  3. Implement UI Events

    Create the OnVolumeIndicationClick callback function. When this callback is triggered, the Enable Audio Volume Indication method is called to enable volume indication. In this example, set the volume indication Interval to 200 milliseconds, the smoothing factor Smooth to 3, and check Report Vad to activate the voice detection function, as shown in the following figure:

  4. Add Callback Event

    1. Create the OnAudioVolumeIndication callback function with the following parameters:

      Input parameterData typeParameter description
      speakerFloatStructure Volume information of users, see FAudioVolumeInfo for details.
      totalVolumeIntegerThe total volume after mixing
    2. Enable listening to the OnAudioVolumeIndication callback, as shown in the following figure:

    3. When the OnAudioVolumeIndication callback is triggered, print the received user volume information, as shown in the following figure:

Reference

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

Sample projects

Agora provides an open-source Blueprint sample project on GitHub for your reference. To learn how to implement call volume adjustment, refer to JoinChannelAudio in the sample project.

Frequently asked questions

API reference

See also