im using setMicrophone in the iOS SDK, but i dont ...
# ask-ai
m
im using setMicrophone in the iOS SDK, but i dont want the microphone sound effect to go off when toggled
t
Thanks for reaching out, Nate. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! If you'd like to disable the microphone sound effect when using
setMicrophone
in the iOS SDK, you can easily do this by configuring the
AudioManager
to use a mute mode that prevents the sound effect from playing. By default, the mute mode
.voiceProcessing
triggers a sound effect when the microphone is muted. To skip this sound, you have two great options: • `.restart`: This restarts the internal
AVAudioEngine
without mic input when muted. It might be a bit slower, but it guarantees no sound effect will play. • `.inputMixer`: This mutes the output of the input mixer. The mic indicator stays on, and no sound effect is played. You can set the mute mode like this:
Copy code
try AudioManager.shared.set(microphoneMuteMode: .restart)
or
Copy code
try AudioManager.shared.set(microphoneMuteMode: .inputMixer)
Just a quick tip: be sure to set this mode before connecting to the room or calling
setMicrophone
, as it controls how microphone muting works at the engine level. If you have any questions or need further help, feel free to ask! Sources: Sources/LiveKit/Participant/LocalParticipant.swift | README.md
m
how do i reset it afterwards so that the setMicrophone does play the sound effect again
t
Let's get your microphone mute mode reset so you can hear that familiar sound effect when muting again. To do this, simply set the mute mode back to
.voiceProcessing
. This is the default setting and it makes sure the iOS sound effect plays whenever the microphone is muted. Here’s a little snippet of code to help you out:
Copy code
do {
    try AudioManager.shared.set(microphoneMuteMode: .voiceProcessing)
} catch {
    print("Failed to set microphone mute mode: \(error)")
}
This will bring back the normal behavior you expect. Just a quick reminder—make sure your app has the necessary microphone permissions, and that your
AVAudioSession
is set up with a recording-capable category like
.playAndRecord
. This helps avoid any session-related hiccups. Sources: Tests/LiveKitTests/AudioProcessingTests.swift | LiveKitExample.xcodeproj/project.pbxproj