AudioKit - How do you tap an AKMicrophone's data to an array of doubles?

Viewed 331

I need to get the data from AKMicrophone in raw form so i can make a custom plot. All of the examples from AudioKit use their built in plots, but I need to use a plot I made. The input my plot is expecting is an array of Doubles, but im not very worried about typing since I can change that. I just cant get a tap to access the data working correctly. I have already looked at these: https://groups.google.com/forum/#!searchin/audiokit/tap%7Csort:date/audiokit/V16xV7zZzPM/wuJjmhG8BwAJ AudioKit - How to get Real Time floatChannelData from Microphone?

but these answers really just show examples from the audiokit examples which aren't helpful for what i need

Here is my attempt, which instantly crashes saying "required condition is false: [AVAEGraphNode.mm:851:CreateRecordingTap: (nullptr == Tap())] 2018-12-27 13:13:25.628188-0700"

mic.avAudioNode.installTap(onBus: 0, bufferSize: 
AVAudioFrameCount(bufferSize), format: nil) { [weak self] (buffer, _) in
                guard let strongSelf = self else {
                    AKLog("Unable to create strong reference to self")
                    return
                }
            buffer.frameLength = AVAudioFrameCount(strongSelf.bufferSize)
                let offset = Int(buffer.frameCapacity - buffer.frameLength)
                if let tail = buffer.floatChannelData?[0] {
                    print(tail)
                }
       }
0 Answers
Related