How to create oscilloscope for audio on android

百般思念 提交于 2019-12-09 20:08:34

问题


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


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!