Android AMR speech codec Solution

Source: Internet
Author: User
Today I have made a good research on the speech compression encoding in Android, and I have some tips:

First of all on the collection of sound source format is the PCM-16bit format, What Is PCM format, you can see the following article:

Http://blog.csdn.net/tkboy/archive/2009/12/19/5038947.aspx

PCM is a non-compressed sound source. PCM signals are digital signals composed of [1], [0], and other symbols. This format is used by Android devices, we also perform compression encoding for this format.

I did not write the encoding library by myself. It was extracted from bambuser. The test showed that this library is really fucking powerful and powerful, each encoding is like this:

Read = maudiorecorder. Read (arrayofbyte1. 0,320 );
Encodelength = mamrencoder. encode (arrayofbyte1, 0, read, arrayofbyte2, amrencoder. mr475 );

Why 320?

I asked a friend who is a sip expert to say this:

Package every 320 bytes or a multiple of these bytes.

Maybe this is the reason, but I still don't quite understand it. Then our technical director said this:

Traditionally, the voice frame is measured in ms. The minimum unit of the voice frame 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.

Okay. Let's talk about the encoding 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 voice format of AMR Nb. If we want to play it through audiotrack, we have to use amrdecoder to decode and restore these 13 bytes to 320-byte PCM for playback.

At present, the efficiency of AMR is relatively high. The compression ratio is: 320: 13,320 bytes to 13 bytes.

You can also consider GSM: 320: 33,320 bytes to compress to 33 bytes.

/**
* @ Author Zhang xingye
* Email: xy-Zhang # 163.com
* Android Development Group: 278401545
*
*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.