How to check strength (intensity) of audio while recording?

前端 未结 1 522
执笔经年
执笔经年 2021-02-09 04:21

I am working on a voice recorder application. I want to know is there any way to find strength of the audio while recording it. I don\'t want to save the recording anywhere. I j

1条回答
  •  日久生厌
    2021-02-09 04:46

    You can start another thread when recording start and use getMaxAmplitude function to capture Amplitudes.

    Below is the snippet.here we are taking sample for every 250 milliseconds and calculated max amplitude

    public void run() {
                int i = 0;
                while(i == 0) {
    
                    try {
                        sleep(250);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    if (mRecorder != null) {
                        amplitude = mRecorder.getMaxAmplitude();
    
                        //Here you can put condition (low/high)
                        Log.i("AMPLITUDE", new Integer(amplitude).toString());
                    } 
    
                }
            }
    

    0 讨论(0)
提交回复
热议问题