先記錄一下心得: 調整ADT字體大小
1. 先輸入關鍵字搜尋font
2. 點選Java Editor Text Font, 按下Edit按鈕
預設10號字體, 改成14號字看起來舒服多了~~~~
新增一個錄音管理類別
public class AudioLevelManager
{
…
}
=============================================================================
AudioRecord: 利用AudioRecord类实现自己的音频录制程序
File: 寫入聲音資料
mBuffer: 緩衝區資料
mIsRecording: 是否正在錄音
-----------------------------------------------------------------------------------------------------------------------------
OnRecordingListener: 定義3個callback function
onAmplitudeChanged: 聲音大小有變化時
onErrorHappened: 錯誤捕捉
onRecordCompleted: 錄音完成
1: public class AudioLevelManager {
2:
3: public static final int SAMPLE_RATE = 34000;
4: private AudioRecord mRecorder;
5: private File mRecording;
6: private short[] mBuffer;
7: private boolean mIsRecording = false;
8: private OnRecordingListener mListener;
9:
10: static public interface OnRecordingListener{
11: public void onAmplitudeChanged(double amp);
12: public void onErrorHappened(String errormsg);
13: public void onRecordCompleted(File waveFile);
14:
15: }
16:
17: public void setOnRecordingListener(OnRecordingListener l){
18: mListener = l;
19: }
=============================================================================
- AudioSource : 錄音來源選擇麥克風 MediaRecorder.AudioSource.MIC
- SAMPLE_RATE: 錄製頻率: 34000 HZ
- ChannelConfig : 雙聲道 AudioFormat.CHANNEL_IN_STEREO
- 單聲道 AudioFormat.CHANNEL_IN_MONO
- AudioFormat : 編碼精準度 AudioFormat.ENCODING_16BIT和8BIT
初始化
1: public void initRecorder() {
2: int bufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, AudioFormat.CHANNEL_IN_MONO,
3: AudioFormat.ENCODING_PCM_16BIT);
4: mBuffer = new short[bufferSize];
5: mRecorder = new AudioRecord(MediaRecorder.AudioSource.MIC, SAMPLE_RATE, AudioFormat.CHANNEL_IN_MONO,
6: AudioFormat.ENCODING_PCM_16BIT, bufferSize);
7: }
全站熱搜
留言列表