我正在用示波器创建一个用于录音的应用程序。我用以下代码进行了录音,现在我添加了oscilloscopse,如图所示。我的要求是示波器的波形应该是zigzac,根据用户的语音。我已经尝试了很长时间,但我找不到解决方案。我不知道实现示波器。请帮我怎么做,请提供一些示例代码片段。感谢。
录音代码:
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,RECORDER_SAMPLERATE, RECORDER_CHANNELS,RECORDER_AUDIO_ENCODING, bufferSize);
recorder.startRecording();
...
byte data[] = new byte[bufferSize];
String filename = getTempFilename();
FileOutputStream outputstream = null;
try {
outputstream = new FileOutputStream(filename, true);
} catch (FileNotFoundException e) {
Log.e("Error @ writeAudioDataToFile() - 1 ", e.getMessage());
}
int read = 0;
if (null != outputstream) {
while (isRecording) {
read = recorder.read(data, 0, bufferSize);
if (AudioRecord.ERROR_INVALID_OPERATION != read) {
try {
outputstream.write(data);
} catch (IOException e) {
Log.e("Error @ writeAudioDataToFile() - 2 ",e.getMessage());
}
}
}
try {
outputstream.close();
} catch (IOException e) {
Log.e("Error @ writeAudioDataToFile() - 3 ", e.getMessage());
}
}
答案 0 :(得分:2)
对此没有一个简单的答案,你肯定需要做一些工作来处理它。以下是一些应该可以帮助您入门的链接:
http://code.google.com/p/musicg/
http://codeidol.com/java/swing/Audio/Build-an-Audio-Waveform-Display/