Peter
Peter

Reputation: 428

How to populate AudioStreamBasicDescription for AMR playback

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

Upvotes: 0

Views: 1678

Answers (1)

Peter
Peter

Reputation: 428

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

Upvotes: 1

Related Questions