PaulStoffregen / Audio

Teensy Audio Library
http://www.pjrc.com/teensy/td_libs_Audio.html
1.08k stars 401 forks source link

Analyze Volume #39

Open PaulStoffregen opened 10 years ago

PaulStoffregen commented 10 years ago

There should be an analyze object that reports "volume". It should take the absolute value of the input, and apply different filters for increases (short time constant) and decreases (long time constant) to simulate the time response of a traditional VU meter. Maybe the time constants should be configurable?

alexmstahl commented 10 years ago

This might be useful for dynamics processors (e.g. AGC, compressors) as well as metering. Configurable time constants, yes please. Variants using RMS averaging (for accuracy) or a simple average (for efficiency) would be nice too.

MacroMachines commented 8 years ago

isn't this just FIR or IIR into a peak? maybe peak just needs to be faster? at any rate this is an easy object to make, just rectify, lowpass (works best with specific filtering for upward and downward movement separated into attack and decay slew rate limiting)

MacroMachines commented 8 years ago

here is a snippet from part of my omnimod code that does this decently:

uint16_t ADCsmooth(uint8_t ADCchan){
   if(ADCmapped[ADCchan] <= ADCvalueOld[ADCchan]){  
      ADCvalue[ADCchan] = (ADCmapped[ADCchan] + (ADCvalue[ADCchan] << CVsmoothingDown[ADCchan]) - ADCvalueOld[ADCchan]) >> CVsmoothingDown[ADCchan]; }
   else{       
      ADCvalue[ADCchan] = (ADCmapped[ADCchan] + (ADCvalue[ADCchan] << CVsmoothingUp[ADCchan]) - ADCvalueOld[ADCchan]) >> CVsmoothingUp[ADCchan]; }
}