我正在使用示波器创建一个用于录音的应用程序。我用下面的代码进行了录音现在我添加了如图所示的示波器。我的要求是示波器的波形应该根据用户的语音音调为之字形。我已经尝试了很长时间,但我找不到解决方案。我没有任何想法来实现示波器。请帮助我如何做到这一点,并请提供一些示例代码片段。谢谢。
录音代码:
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());
}
}