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());
}
}