简体   繁体   English

如何更改录制音频的音调并保存在背景中?

[英]How to change the pitch of recorded audio and save in background?

I'm recording an audio. 我正在录制音频。 after recording i want to change the pitch without changing frequency. 录制后,我想更改音高而不更改频率。 and saving file on sdcard. 并将文件保存在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 http://android-er.blogspot.in/2014/04/audiorecord-and-audiotrack-and-to.html

Run a background thread and record audio using MediaRecorder below code helps to record voice call in background and it writes file into sdcard 运行以下线程并使用MediaRecorder录制音频,以下代码有助于在后台录制语音呼叫,并将文件写入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;

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM