先記錄一下心得:  調整ADT字體大小

1. 先輸入關鍵字搜尋font

2. 點選Java Editor Text Font, 按下Edit按鈕

image

預設10號字體, 改成14號字看起來舒服多了~~~~

image

新增一個錄音管理類別

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:     }

=============================================================================

  1. AudioSource       : 錄音來源選擇麥克風  MediaRecorder.AudioSource.MIC
  2. SAMPLE_RATE: 錄製頻率: 34000 HZ
  3. ChannelConfig    : 雙聲道  AudioFormat.CHANNEL_IN_STEREO
  4.                            單聲道  AudioFormat.CHANNEL_IN_MONO
  5. 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:     }
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()