How to do Visualizer while recording audio in android

koti picture koti · Nov 26, 2012 · Viewed 12.9k times · Source

I know Visualizer to show some wave while playing audio using android Media Player.

But i want to show Visualizer while recording audio means while recording i want to show linear wave which changes based on user voice beat.

Is it possible to do in android.

Answer

elgui picture elgui · Dec 3, 2012

by calling every x milliseconds your MediaRecorder.getMaxAmplitude(), you gonna have (from official documentation) :

the maximum absolute amplitude that was sampled since the last call to this method.

then, you can process this value in real time to draw a graph or change some view properties.
not perfect, but I hope it helps =)

edit: just so you know, the retrieved value will be the same across all android devices : between 0 and 32767. (I have more than 10k user's reports giving me this value when they blow in the mic).