java - Making a VU meter from an audio buffer -



java - Making a VU meter from an audio buffer -

so working on application deals audio, , have buffer containing of info sent sound card. wondering if has suggestions best way plot vu meter? if makes difference, using java. of examples have seen have been physical vu meters.

edit: need figure out how volume of sound buffer @ given point.

regards, jack hunt

what reply calculate leaky integral of absolute values of buffer. 50% value "off" digital sound needs reproduce both postive , negative sound pressures. see wikipedia article on digital sound if don't this.

real vu meaters leaky integrator of amplitude of signal. ( simple buffer , capacitor can suffice if galvanometer or electonic vu meter chip has sufficently high input resistance)

so 16 bit samples code might like.... (off top of head)

//set long total=0; const long half = 32768; //2^(n-1) const long decayinmilliseconds=30; // 30ms needle fall zero. // leak rate plenty reported signal decay 0 decaymilliseconds after // actual amplitude goes zero. int leakrate = (sample_rate*1000 /decayinmilliseconds) * half; // goes in loop work // can executed on buffer-loads of info @ less sampling rate, net number of calls persecond needs equal sampling rate. int amplitude = buffer[i]-half; total = total + abs(amplitude); total = total - leakrate; if( total > half) { total = half; } //total current "vu level".

the value of total displayed on logarithmic scale.

java audio

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -