Skip to content

Instantly share code, notes, and snippets.

@abdulajet
Last active June 25, 2021 15:29
Show Gist options
  • Save abdulajet/d0befdd0d5b6f7df0f8a626c9a916f5c to your computer and use it in GitHub Desktop.
Save abdulajet/d0befdd0d5b6f7df0f8a626c9a916f5c to your computer and use it in GitHub Desktop.
func startAnalysingAudio() {
let inputNode = audioEngine.inputNode
let bus = 0
inputNode.installTap(onBus: bus, bufferSize: 2048, format: inputNode.inputFormat(forBus: bus)) { (buffer: AVAudioPCMBuffer!, time: AVAudioTime!) -> Void in
self.session.matchStreamingBuffer(buffer, at: time)
}
audioEngine.prepare()
try! audioEngine.start()
}
func stopAnalysingAudio() {
let inputNode = audioEngine.inputNode
let bus = 0
inputNode.removeTap(onBus: bus)
self.audioEngine.stop()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment