Volume Detection

Anneke's icon

Hi

I'm trying to get max to detect the level of volume coming from input(a mic, or whatever), in order to change the saturation of matrixes. What object can I use to detect a changing volume level as well as the amount of change in volume?

Szrp's icon

Well, the input signal itself already -is- a function of amplitude over time, so at a very basic level, the only thing you have to do is lead the mic signal through an [abs~] to get absolute (positive) values.

What else you need to do depends a bit on the application. Often, you'll want to smooth the signal so you don't get tons of little peaks, but more a general amplitude curve. [rampsmooth~] will do this nicely. Since you'll often need the amplitude in control rate, you'd generally also attach a [snapshot~ 10] or similar to it.

So, to start, try for example an [abs~] attached to a [rampsmooth~ 500 500] attached to a [snapshot~ 10]. You'll have to experiment a bit with different ramp times in [rampsmooth~] to get what you really want. Higher ramp times will make your amplitude detection lag behind a bit more and may ignore some peaks, but will produce a smoother result. Lower ramp times are more accurate and faster, but can get you pretty "nervous" readings. Sometimes it's also useful to set, for instance, the rampup time lower than the rampdown time - so you get more or less smooth results but still catch some sharper transients.

Anything else depends a lot on what exactly you need.