I am trying to get audio of microphone as a byte Array and then I want to convert AVAudioPCMBuffer data to audio and play it, how to convert AVAudioPCMBuffer data to audio? and is this best method to convert AVAudioPCMBuffer data audio
let audioEngine = AVAudioEngine()
func getAudio() {
let inputNode = audioEngine.inputNode
var error: NSError?
let bus = 0
inputNode.installTap(onBus: bus, bufferSize: 2048, format: inputNode.inputFormat(forBus: bus)) {
(buffer: AVAudioPCMBuffer!, time: AVAudioTime!) -> Void in
print(buffer)
}
audioEngine.prepare()
do {
try audioEngine.start()
} catch {
print("Can't start the engine: \(error)")
}
}