PCM is just a digital representation of an analog audio signal. Unfortunately, it does not contain any metadata about audio channels, bit depth or sample rate - all this is necessary for the correct reading of the specified PCM data. I would suggest that AVAudioPlayer will accept this PCM data wrapped in an NSData object until you can manually set these variables in the AVAudioPlayer object. Unfortunately, these variables are read-only, so even though the documentation says that AVAudioPlayer can handle everything that Core Audio can handle, it cannot process raw LPCM data.
According to zoul, I would suggest that the easiest way to do this is to add a WAV header as it informs AVPlayer about the variables needed above. It is 44 bytes, it is easy to model and it is well defined - I used the same definition as above to implement encoding and decoding of the wav header. Also, it just preceded your unchanged LPCM data.
rcw3
source share