Maximilian
Maximilian

Reputation: 1117

AudioKit: How to tap the same input for multiple uses (AudioKitUI + Speech Recognition)

I would like to be able to use one of AudioKitUI's components FFTView in conjunction with the input node to visually show the node input as well as perform Speech Recognition.

Per BaseTap.swift notes about taps (line 65):

// a node can only have one tap at a time installed on it
// make sure any previous tap is removed.
// We're making the assumption that the previous tap (if any)
// was installed on the same bus as our bus var.

If a node can only have one tap, how can we use the AudioKitUI components in conjunction with the actual data of those taps?

I am (successfully) tapping the input to do speech recognition as such:

audioManager.mic.avAudioNode.installTap(onBus: 0, bufferSize: 1024, format: inputFormat) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in self.recognitionRequest?.append(buffer)

however when I try to install the tap for recondition and then use FFTView, the app crashes with error -10868. This makes sense considering I can only have one tap installed, but conceptionally I don't understand how to get around this limitation. I know and have seen apps that tap an audio input, display that data, as well as process the data simultaneously. Any guidance would be so appreciated.

Upvotes: 2

Views: 510

Answers (1)

Aurelius Prochazka
Aurelius Prochazka

Reputation: 4573

Just put a series of mixers inline and do what you need to each of them. Tap each one a maximum of once.

Upvotes: 4

Related Questions