Perform action when sound comes above threshold?

    Feb 09 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?

    • Feb 09 2011 | 11:55 am
      quick and dirty solution:
    • Feb 09 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 &&
    • Feb 09 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)
    • Feb 09 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.
    • Feb 10 2011 | 9:33 am
      I think this will help you:
      also make sure you know the difference between floats and ints and signals in max and how these are handled
    • Oct 14 2014 | 6:07 pm
      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 !
    • Oct 14 2014 | 7:34 pm
      Is this what you mean?
    • Oct 14 2014 | 8: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 :)
    • Oct 15 2014 | 10: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?
    • Oct 18 2014 | 6:36 pm
      Solved . :) Thx a lot!
    • Dec 06 2015 | 4:09 pm
      Hey guys, I'm working on a similar subpatch where the intensity of someone’s voice changes states based on the meter~ object’s 3 colours; green for speaking volume, orange for louder speech and red for shouting. I'm stuck over what parameters these 3 states should be set at based on the meter~ object’s parameters and how to carry on this change of state to other subpatches (e.g. one which adds or subtracts a certain amount of white noise to the incoming speech in 'real-time', going from none added to the normal speech (green) to a significant amount as someone shouts (red). Any light shed would be appreciated!
    • Sep 11 2016 | 4:45 pm
      Cheers to Timo for his great advice and example. Definitely true when shaping control streams.