2

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

enter image description here

M.A.Murali
  • 9,988
  • 36
  • 105
  • 182
  • Don't know how to help you with your question but just so you know, Android has a [Visualizer](http://developer.android.com/reference/android/media/audiofx/Visualizer.html) library available since API 9 – eladr Jun 04 '12 at 14:37
  • @murali i had done a sample project on the same , i need to search on my repository.i found that code on net , and i just put it in my project , and it was doing good job , do u want any special effect on spectram analyser..? – SRam Jul 18 '12 at 14:08
  • @murali any example is available send me link it is usfull to me.... – NagarjunaReddy Feb 24 '14 at 07:52

1 Answers1

2

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/

Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274
  • Will Visualizer library help me as told in comment by spacesaji? – M.A.Murali Jun 04 '12 at 14:42
  • You should take a read through the documentation he linked to, but I doubt it will be useful for your specific requirement. The first paragraph notes that it is "not an audio recording interface" -- meaning it only analyzes outgoing audio, not incoming. – Kevin Coppock Jun 04 '12 at 14:46
  • please provide some sample code to achieve oscilloscope with audio and whatare things required to get oscilloscope . please help me. – M.A.Murali Jun 06 '12 at 15:44
  • Read the posted link. I can tell that you didn't. – Kevin Coppock Jun 06 '12 at 16:40