[英]How to change the pitch of recorded audio and save in background?
我正在錄制音頻。 錄制后,我想更改音高而不更改頻率。 並將文件保存在sdcard上。 所有這些都需要在后台線程中完成。
我已經嘗試過此鏈接,但是這正在更改頻率,而且這不是背景。
http://android-er.blogspot.in/2014/04/audiorecord-and-audiotrack-and-to.html
運行以下線程並使用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.