i am creating an app for audio recording with oscilloscope. i did the audio recording with the following code now i add oscilloscopse as shown in the figure.my requirement is oscilloscope's wave should be zigzac according to the user's voice tone. i have tried long time but i could not find solution. i do not have any idea to implement the oscilloscope. please help me how to do it and please provide some sample code snippets. thanks.
audio recording code:
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());
}
}
There's not really a simple answer for this, it's going to definitely take some work on your part to process it. Here are a few links that should be able to get you started:
http://code.google.com/p/musicg/
http://codeidol.com/java/swing/Audio/Build-an-Audio-Waveform-Display/
来源:https://stackoverflow.com/questions/10882990/how-to-create-oscilloscope-for-audio-on-android