I've got a data stream, specifically coming from an MP3 stream.
In an attempt to convert it to an AVAudioPCBBuffer
, I'm creating an AVAudioFormat to describe it as follows:
AVAudioFormat* format = [[AVAudioFormat alloc] initWithStreamDescription:&description];
when printing format the output is:
<AVAudioFormat 0x2818944b0: 2 ch, 48000 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame>
Now, when I'm trying to initialize the AVAudioPCMBuffer
like this:
AVAudioPCMBuffer* pcbBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:frameCount];
I get an exception:
required condition is false: isPCMFormat(fmt)
What am I doing wrong?
Thanks
You're using the wrong AVAudioBuffer
subclass. AVAudioPCMBuffer
is for uncompressed "Pulse-code modulation" audio. You want AVAudioCompressedBuffer
instead.