audio - Detecting the current volume on Android -


i'm building application recording audio microphone, whenever audio reaches threshold perform action.

however how should calc appropriate volume threshold ? i've static volume coded works across devices not devices (in somes cases sensitive or vice versa).

i'm using audiorecord, here's part of code:

int buffersize = audiorecord.getminbuffersize(constants.recording_frequency,constants.channelconfiguration,constants.audioencoding);     audiorecord audiorecord = new audiorecord( mediarecorder.audiosource.mic,constants.recording_frequency,constants.channelconfiguration,constants.audioencoding, buffersize);  short[] buffer = new short[buffersize]; while(true) {    int bufferreadresult = audiorecord.read(buffer, 0, buffersize);    (int = 0; < bufferreadresult; i++) {       currentvolume = java.lang.math.abs(buffer[i]);       if (currentvolume > constants.no_volume_amplitude)         // alright ! i'm looking :d    } } 

so, question is: how calculate constants.no_volume_amplitude instead of having hard coded ?

thanks in advance, ze


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -