Szymon Mrozek
Szymon Mrozek

Reputation: 117

InstallTapOnBus - for output signal

As in topic subject, I want to analyze buffer of the output signal. I've used this function ( InstallTapOnBus ) for microphone signal, but i does not work for output. Anyone know how do that?

    let bus = 0 
    let node = engine.outputNode
    node.installTap(onBus: bus, bufferSize: AVAudioFrameCount(BUFFER_SIZE), format: node.outputFormat(forBus: bus), block: { (buffer : AVAudioPCMBuffer ,time : AVAudioTime) in

        ...

    })
    try! engine.start()
}

It provides me an error : "required condition is false: _isInput"

Upvotes: 5

Views: 1185

Answers (2)

Nick
Nick

Reputation: 1278

Try mainMixerNode instead of outputNode.

This worked for me (iOS 12):

let outputNode = self.audioEngine.mainMixerNode let format = self.audioEngine.mainMixerNode.outputFormat(forBus: 0)

Then installTap on mainMixerNode like you did.

Upvotes: 2

Chris
Chris

Reputation: 2907

Have you tried tapping the mixer instead of the microphone directly?

Microphone-to-mixer-to-output with Mixer Tap

Upvotes: 2

Related Questions