gpt4 book ai didi

ios - AudioKit 录音机设置与麦克风崩溃 "required condition is false: mixingDest"

转载 作者:搜寻专家 更新时间:2023-10-31 22:17:56 24 4
gpt4 key购买 nike

我希望有人能帮我解决这个问题。我正在尝试进行基本的录音设置,但 AudioKit 在我身上崩溃了,我确定这是我的错,我没有做正确的事情。这是我的设置。在我的 viewDidLoad 中,我像这样配置 AudioKit:

// Session settings
do {
AKSettings.bufferLength = .short
try AKSettings.setSession(category: .playAndRecord, with: .allowBluetoothA2DP)
} catch {
AKLog("Could not set session category.")
}

AKSettings.defaultToSpeaker = true

// Setup the microphone
micMixer = AKMixer(mic)
micBooster = AKBooster(micMixer)

// Load the test player
let path = Bundle.main.path(forResource: "audio1", ofType: ".wav")
let url = URL(fileURLWithPath: path!)
testPlayer = AKPlayer(url: url)
testPlayer?.isLooping = true

// Setup the test mixer
testMixer = AKMixer(testPlayer)

// Pass the output from the player AND the mic into the recorder
recordingMixer = AKMixer(testMixer, micBooster)
recorder = try? AKNodeRecorder(node: recordingMixer)

// Setup the output mixer - only pass the player NOT the mic
outputMixer = AKMixer(testMixer)

// Pass the output mixer to AudioKit
AudioKit.output = outputMixer

// Start AudioKit
do {
try AudioKit.start()
} catch {
print("AudioKit did not start! \(error)")
}

应用构建良好,但一旦我触发 recorder.record(),应用就会崩溃并显示消息:

required condition is false: mixingDest.

我真的不想将麦克风传递到扬声器输出,但我确实想要录音。

我希望能够通过“testPlayer”播放文件,通过扬声器收听,同时能够记录“testPlayer”和麦克风的输出,而不需要通过扬声器。

我确信这是可行的,但我不太了解这些东西应该如何工作,无法知道我做错了什么。

非常感谢任何帮助!!

最佳答案

好的,在与 AudioKit 人员交谈后,我发现问题是因为我的 recordingMixer 没有连接到 AudioKit.output。为了通过混音器拉取音频,需要将其连接到 AudioKit.output。

为了使我的 recordingMixer 的输出静音,我必须创建一个静音的虚拟录音混音器,并将其传递给 outputMixer。

请参阅下面更新的示例:

// Session settings
do {
AKSettings.bufferLength = .short
try AKSettings.setSession(category: .playAndRecord, with: .allowBluetoothA2DP)
} catch {
AKLog("Could not set session category.")
}

AKSettings.defaultToSpeaker = true

// Setup the microphone
micMixer = AKMixer(mic)
micBooster = AKBooster(micMixer)

// Load the test player
let path = Bundle.main.path(forResource: "audio1", ofType: ".wav")
let url = URL(fileURLWithPath: path!)
testPlayer = AKPlayer(url: url)
testPlayer?.isLooping = true

// Setup the test mixer
testMixer = AKMixer(testPlayer)

// Pass the output from the player AND the mic into the recorder
recordingMixer = AKMixer(testMixer, micBooster)
recorder = try? AKNodeRecorder(node: recordingMixer)

// Create a muted mixer for recording audio, so AudioKit will pull audio through the recording Mixer, but not play it through the output.
recordingDummyMixer = AKMixer(recordingMixer)
recordingDummyMixer.volume = 0

outputMixer = AKMixer(testMixer, recordingDummyMixer)

// Pass the output mixer to AudioKit
AudioKit.output = outputMixer

// Start AudioKit
do {
try AudioKit.start()
} catch {
print("AudioKit did not start! \(error)")
}

我希望这对以后的人有帮助。

关于ios - AudioKit 录音机设置与麦克风崩溃 "required condition is false: mixingDest",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50659870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com