Android Audio Development (1): Basics

Source: Internet
Author: User

First, a bit of gossip, some time ago I have a feeling: Android development, itself is not a way to go far, it is just a platform, provides a lot of packaged API, so that you can quickly develop a specific business-oriented applications.


The real value lies in the combination of Android and the specific business direction, such as: Android and AV, Android and smart hardware interaction, Android and front-end technology integration and exploration, Android information security, Android source depth customization and so on.


I have been more optimistic about the audio/video/multimedia direction, I hope this can be deeply accumulated and explored, some time ago I released an Android VoIP network phone application "Flying pigeon phone", and wrote an analysis of its overall structure of the article "Pigeoncall: an Android VoIP Internet Telephony app architecture analysis, welcome to interested friends First look.


In this application development process learned a lot of things, so want to write some articles share sharing, this article as the opening, mainly in the form of question and answer, introduce some basic knowledge of audio development, very important, because do not understand these common sense, many Android API or third-party library parameters, You don't even know how to configure it.


1. What are the main applications for audio development?


Audio player, Sound Recorder, voice phone, audio and video surveillance applications, voice and video streaming applications, sound editing/processing software, Bluetooth headphones/speakers, etc.


2. What are the specific content of audio development?


(1) Audio capture/playback

(2) Audio algorithm processing (denoising, mute detection, echo cancellation, sound processing, AMP/boost, mix/detach, etc.)

(3) Audio codec and format conversion

(4) Development of audio transmission protocols (SIP,A2DP, AVRCP, etc.)


3. What are the difficulties in audio applications?


Delay sensitive, lag sensitive, noise suppression (denoise), echo cancellation (AEC), mute Detection (VAD), mixing algorithm, and more.


4. What are the basic concepts of audio development?


In audio development, the following concepts are often encountered.


(1) sample rate (Samplerate)


Sampling is the process of digitizing analog signals, not just the audio needs to be sampled, all analog signals need to be converted to digital signals that can be represented by 0101来, as shown below:


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7C/F6/wKioL1bdXQviw_TBAAAVYm_x3gk862.gif "title=" 8a53c81e-88d0-4766-b5cc-49c9efcc7090.gif "alt=" Wkiol1bdxqviw_tbaaavym_x3gk862.gif "/>


The blue represents the analog audio signal, and the red dots represent the quantified values that are sampled.


The higher the sampling frequency, the denser the red interval, the greater the amount of data used to record the audio signal, and the higher the audio quality.


According to the Nyquist theory, the original sound can be restored without loss as long as the sampling frequency is not less than twice times the maximum frequency of the audio signal.


Usually the human ear can hear the frequency range around the 20hz~20khz sound, in order to ensure that the sound is not distorted, the sampling frequency should be above 40kHz. Commonly used audio sampling frequency is: 8kHz, 11.025kHz, 22.05kHz, 16kHz, 37.8kHz, 44.1kHz, 48kHz, 96kHz, 192kHz and so on.


(2) Quantization accuracy (bit width)


, each red sampling point, need to use a numeric value to represent the size, the data type size of this value can be: 4bit, 8bit, 16bit, 32bit and so on, the more the number of digits, the more refined, the better the sound quality naturally, of course, the data volume will be multiplied.


Common bit widths are: 8bit or 16bit


(3) Number of channels (channels)


Because the audio acquisition and playback can be superimposed, so that the sound can be collected from multiple audio sources at the same time, and output to different speakers, so the number of channels generally indicates the number of sound recordings or the corresponding number of speakers during playback.


Mono and two-channel (Stereo) are more common, as the name implies, the former channel number is 1, the latter is 2


(4) Audio frames (frame)


This concept is very important in application development, and many articles on the Web do not specifically describe this concept.


Audio and video is very different, video every frame is an image, and from the above the positive and dark waves can be seen, the audio data is streaming, itself does not have a clear frame of the concept, in the actual application, in order to audio algorithm processing/transmission of convenience, generally used to take 2.5ms~60ms as a unit of data volume for a frame of audio.


This time is called "Sampling time", its length is not a special standard, it is based on the codec and the specific application needs to determine, we can calculate the size of a frame of audio frame:


Assuming that an audio signal is a sample rate of 8kHz, a dual channel, and a bit width of 16bit,20ms frame, the size of one frame of audio data is:


int size = 8000 x 2 x 16bit x 0.02s = 5120 bit = 640 byte


5. What are the common audio encoding methods?


As mentioned above, the analog audio signal to the digital signal needs to be sampled and quantified, the quantization process is called coding, according to different quantization strategies, produced many different encoding methods, common encoding methods are: PCM and ADPCM, these data represent a lossless original digital audio signal, Add some file header information, can be stored as WAV files, it is a combination of Microsoft and IBM developed for audio digital storage standards, can be easily parsed and played.


In the process of audio development, we often involve the reading and writing of WAV files to verify the correctness of the audio data collected, transmitted and received.


6. What are the common audio compression formats?


First of all, briefly introduce the basic principle of audio data compression: Because there is redundant information, it can be compressed.


(1) Spectrum masking effect: The frequency range of the audible signal that the human ear can perceive is 20hz~20khz, and the audio signal outside this frequency range is redundant.


(2) Time-domain masking effect: When the strong tone signal and the weak tone signal appear simultaneously, the weak signal will not hear, therefore, the weak sound signal also belongs to the redundant signal.


The following is a simple list of common audio compression formats:


MP3,AAC,OGG,WMA,OPUS,FLAC,APE,M4A,AMR, wait.


7. What are the Adndroid VoIP-related open source applications?


IMSDROID,SIPDROID,CSIPSIMPLE,LINPHONE,WEBRTC, wait.


8. What are the open source libraries processed by the audio algorithm?


Speex, FFMPEG,WEBRTC Audio module (NS, VAD, AECM, AGC), etc.


What audio development-related APIs does Android provide?


Audio capture: Mediarecoder

Audio playback: Soundpool,mediaplayer,audiotrack (the difference between them can be referred to this article)

Audio Codec: Mediacodec

NDK Api:opensl ES


11. What is the delay standard for audio development?


ITU-TG.114 provides that the acceptable latency for high-quality speech is 300ms. In general, if the delay is 300~400ms, the interaction of the call is poor, but it can be accepted. When the delay is greater than 400ms, interactive communication is very difficult.


12. Summary


Audio development of the knowledge point is actually quite a lot of, an article can not be described in detail, therefore, not comprehensive and detailed place, please search professional information for in-depth understanding. There is no clear place in the article welcome message or letter [email protected] exchange, or follow my Sina Weibo @ Lu _ June or the public number @Jhuster get the latest articles and information.

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/7C/F7/wKiom1bdXr-BXKLtAACb8XAe6Uo863.jpg "title=" Weixin _jhuster.jpg "alt=" Wkiom1bdxr-bxkltaacb8xae6uo863.jpg "/>

This article is from the "jhuster column" blog, be sure to keep this source http://ticktick.blog.51cto.com/823160/1748506

Android Audio Development (1): Basics

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.