avaudioconverter

Decode AAC to PCM format using AVAudioConverter Swift

泪湿孤枕 提交于 2020-02-18 05:20:26
问题 How convert AAC to PCM using AVAudioConverter, AVAudioCompressedBuffer and AVAudioPCMBuffer on Swift? On WWDC 2015, 507 Session was said, that AVAudioConverter can encode and decode PCM buffer, was showed encode example, but wasn't showed examples with decoding. I tried decode, and something doesn't work. I don't know what:( Calls: //buffer - it's AVAudioPCMBuffer from AVAudioInputNode(AVAudioEngine) let aacBuffer = AudioBufferConverter.convertToAAC(from: buffer, error: nil) //has data let

AVAudioConverter is broken in iOS 10

房东的猫 提交于 2019-12-04 08:57:28
AVAudioConverter seems broken in iOS 10. The code was working in iOS 9 and now Error Domain=NSOSStatusErrorDomain Code=-50 "(null)" is returned no matter what audio format is used. It suprises me every year, that basic library functionality stops working. func audioConverterFailureIOS10() { // Describe the audio format let inFormat = AVAudioFormat(standardFormatWithSampleRate: 44100, channels: 2) let outFormat = AVAudioFormat(standardFormatWithSampleRate: 22050, channels: 2) // Allocate buffers let outBuffer = AVAudioPCMBuffer(pcmFormat: outFormat, frameCapacity: 1024) // Create an input block