Audiokit - How to Get Real Time Floatchanneldata from Microphone

AudioKit - How to get Real Time floatChannelData from Microphone?

Use a tap on which ever node you want to get the data out from. I used AKNodeOutputPlot in my quote above because its is fairly straightforward, just using that data as input for a plot, but you could take the data and do whatever with it. In this code (from AKNodeOutputPlot):

internal func setupNode(_ input: AKNode?) {
if !isConnected {
input?.avAudioNode.installTap(
onBus: 0,
bufferSize: bufferSize,
format: nil) { [weak self] (buffer, _) in

guard let strongSelf = self else {
AKLog("Unable to create strong reference to self")
return
}
buffer.frameLength = strongSelf.bufferSize
let offset = Int(buffer.frameCapacity - buffer.frameLength)
if let tail = buffer.floatChannelData?[0] {
strongSelf.updateBuffer(&tail[offset], withBufferSize: strongSelf.bufferSize)
}
}
}
isConnected = true
}

You get the buffer data in real time. Here we just send it to "updateBuffer" where it gets plotted, but instead of plotting you'd do something else.

Implementing microphone analysis with Audiokit v5

https://github.com/AudioKit/AudioKit/issues/2267 the issue should be fixed by updating to AudioKit 4.11.1 pod 'AudioKit' , '~> 4.11.1' . This version successfully compiles in Xcode 12. You also need to replace all AudioKit instances with AKManager for example: AudioKit.output = ... with AKManager.output = ...

AudioKit real-time recording and playback

For any app that uses the device microphone, you need to add the NSMicrophoneUsageDescription key to Info.plist. Once that's taken care of you just route the microphone through the effects, and set the output to the end of the chain.

import UIKit
import AudioKit

class ViewController: UIViewController {

var microphone = AKMicrophone()
var reverb = AKReverb()

override func viewDidLoad() {
super.viewDidLoad()

microphone >>> reverb
AudioKit.output = reverb
AKSettings.ioBufferDuration = 0.002 // Optional, set this to decrease latency
AudioKit.start()
}
}

iOS AudioKit: How to observe currently elapsed time while recording

After combing through the source, I came across this class AKPeriodicFunction, which is passed in the AudioKit.start() call. This will fire a closure at a given interval so you can do whatever.



Related Topics



Leave a reply



Submit