How to convert .pcm file to .wav or .mp3?

后端 未结 4 716
终归单人心
终归单人心 2020-12-14 09:29

I am currently developing an Android Application that has audio recording and playing. I am new to dealing with audio and I\'m having some trouble with encoding and formats.

4条回答
  •  清歌不尽
    2020-12-14 10:02

    Just to register, I solved my need of recording an audio playable in common players using MediaRecorder instead of Audio Recorder.

    To start recording:

        MediaRecorder mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        mRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
        mRecorder.setOutputFile(Environment.getExternalStorageDirectory()
                    .getAbsolutePath() + "/recording.3gp");
    
        mRecorder.prepare();
        mRecorder.start();
    

    And to play the recording:

        mPlayer = new MediaPlayer();
        mPlayer.setDataSource(Environment.getExternalStorageDirectory()
                    .getAbsolutePath() + "/recording.3gp");
    
        mPlayer.prepare();
        mPlayer.start();
    

提交回复
热议问题