android中采集音频的apiandroid.media.AudioRecord

其中构造器的几个参数就是标准的声音采集参数

以下是参数的含义解释

public AudioRecord (int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)

Since:API Level 3

Class constructor.

Parameters

audioSource

the recording source. SeeMediaRecorder.AudioSourcefor recording source definitions.

音频源:指的是从哪里采集音频。这里我们当然是从麦克风采集音频,所以此参数的值为MIC

sampleRateInHz

the sample rate expressed in Hertz. Examples of rates are (but not limited to) 44100, 22050 and 11025.

采样率:音频的采样频率,每秒钟能够采样的次数,采样率越高,音质越高。给出的实例是441002205011025但不限于这几个参数。例如要采集低质量的音频就可以使用40008000等低采样率。

channelConfig

describes the configuration of the audio channels. SeeCHANNEL_IN_MONOandCHANNEL_IN_STEREO

声道设置:android支持双声道立体声和单声道。MONO单声道,STEREO立体声

audioFormat

the format in which the audio data is represented. SeeENCODING_PCM_16BITandENCODING_PCM_8BIT

编码制式和采样大小:采集来的数据当然使用PCM编码(脉冲代码调制编码,即PCM编码。PCM通过抽样、量化、编码三个步骤将连续变化的模拟信号转换为数字编码。) android支持的采样大小16bit或者8bit。当然采样大小越大,那么信息量越多,音质也越高,现在主流的采样大小都是16bit,在低质量的语音传输的时候8bit足够了。

bufferSizeInBytes

the total size (in bytes) of the buffer where audio data is written to during the recording. New audio data can be read from this buffer in smaller chunks than this size. SeegetMinBufferSize(int, int, int)to determine the minimum required buffer size for the successful creation of an AudioRecord instance. Using values smaller than getMinBufferSize() will result in an initialization failure.

采集数据需要的缓冲区的大小,如果不知道最小需要的大小可以在getMinBufferSize()查看。

采集到的数据保存在一个byteBuffer中,可以使用流将其读出。亦可保存成为文件的形式

更多相关文章

  1. android设置Spinner字体颜色,格式,大小
  2. [置顶] Android MediaPlayer+Stagefright框架(音频)图解
  3. Android动态设置edittext的hint属性显示的提示文字大小
  4. Android Jetpack应指南学习笔记8——Navigation(二)使用safe arg
  5. Android6.0 Launcher3 修改app字体大小
  6. android上传图片和参数(属性)到服务器
  7. android 音频系统java部分代码阅读

随机推荐

  1. Kotlin编程之Kotlin Android(安卓)Extens
  2. Android(安卓)动态设置TextView的drawabl
  3. Android游戏开发源码案例25个汇总
  4. Android是如何规避GPL传染性的
  5. 开发Android应用的时候遇到的问题
  6. 重拾Android之路之开发准备
  7. Android(安卓)是什么
  8. Android的线程使用来更新UI----Thread、H
  9. Android(安卓)开机动画
  10. [Android(安卓)源码] Android源码下载