# Manage media and devices (/en/realtime-media/interactive-live-streaming/build/control-audio-and-devices/volume-control-and-mute/macos)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

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

## Understand the tech [#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.
    **Volume adjust workflow**

    ![VolumeControlMute](https://assets-docs.agora.io/images/video-sdk/volume-control-mute-adjustVolume.svg)

    **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.

    <CalloutContainer type="warning">
      <CalloutDescription>
        If you set the volume too high using the signal volume adjustment methods, it may lead to audio distortion on some devices.
      </CalloutDescription>
    </CalloutContainer>

    ## Prerequisites [#prerequisites-2]

    Ensure that you have implemented the [SDK quickstart](../../index.mdx) in your project.

    ## Implement volume control [#implement-volume-control-2]

    Use one or more of the following volume control methods to adjust volume settings.

    ### Mute and unmute users [#mute-and-unmute-users-2]

    * To mute or unmute the local audio stream, call `muteLocalAudioStream`:

      <CodeBlockTabs defaultValue="objective-c">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="objective-c">
            objc
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="swift">
            swift
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="objective-c">
          ```objc
          [agoraKit muteLocalAudioStream:YES];
          ```
        </CodeBlockTab>

        <CodeBlockTab value="swift">
          ```swift
          // Stop publishing the local audio stream
          agoraKit.muteLocalAudioStream(true)

          // Resume publishing the local audio stream
          agoraKit.muteLocalAudioStream(false)
          ```
        </CodeBlockTab>
      </CodeBlockTabs>
    * To mute or unmute a remote user, call `muteRemoteAudioStream` with the `uid` of the remote user:

      <CodeBlockTabs defaultValue="objective-c">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="objective-c">
            objc
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="swift">
            swift
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="objective-c">
          ```objc
          [agoraKit muteRemoteAudioStream:remoteUid mute:YES];
          ```
        </CodeBlockTab>

        <CodeBlockTab value="swift">
          ```swift
          // Stop subscribing to the audio stream of the remote user
          agoraKit.muteRemoteAudioStream(remoteUid, mute: true)

          // Resume subscribing to the audio stream of the remote user
          agoraKit.muteRemoteAudioStream(remoteUid, mute: false)
          ```
        </CodeBlockTab>
      </CodeBlockTabs>

    <CalloutContainer type="info">
      <CalloutDescription>
        To mute remote users without unsubscribing, set their [playback volume](#adjust-the-playback-volume) to `0`.
      </CalloutDescription>
    </CalloutContainer>

    ### Adjust the playback volume [#adjust-the-playback-volume-2]

    Call `adjustPlaybackSignalVolume` or `adjustUserPlaybackSignalVolume` to adjust the volume of the audio playback signal.

    <CodeBlockTabs defaultValue="objective-c">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="objective-c">
          objc
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="swift">
          swift
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="objective-c">
        ```objc
        // Set the volume of all remote users played locally
        [agoraKit adjustPlaybackSignalVolume: 50];
        // Set the local playback volume for a specific remote user.
        [agoraKit adjustUserPlaybackSignalVolume: uid, volume: 50];
        ```
      </CodeBlockTab>

      <CodeBlockTab value="swift">
        ```swift
        // Set the volume of all remote users played locally
        agoraKit.adjustPlaybackSignalVolume(50)
        // Set the local playback volume for a specific remote user
        agoraKit.adjustUserPlaybackSignalVolume(uid, volume: 50)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Adjust the in-ear monitoring volume [#adjust-the-in-ear-monitoring-volume-2]

    During the process of audio capture, mixing, and playback, Agora enables you to adjust the volume of in-ear monitoring. Enable and set the in-ear monitoring through `enableInEarMonitoring` and `setInEarMonitoringVolume`.

    <CodeBlockTabs defaultValue="objective-c">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="objective-c">
          objc
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="swift">
          swift
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="objective-c">
        ```objc
        // Enable in-ear monitoring
        [agoraKit enableInEarMonitoring:true];
        // Adjust in-ear monitoring volume
        [agoraKit setInEarMonitoringVolume:50];
        ```
      </CodeBlockTab>

      <CodeBlockTab value="swift">
        ```swift
        // Enable in-ear monitoring
        agoraKit.enableInEarMonitoring(true)
        // Adjust in-ear monitoring volume
        agoraKit.setInEarMonitoringVolume(50)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Adjust the recording volume [#adjust-the-recording-volume-2]

    Call `adjustRecordingSignalVolume` to adjust the volume of the audio recording signal.

    <CodeBlockTabs defaultValue="objective-c">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="objective-c">
          objc
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="swift">
          swift
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="objective-c">
        ```objc
        // Adjust the recording signal volume
        [agoraKit adjustRecordingSignalVolume: 50];
        ```
      </CodeBlockTab>

      <CodeBlockTab value="swift">
        ```swift
        // Adjust the recording signal volume
        agoraKit.adjustRecordingSignalVolume(50)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    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 [#get-volume-information-of-users-2]

    Video SDK enables you to obtain the user IDs and corresponding volumes of the three users with the highest instantaneous volumes in a channel during the process of audio recording, mixing, and playback. You use `reportAudioVolumeIndicationOfSpeakers` callback to obtain this information. A returned `uid` of `0` in the callback indicates the local user.

    <CalloutContainer type="info">
      <CalloutDescription>
        Call `enableAudioVolumeIndication` to enable reporting of the users' volume in the callback.
      </CalloutDescription>
    </CalloutContainer>

    <CodeBlockTabs defaultValue="objective-c">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="objective-c">
          objc
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="swift">
          swift
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="objective-c">
        ```objc
        // Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
        // their respective volumes, and determine whether the local user is speaking.
        - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine
        reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo *> *_Nonnull)speakers
                   totalVolume:(NSInteger)totalVolume {
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="swift">
        ```swift
        // Retrieve the user IDs of the three users with the highest instantaneous speaking volume,
        // their respective volumes, and determine whether the local user is speaking.
        func rtcEngine(
        _ engine: AgoraRtcEngineKit,
        reportAudioVolumeIndicationOfSpeakers speakers: [AgoraRtcAudioVolumeInfo],
        totalVolume: Int
        ) {
        }

        // Enable the reportAudioVolumeIndicationOfSpeakers callback
        agoraKit.enableAudioVolumeIndication(200, smooth: 3, reportVad: true)
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ## Reference [#reference-2]

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

    ### API reference [#api-reference-2]

    * [`setdevicevolume`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/setdevicevolume\(_\:volume:\))
    * [`adjustRecordingSignalVolume`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/adjustrecordingsignalvolume\(_:\))
    * [`adjustPlaybackSignalVolume`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/adjustplaybacksignalvolume\(_:\))
    * [`adjustUserPlaybackSignalVolume`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/adjustuserplaybacksignalvolumeex\(_\:volume\:connection:\))
    * [`adjustAudioMixingPlayoutVolume`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/adjustaudiomixingplayoutvolume\(_:\))
    * [`enableaudiovolumeindication`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/enableaudiovolumeindication\(_\:smooth\:reportvad:\))
    * [`muteLocalAudioStream`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agoraspatialaudiokitbase/mutelocalaudiostream\(_:\))
    * [`muteRemoteAudioStream`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcenginekit/muteremoteaudiostream\(_\:mute:\))

    ### Sample projects [#sample-projects-2]

    Agora offers the following open-source sample project for adjusting recording, playback, and in-ear monitoring volumes for your reference:

    * GitHub: [JoinChannelAudio](https://github.com/AgoraIO/API-Examples/blob/main/macOS/APIExample/Examples/Basic/JoinChannelAudio/JoinChannelAudio.swift)

    For adjusting the playback volume of mixing or audio effect files, refer to the following sample project:

    * GitHub: [AudioMixing](https://github.com/AgoraIO/API-Examples/tree/main/macOS/APIExample/Examples/Advanced/AudioMixing)

    ### Frequently asked questions [#frequently-asked-questions-2]

    * [How can I solve the problem of low volume?](/en/api-reference/faq/quality/audio_low)

    ### See also [#see-also-2]

    * [Custom audio source](custom-audio.mdx)
    * [Custom video source](custom-video.mdx)

    
  
      
  
      
  
      
  
      
  
      
  
      
  
      
  
      
  
      
  
      
  
