Last active
June 25, 2021 15:29
-
-
Save abdulajet/d0befdd0d5b6f7df0f8a626c9a916f5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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