How to record audio file in Android

前端 未结 4 936
逝去的感伤
逝去的感伤 2020-12-25 13:49

I am working in android. How can I record an audio file through microphone, and how can I save the recorded file in the emulator?

4条回答
  •  遥遥无期
    2020-12-25 14:14

    I had tried to record the WAV file in android. But somehow, it is only recording the. WAV file in stereo only and you should use the audio recorder with the following parameter

    recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
                            RECORDER_SAMPLERATE, AudioFormat.CHANNEL_IN_MONO,RECORDER_AUDIO_ENCODING, bufferSize);
    
            recorder.startRecording();
    

    and from the recorder, you need to write all the data into one file and also you need to give header information

    then just do

    recorder.stopRecording();
    

    but I have just one problem in this is even if I give AudioFormat.CHANNEL_IN_MONO..it still record in stereo format. Hope my answer helps you.

提交回复
热议问题