# Audio You can control user audio in ongoing session using methods provided by the Video SDK. > Prior to using audio and video controls, you must **request permissions to use the microphone**. See the rest of this page for details and [Requesting Authorization for Media Capture on macOS](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos?language=objc) for more. ## Audio controls Using the SDK functions, you can provide users in a session with controls for managing their audio. Session hosts can manage their own audio as well the audio of other users in the session. Some common features that you might want to include in your app could be an option to mute or unmute a user's audio. Prior to changing the audio control, you may also need to obtain data about the state of each users' audio and present it in the UI of your app. The following sections show some examples of audio and video controls. ## Check if the user is connected to audio Before you can use audio controls, you must first check if the user is connected to audio by getting the user's `ZMVideoSDKAudioType`. ```swift // Get the user\'s audioStatus if let audioStatus = user.getAudioStatus() { // Get the user\'s audioType. let audioType = audioStatus.getAudioType() } ``` ```objectivec // Get the user\'s audioStatus. ZMVideoSDKAudioStatus *audioStatus = [user getAudioStatus]; // Get the user\'s audioType. ZMVideoSDKAudioType audioType = [audioStatus getAudioType]; ``` ## Connect to audio If the user is not already connected, you can connect to the audio through the `ZMVideoSDKAudioHelper`. ```swift if audioType == ZMVideoSDKAudioType_None { // User\'s audio is not connected. // Get the ZMVideoSDKAudioHelper to perform audio actions. if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() { // Connect User\'s audio. audioHelper.startAudio() } } else { // User is already connected to audio. } ``` ```objectivec if (audioType == ZMVideoSDKAudioType_None) { // User\'s audio is not connected. // Get the ZMVideoSDKAudioHelper to perform audio actions. ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedZMVideoSDK] getAudioHelper]; if (audioHelper) { // Connect User\'s audio. [audioHelper startAudio]; } } else { // User is already connected to audio. } ``` ## Mute audio Once connected, you can mute a user's audio by calling `muteAudio` with the user's ID: ```swift // Get the ZMVideoSDKAudioHelper to perform audio actions. if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() { // Mute user. audioHelper.muteAudio(user) } ``` ```objectivec // Get the ZMVideoSDKAudioHelper to perform audio actions. ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedZMVideoSDK] getAudioHelper]; if (audioHelper) { // Mute user. [audioHelper muteAudio:user]; } ``` ## Unmute audio Unmute a user's audio in a similar manner using `unMuteAudio`: ```swift // Get the ZMVideoSDKAudioHelper to perform audio actions. if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() { // Unmute user. audioHelper.unMuteAudio(user) } ``` ```objectivec // Get the ZMVideoSDKAudioHelper to perform audio actions. ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedZMVideoSDK] getAudioHelper]; if (audioHelper) { // Mute user. [audioHelper muteAudio:user]; } ``` ## Disconnect from audio To disconnect completely from audio, use `stopAudio`: ```swift // Get the ZMVideoSDKAudioHelper to perform audio actions. if let audioHelper = ZMVideoSDK.shared()?.getAudioHelper() { // Disconnect User\'s audio. audioHelper.stopAudio() } ``` ```objectivec // Get the ZMVideoSDKAudioHelper to perform audio actions. ZMVideoSDKAudioHelper *audioHelper = [[ZMVideoSDK sharedZMVideoSDK] getAudioHelper]; if (audioHelper) { // Disconnect User\'s audio. [audioHelper stopAudio]; } ``` ## Sound options By default, Zoom uses noise suppression and echo cancellation to improve the quality of the audio received by your microphone, but these audio filters can interfere with situations that require capturing the full range of audio. See [Configuring professional audio settings for Zoom Meetings](https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0059985) for details. Video SDK uses the same technology to improve audio quality, but also supports the ability to turn off these filters to capture the **original sound** of the microphone, for example, to support the use of a high-quality microphone with built-in audio filters or to capture the full audio range without noise suppression. _**Capturing the microphone's original sound disables the background noise suppression feature.**_ ### Original sound To enable original sound, set [`enableMicOriginalInput`](https://marketplacefront.zoom.us/sdk/custom/macos/interface_z_m_video_s_d_k_audio_setting_helper.html#ad3e4e8c64fcdc17bab2785f2aa60fd73) to true (`YES`) in the `ZMVideoSDKAudioSettingHelper` class. The default setting is false (`NO`). ```objectivec ZMVideoSDKAudioSettingHelper *audioSettingHelper = [[ZMVideoSDK sharedVideoSDK] getAudioSettingHelper]; [audioSettingHelper enableMicOriginalInput:YES]; ``` To disable, set `enableMicOriginalInput` to false (`NO`). ```objectivec [audioSettingHelper enableMicOriginalInput:NO]; ``` ### Background noise suppression By default, Zoom Video SDK's standard optimized audio is used for processing your microphone audio. This includes some background noise suppression and is best for most situations, but the level of background noise suppression can be adjusted to suit your needs. Set the noise suppression level using [`setSuppressBackgroundNoiseLevel`](https://marketplacefront.zoom.us/sdk/custom/macos/interface_z_m_video_s_d_k_audio_setting_helper.html#ade36bf1f0c2b7b890565698d2fd425dc) in the `ZMVideoSDKAudioSettingHelper` class. ```objectivec ZMVideoSDKAudioSettingHelper *audioSettingHelper = [[ZMVideoSDK sharedVideoSDK] getAudioSettingHelper]; [audioSettingHelper setSuppressBackgroundNoiseLevel: ZMVideoSDKSuppressBackgroundNoiseLevel_High]; ``` You can choose from [the following levels](https://marketplacefront.zoom.us/sdk/custom/macos/_z_m_video_s_d_k_def_8h.html#a9d8a7413f0358ae518a65f0ff561afa6): - `ZMVideoSDKSuppressBackgroundNoiseLevel_Auto` (the default setting) - `ZMVideoSDKSuppressBackgroundNoiseLevel_Low` - `ZMVideoSDKSuppressBackgroundNoiseLevel_Medium` - `ZMVideoSDKSuppressBackgroundNoiseLevel_High` ## Callbacks The following are examples of some audio callbacks. ### Get notified when a user's audio status has changed ```swift func onUserAudioStatusChanged(_ audioHelper: ZMVideoSDKAudioHelper!, userList userArray: [ZMVideoSDKUser]!) { // UserArray contains the users that had an audio status change. // Use helper to perform actions on a user. if let userArray = userArray { for user in userArray { // Use to check if a user's audio is muted. // If true, the user is muted. If false, the user is unmuted. if ((user.getAudioStatus().isMuted) == true) { // User's audio is not muted. } // Use to obtain a certain user's audio type. if let audioType = getAudioStatus()?.audioType { print("User has audio type: \(audioType)") } } } } ``` ```objectivec - (void)onUserAudioStatusChanged:(ZMVideoSDKAudioHelper*)audioHelper userList:(NSArray*)userArray { // UserArray contains the users that had an audio status change. // Use helper to perform actions on a user. for (int i = 0; i < userArray.count; i++) { if (userArray[i]) { // Use to check if a user's audio is muted. // If true, the user is muted. If false, the user is unmuted. if ([user getAudioStatus].isMuted) { // User's audio is not muted. } // Use to obtain a certain user's audio type. NSLog(@"User has audio type: %lu", [userArray[i] getAudioStatus].audioType); } } } ``` ### Get notified when a user's active audio changes `onUserActiveAudioChanged` is different from `onUserAudioStatusChanged`. The SDK calls `onUserActiveAudioChanged` when a given user's audio changes, it calls `onUserAudioStatusChanged` when the user's audio status changes. For example, if the user is unmuted and is using their device's microphone, `onUserActiveAudioChanged` will be triggered whenever their microphone detects a noise. ```swift func onUserActiveAudioChanged(_ audioHelper: ZMVideoSDKAudioHelper!, userList userArray: [ZMVideoSDKUser]!) { // UserArray contains the users that had an active audio change. // Use helper to perform audio actions. if let userArray = userArray { for user in userArray { // Use to see if the user is currently talking. if let audioStatus = user.getAudioStatus(), audioStatus.isTalking, let userName = user.getUserName() { print("\(userName) began talking.") } } } } ``` ```objectivec - (void)onUserActiveAudioChanged:(ZMVideoSDKAudioHelper*)audioHelper userList:(NSArray*)userArray { // UserArray contains the users that had an active audio change. // Use helper to perform audio actions. for (int i = 0; i < userArray.count; i++) { if (userArray[i]) { // Use to see if the user is currently talking. if ([userArray[i] getAudioStatus].isTalking) { NSLog(@"%@ began talking.", userArray[i].getUserName); } } } } ```