android – How to save audio recording with PlaybackParams?-ThrowExceptions

Exception or error:

I am working on an audio recorder app which has some effects. I am getting a problem that I cannot save audio files with effects. As soon as I stop recording it saves recording but i want to save the recording when I click on the Save button with effects. I am using Seekbar for changing pitch.

Here is SeekBar Code

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                int val = (progress * (seekBar.getWidth() - 2 * seekBar.getThumbOffset())) / seekBar.getMax();
                textView.setText("" + progress);
                textView.setX(seekBar.getX() + val + (float) seekBar.getThumbOffset() / 2);
                if (mediaPlayer.isPlaying()){
                    mediaPlayer.stop();
                }
                if (progress == 0){
                    params.setPitch(0.3f);
                }
                else if (progress == 1){
                    params.setPitch(0.6f);
                }
                else if (progress == 2){
                    params.setPitch(1f);
                }
                else if (progress == 4){
                    params.setPitch(1.3f);
                }
                else if (progress == 5){
                    params.setPitch(1.6f);
                }
                else if (progress == 6){
                    params.setPitch(1.9f);
                }
                else if (progress == 7){
                    params.setPitch(2f);
                }
                else if (progress == 8){
                    params.setPitch(2.3f);
                }
                else if (progress == 9){
                    params.setPitch(2.6f);
                }
                else if (progress == 10){
                    params.setPitch(2.9f);
                }
                else if (progress == 3){
                    params.setPitch(3f);
                }
            }

Here is AudioSaving Recoding Code

            mediaRecorder=new MediaRecorder();
            mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
            mediaRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
            mediaRecorder.setOutputFile(mFileName);

Any Suggestions ??

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *