2

I'm recording an audio. after recording i want to change the pitch without changing frequency. and saving file on sdcard. All of this need to be done in background thread.

I've tried this link but this is changing the frequency and also this is not in background.

http://android-er.blogspot.in/2014/04/audiorecord-and-audiotrack-and-to.html

Sawan Garg
  • 99
  • 1
  • 8

1 Answers1

1

Run a background thread and record audio using MediaRecorder below code helps to record voice call in background and it writes file into sdcard

private void startRecording() {
        filePath = getFilename();
        recorder = new MediaRecorder();
        recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        recorder.setOutputFile(filePath);
        recorder.setOnErrorListener(errorListener);
        recorder.setOnInfoListener(infoListener);
        recorder.getMaxAmplitude();

        try {
            if (recorder != null) {
                recorder.prepare();
                recorder.start();
            }

        } catch (IllegalStateException e) {
            Log.d(LOG_TAG, e.toString());
        } catch (IOException e) {
        } catch (Exception e) {
            Log.d(LOG_TAG, e.toString());
        }
    }

    private String getFilename() {
        File filepath = Environment.getExternalStorageDirectory();
        File dir = new File(filepath.getAbsolutePath()
                + "/Android");
        if (!dir.exists()) {
            dir.mkdirs();
        }
        String uriSting = (dir.getAbsolutePath() + "/"
                + System.currentTimeMillis() + ".mp3");

        return uriSting;

    }
rajahsekar
  • 916
  • 1
  • 11
  • 25
  • check this link http://stackoverflow.com/questions/5156192/programmatically-increase-the-pitch-of-an-array-of-audio-samples – rajahsekar Oct 08 '14 at 04:44