【问题标题】:AudioKit recorder setup with mic crashing with "required condition is false: mixingDest"AudioKit 录音机设置,麦克风崩溃,“所需条件为假:mixedDest”
【发布时间】:2018-06-02 18:19:55
【问题描述】:

我希望有人可以在这里帮助我。我正在尝试进行基本的录音设置,但 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(),应用程序就会崩溃并显示以下消息:

要求条件为假:mixingDest。

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

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

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

非常感谢任何帮助!

【问题讨论】:

    标签: ios swift audiokit


    【解决方案1】:

    好的,所以在与 AudioKit 人员交谈后,我发现问题是因为我的录音混音器没有连接到 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)")
    }
    

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

    【讨论】:

    • recordingDummyMixer 在我的情况下不需要。 outputMixer = AKMixer(testMixer, recordingMixer) 工作正常
    • 感谢蒂姆,您的帖子很有帮助。在正在运行的引擎中更换效果 AU 时,我遇到了同样的问题。引擎找到从输入到输出的路径很重要。所以我解决了这个问题,首先将新效果器连接到混音器,然后将上游混音器连接到该效果器,然后再断开旧效果器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多