How to sample microphone on Android without recording to get live amplitude/level?

前端 未结 4 467
夕颜
夕颜 2020-12-01 00:39

I was trying to get the amplitude level of a microphone on Android like so:

MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecord         


        
4条回答
  •  生来不讨喜
    2020-12-01 01:06

    Yep you have to call recorder.start() first, and you must not forget to call recorder.stop() at the end too!

    See http://code.google.com/p/android-labs/source/browse/trunk/NoiseAlert/src/com/google/android/noisealert/ for an example application, you may want to take a look at SoundMeter.java and NoiseAlert.java

提交回复
热议问题