【发布时间】:2017-10-23 20:29:02
【问题描述】:
我正在编写一个采用摩尔斯电码并通过扬声器播放的应用程序。
目前我可以使用此代码通过麦克风录制音频:
public void startRecord() throws Exception{
if (record != null){
record.release();
}
File fileOut = new File(FILE);
if (fileOut != null){
fileOut.delete(); // delete any existing file at that location.
}
record = new MediaRecorder();
record.setAudioSource(MediaRecorder.AudioSource.MIC);
record.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
record.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
record.setOutputFile(FILE);
record.prepare();
record.start();
}
并且我能够以如下格式生成莫尔斯电码:
"-.... .---- -.... -.-. -.... ..... --... ---.."
我可以使用这样的 for 循环遍历这个字符串:
char[] chars = message.toCharArray();
for (char ch : chars) {
//add to audio file
}
但我不确定如何从串在一起的 wav 文件中创建文件。我看过一些帖子提到将音频源设置为来自设备的文件,但我不知道如何挑选和选择哪个文件以及在哪里插入它们,或者如何将它们全部编译成一个音频文件。
【问题讨论】:
-
"Can someone help me?" is not a question。请edit您的问题更具体地说明您需要什么帮助。
-
难道你不能单独播放破折号、圆点的声音,然后分别播放吗?
标签: java android audio wav mediarecorder