Tutorial :Is that possible to get the current sample amplitude by MediaRecorder or other class



Question:

I have a media recorder, and want to record a media from mic and get it's amplitude sample. I want to try to get the correct and current amplitude instantaneously when calling some API. But there is just one API in MediaRecorde for getting amplitude: getMaxAmplitude, and it is used to get the maximum absolute amplitude measured since the last call. Is that possible to get the current sample amplitude instantaneously by MediaRecorder or other class from mic?

Thanks, Best regards, Chen


Solution:1

The documentation for MediaRecorder.getMaxAmplitude says:

Returns the maximum absolute amplitude that was sampled since the last call to this method. Call this only after the setAudioSource().

Thus, you could just sample twice over a small time interval and look at the second value. That would effectively be an instantaneous sample.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »