Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 07:34, 24 June 2007.

How to find out the mode of an AMR file to set the frame length properly

From Forum Nokia Wiki

How to find out the mode of an AMR file to set the frame length correctly

The frame length of an AMR file varies according to the mode( bitrate ) of that particular AMR content. Especially while using streaming classes like CMdaAudioOutputStream, the buffers should be loaded according to the frame length which can be resolved from the mode, to which that particular AMR file belongs to.

The mode information of an AMR file can be extracted from the first byte of the first frame( ie, the first byte after the 6 byte AMR header ). Following is the code snippet which demonstrates how to extract the mode information from an AMR file:

const TInt KAMRFrameLenTable[8] = { 13, 14, 16, 18, 20, 21, 27, 32 };
#define KAMRHeaderLength 6
RFs iFs;
RFile iFile;
_LIT(KAudioFilePath,”C:\Data\Test.amr”);
User:: LeaveIfError(iFs.Connect());
TInt ret = iFile.Open(iFs, KAudioFilePath, EFileRead | EFileStream);
   if(ret != KErrNone)
       { return ret; }
   // reading AMR header
TBuf8<KAMRHeaderLength> header;
 ret = iFile.Read(header, KAMRHeaderLength);
   if(ret == KErrNone)
       {
        iFile.Read(header, 1); // reading 1st byte of the first frame
             if(header.Length())
               {
               // resolving the AMR mode from the first frame’s 1st byte
               TInt mode = (header[0] & 0x38) >> 3; // 0x38 == 00111000
              // frame length is set according to the mode returned
               iFrameLen = KAMRFrameLenTable[mode]; 
               }                
         }
Related Discussions
Thread Thread Starter Forum Replies Last Post
amr[amr-nb] and true tones[amr-wb] jacqueline79 Audio 2 2007-11-26 09:15
CImageEncoder - encodes in hardware or software erst Symbian Media (Graphics & Sounds) 22 2008-03-27 13:55
Switching to Low Res mode on V9.1 phones greatape General Symbian C++ 10 2006-10-12 12:01
reading from a file and writing to another file ibraheemJazba General Symbian C++ 3 2007-03-08 11:50
S60 2.1上的AMR格式录音问题 xiaokun Symbian 5 2007-05-30 08:27
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZaudioQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX