我正在使用Audiokit在iOS中构建具有录音功能的卡拉OK风格的应用程序。我正在录音的同时播放音乐,以录制人声和音乐,但效果很好,我想在用户在设备上录音(不带耳机)时关闭麦克风监视功能,类似于Garageband中的功能。这将是AkSetting配置吗?
我尝试以各种顺序将AKBooster增益设置为0,但是我无法用它来录制人声。 预先感谢。
do {
try AKSettings.setSession(category: .playAndRecord, with: .allowBluetoothA2DP)
} catch {
AKLog("Could not set session category.")
}
AKSettings.defaultToSpeaker = true
AKSettings.enableEchoCancellation = true
mic = AKMicrophone()
let tape = try? AKAudioFile()
player = try? AKAudioPlayer(file: tape!)
let beatFile = try? AKAudioFile(readFileName: "candybeat.mp3")
beatPlayer = AKPlayer(audioFile: beatFile!)
mixer = AKMixer(mic)
booster = AKBooster(mixer)
mainMixer = AKMixer(beatPlayer, booster, player)
AudioKit.output = mainMixer
try? AudioKit.start()
recorder = try? AKNodeRecorder(node: mainMixer, file: tape)