Perform action when sound comes above threshold?

Feb 9, 2011 at 11:19am

Perform action when sound comes above threshold?

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?

#54875
Feb 9, 2011 at 11:55am

quick and dirty solution:

– Pasted Max Patch, click to expand. –
#197636
Feb 9, 2011 at 12:18pm

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!

#197637
Feb 9, 2011 at 12:36pm

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)

#197638
Feb 9, 2011 at 7:51pm

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.

#197639
Feb 10, 2011 at 9:33am

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

#197640

You must be logged in to reply to this topic.