0
votes

source data is AMR-NB 5.9kbit/s (AMR_5.90)

I've tried the below settings (and a dozen variations) but I'm getting nothing more than garbage audio. Does anyone know the correct settings for AMR?

 AudioStreamBasicDescription asbd;
 asbd.mSampleRate = 8000.0;
 asbd.mFormatID = kAudioFormatAMR;
 asbd.mFormatFlags = 0;
 asbd.mBytesPerPacket = 15;  // (118>>3)
 asbd.mFramesPerPacket = 1;
 asbd.mBytesPerFrame = 15;
 asbd.mChannelsPerFrame = 1;
 asbd.mBitsPerChannel = 118;  //tried also 0 and 13
 asbd.mReserved = 0;

Based on info from wikipedia for AMR:

Sampling frequency 8 kHz/13-bit (160 samples for 20 ms frames)

Generates frame length of 95, 103, 118, 134, 148, 159, 204, or 244 bits for bit rates 4.75, 5.15, 5.90, 6.70, 7.40, 7.95, 10.2, or 12.2 kbit/s, respectively

And the data structure description from here:

http://developer.apple.com/iphone/library/documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html#//apple_ref/doc/c_ref/AudioStreamBasicDescription

1
What APIs are you using for decoding and playback? If you're using an Audio File Stream, are you not able to use AudioFileStreamGetProperty to get a populated ASBD?warrenm
I'm trying playback from in memory source using: AudioQueueNewOutput AudioQueueAllocateBuffer AudioQueueEnqueueBuffer AudioQueuePrime AudioQueueStartPeter
I managed to write the data back out to a file, and read it back in to get the property mentioned, mFramesPerPacket comes back as 2400 which doesn't seem probable, but feeding that value (and many variants on the other values) back into the ASBD structure hasn't helped.Peter
for anyone trying to do the same, the only workaround I've found is to write my data out to the filesystem, and use the 'AudioFileReadPackets' functionality to read and play back the file.Peter

1 Answers

1
votes

iOS dropped AMR support, so the new solution is to use OpenCoreAMR to convert data to PCM