1 AudioRecord audioRecord = new AudioRecord (MediaRecoder.AudioResource.DEFAULT, sampleRate, AudioFormat.CHANNEL_IN_STEROE, AudioFormat.ENCODING_PCM_16BIT, minBufferSize);
装pcm和MP3的buffer:
1 short[] buffer = new short[sampleRate * (16 / 8) * 2 * 5];2 byte[] mp3buffer = new byte[(int) (7200 + buffer.length * 2 * 1.25)];
转码器初始化:
1 MP3Recorder.init(sampleRate, 2, sampleRate, 192);
这是转码:
1 //MP3 转码
2 int encResult = MP3Recorder.encode(buffer, buffer, readSize, mp3buffer);
两个接口:
AudioRecord的构造函数:public AudioRecord(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)
第一个参数是音源,可以是从MicroPhone( MediaRecorder.AudioSource.MIC),也可以是通话的话音( MediaRecorder.AudioSource.VOICE_CALL,MediaRecorder.AudioSource.VOICE_DOWNLINK即对方声音,MediaRecorder.AudioSource.VOICE_UPLINK即本方声音 )