I would like to record some sound using a AVAudioEngine
custom microphone as well. I already have a working sample, but I just can't figure out how to specify the output format I want ...
My requirement would be what I need AVAudioPCMBuffer
, as I say what he is currently doing ...
Do I need to add a separate node that does some transcoding? I can not find a lot of documentation / samples on this issue ...
And so am I. When it comes to Audio-Stuff. I know that I want to NSData
contain PCM-16bit with a maximum sampling frequency of 16000 (8000 would be better)
Here is my working example:
private var audioEngine = AVAudioEngine()
func startRecording() {
let format = audioEngine.inputNode!.inputFormatForBus(bus)
audioEngine.inputNode!.installTapOnBus(bus, bufferSize: 1024, format: format) { (buffer: AVAudioPCMBuffer, time:AVAudioTime) -> Void in
let audioFormat = PCMBuffer.format
print("\(audioFormat)")
}
audioEngine.prepare()
do {
try audioEngine.start()
} catch { }
}
If I changed the format to say "
let format = AVAudioFormat(commonFormat: AVAudioCommonFormat.PCMFormatInt16, sampleRate: 8000.0, channels: 1, interleaved: false)
, , , hwInput...
!!!
EDIT: AVAudioConverter
, iOS8...