I'd like to use AVAudioConverter to convert audio captured from the microphone to μLaw.
Unfortunately, when I try to create an output buffer to convert into, I get an exception. I've tried both AVAudioPCMBuffer and AVAudioCompressedBuffer, and neither works for me.
Is this supposed to work?
Thanks!
let format = AVAudioFormat(settings: [AVFormatIDKey: NSNumber(value: kAudioFormatULaw), AVSampleRateKey: 8000, AVNumberOfChannelsKey: 1])
let buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: 1000)
// required condition is false: isPCMFormat
let buffer = AVAudioCompressedBuffer(format: format, packetCapacity: 1000)
// required condition is false: !(fmt.IsPCM() || fmt.mFormatID == kAudioFormatALaw || fmt.mFormatID == kAudioFormatULaw)