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

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

Asked by: Freddie839 | Posted: 25-01-2022

Answer 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.

Answered by: Emily388 | Posted: 26-02-2022

Similar questions

android - MediaRecorder Prepare Failed

I'm new here. I have been trying to create a video capture app using the android emulator without much success. As far as I know and looking through all the samples and code on the internet (this site and others), I must still be missing a step. I've tried using this sample near the end of this thread made by JonPro: http://www....

android - Problems with MediaRecorder class to record audio - prepare() gives an exception - Permission denied

I'm new in Android development and I have the next question/problem. I'm playing around with the MediaRecorder class to record just audio from the microphone. I'm following the steps indicated in the official site: So I have ...

android - How to know whether a MediaRecorder is in running state or not?

I wrote a code to record audio of call conversation using MediaRecorder. how can i know whether a MediaRecorder is in running state or not, to stop the recording. like boolean running; MediaRecorder mr; //what should i assign to running? if(running){ mr.stop() } Above code is just an example.. If you do not understand my question, please tell me.. i will explain clearly...

Android MediaRecorder and setOutputFile

I've read the Android SDK and I've found that the MediaRecorder class can take input from a Camera, Audio or other source and compress it. Through the setOutputFile method you can specify where you want the data to be stored (File or URI), but what if I want to store that data in a memory buffer and send it over a connection? Or process it before sending it? I mean is there a way not to create a file but to use a memory bu...

android - how to change video orientation in MediaRecorder to portrait

When I record video by MediaRecorder, it always records in landscape mode, regardless of real device orientation. How to force MediaRecorder/Camera use real orientation ?

android - How can I keep the MediaRecorder keeps recording after an orientation change

Can you please tell me how can I keep the MediaRecorder keeps recording after an orientation change? I try looking into source code of packages/apps/SoundRecorder/src/com/android/soundrecorder/, I don't see it handles that cases. Thank you.

android - CallBack for the recorded block in MediaRecorder

I am trying to record a voice from Mic using Media Recorder class. in the mentioned class we have just setOutputFile method to set the output file, but I need to get a buffer of some certain recorded voice, I mean i need something like a CallBack method that return a block of recorded byte at that time and i am going to send the mentioned bytes to another device... Actually I want to stream and send the recorded vo...

android - Samsung Galaxy MediaRecorder internal Buffering

I am noticing that the behavior of the is different on the Galaxy than on my other devices (Hero, Nexus, Incredible, etc.) The Galaxy seems to write MPEG data to file in 1 minutes intervals (approx 1.5 MB chunks), suggesting that it internally buffers its data. I need the data to come more quickly than once per minute. Does anyone have any suggestions on controlling this behavior? The androi...

java - stream a MediaRecorder file while recording

I am trying to get a video stream from point A (2.1 android phone) to point B (my server) in real time. How would I do it? Detailed below are my attempts (a little long, but concise!) The goal is to get an hour long video recorded with the phone to the server without pausing/stopping the stream. a delay of up to several minutes isn't a problem. I've tried three approaches threa...

Can sound be turned off in MediaRecorder of the Android API?

I would like to write a program that records video but not sound. Can anyone help me on how to not record the sound while recording the video using MediaRecorder?

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android