带有麦克风崩溃的 AudioKit 录音机设置,“所需条件为假:mixedDest”

tim*_*dsn 3 ios swift audiokit

我希望有人能在这里帮助我。我正在尝试进行基本的录音设置,但 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)")
}
Run Code Online (Sandbox Code Playgroud)

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

所需条件为假:mixedDest。

我真的不想将麦克风传递给扬声器输出,但我确实想录制它。

我希望能够通过“testPlayer”播放文件,通过扬声器听到它,同时能够记录“testPlayer”和麦克风的输出,而无需将麦克风通过扬声器传回。

我确信这是可行的,但我对这些事情应该如何工作知之甚少,无法知道我做错了什么。

非常感谢任何帮助!

tim*_*dsn 7

好的,在与 AudioKit 人员交谈后,我发现问题是因为我的录音混合器未连接到 AudioKit.output。为了通过混音器提取音频,它需要连接到 AudioKit.output。

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

请参阅下面的更新示例:

// 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)")
}
Run Code Online (Sandbox Code Playgroud)

我希望这对未来的人有所帮助。