Android AMR speech codec Solution Androidandroidarmarm sound collection today, I have made a good research on Android speech compression encoding. I have some tips:
first, the format of the collected audio source is the PCM-16bit format, what is the PCM format, let's take a look at the following Article :
http://blog.csdn.net/tkboy/archive/2009/12/19/5038947.aspx
PCM is a sound source without compression, PCM signals are digital signals composed of [1], [0], and other symbols. Android devices adopt the sound source format, which we compress and encode.
I did not write the encoding library myself, but extracted it from bambuser. The test showed that this library is really powerful and powerful, so powerful that it can be reused, the encoding is as follows:
Read = maudiorecorder. read (arrayofbyte1, 0,320);
encodelength = mamrencoder. encode (arrayofbyte1, 0, read, arrayofbyte2, amrencoder. mr475);
why is it 320?
I asked a friend who is a sip expert to say this:
package every 320 bytes or a multiple of these bytes
This is probably the reason, however, I still don't quite understand this, and our technical director said this:
traditionally, the unit of voice frames is 20 m, the data size for every 20 ms is 320 bytes. Of course, this is 16 bit, 8 kHz.
how to calculate it.
well, I 'd like to explain the encoding situation to you and deepen your understanding of this aspect:
after the 320-byte PCM-16 speech is encoded, the programming length is 13 bytes, that is, the AMR Nb speech format, if we want to use audiotrack to play the video, we need to use amrdecoder to decode the 13 bytes and restore them to 320-byte PCM for playing.
at present, the efficiency of AMR is relatively high, and the compression ratio is: 320: 13,320 bytes compressed to 13 bytes
GSM can also be considered as follows: 320: 33,320 bytes to compress into 33 bytes