Forums > MaxMSP

Perform action when sound comes above threshold?

February 9, 2011 | 11:19 am

I bought an external sound card, and what I want to do is listen to 5 microphones simultaneously, and only start recording sound once the microphones’ sound level comes above a certain threshold. (let’s say when I clap my hands, or somebody walks by)

I assume that when using the analog to digital converter, the software picks up a sound level from 0 to 1023, and that I just could simply say (in abstract language) "if soundlevel > 300, then… etc." but I’m reading forum posts and doing tutorials for the last 7 hours now and I can’t get it to work.

So I just want to define a soundvolume threshold, that when being reached triggers an action. Can somebody here maybe guide me in the right direction, or tell me specifically which websites or tutorials to take a look at?


February 9, 2011 | 11:55 am

quick and dirty solution:

– Pasted Max Patch, click to expand. –

February 9, 2011 | 12:18 pm

wow, that’s even better than a website link or tutorial… many thanks! =) just a small question though to understanding the structure behind it.

I guess the [0.3 value * float] sets the threshold for the soundvolume, but from what range does this go? Since I read that maxmsp’s coding can be compared to C, I assumed this would be 0 to 1023, but since your numbers are so small I think I’m wrong.

Last thing: I’m experimenting with three different soundvolume ranges now (to let the software do something different when the soundvolume is in quiet range 1, compared to when the volume is in louder ranges 2 or 3). Can I simply say ">0.3 && <0.5" or how do I effectively do this? Thanks again!


February 9, 2011 | 12:36 pm

the output range of the meter~ object is range is 0…1 from an input which is not amplified (though you could amplify it more in max)

the sound data itself (msp signal) normally ranges from -1. to 1., this is what the input and output can be, however, in between the value can be much higher (causing clipping on the output if you don’t decrease it)

check the split object for what you want, however, you might need to smooth out the data as well, or prevent excessive on and off switches (check speedlim, delay and gate)


February 9, 2011 | 7:51 pm

I’m now trying to set three ranges (from 0-0.3 perform action1, from 0.3-0.7 perform action two, from 0.7-1.0 perform action3) but I still can’t get it to work. Are you sure that the meter~ object sends out a value *between* 0 and 1, or send out a value that’s either 0 *or* 1? I still struggle to get it to work.


February 10, 2011 | 9:33 am

I think this will help you:

– Pasted Max Patch, click to expand. –

also make sure you know the difference between floats and ints and signals in max and how these are handled


October 14, 2014 | 11:07 am

How can this be achieved for 4 audio inputs ? I’ve been trying but with no luck. Also, I want the output to stay at the current state and not just send the msg and go back to 0 again , according to Timo’s example.. Any tips would be appreciated !

  • This reply was modified 6 days by  Anton.

October 14, 2014 | 12:34 pm

Is this what you mean?

– Pasted Max Patch, click to expand. –

October 14, 2014 | 1:24 pm

Basically I want to change sound files (smoothly) depending on how noisy the environment is.
What I want to achieve is, if the in float number is X for at least 2 seconds then bang 1. If its is Z for 2 seconds then bang 2. etc..
I need to do this for four states. This is where I am now. But cant work it out.. Im messing around with the delay object but seems not to work. The patch is the following:
Thx for the response :)

– Pasted Max Patch, click to expand. –
  • This reply was modified 6 days by  Anton.

October 15, 2014 | 3:02 am

Take a look at the sah~ object or maybe build something with a timer object and a if / then statement. But i think Timo already solved that for you?


October 18, 2014 | 11:36 am

Solved . :)
Thx a lot!


Viewing 11 posts - 1 through 11 (of 11 total)