Amplitude of return of microphone input in the absence of recording

I have the following code and you should be able to listen to the microphone on the phone and use this value to graphically display on some kind of visualizer:

Timer micTimer = new Timer();
micTimer.schedule(new TimerTask(){
    @Override
    public void run(){
        int x = MediaRecorder.getAudioSourceMax();
        Log.v("Timer", "" + x);
    }
}, 0, 100);

I know that this is probably far from the case. Later in the class, I use the AudioRecorder object to record sound for some subsequent processing. Here I do not want to record anything, just displaying the sound on the visualizer. The log from this code prints the number 6 every 100 ms. Could this have anything to do with this by automatically adjusting the gain? If so, how do I get around this?

+3
source share
2 answers

, , . , . , getMaxAmplitude() ( 0), , , , . NoiseAlert. .

, , , MediaRecorder, ; , "" .

+2

6 100 . :

mediaRecorder = new MediaRecorder();
//...
//...
//int x = MediaRecorder.getAudioSourceMax(); change to:
int x = mediaRecorder.getMaxAmplitude();
+1

Source: https://habr.com/ru/post/1788543/


All Articles