Forums > MaxMSP

detecting if a number coming from a sensor is changing

February 3, 2009 | 11:39 pm

hi again

i have had a look at the change object but it seems to do the opposite of what i want

i am playing sounds in response to numbers coming in from a sensor and i need an object (or combination of objects) that can continually test numbers coming in from the sensor to see if they are changing or staying the same. if they stay the same (and the sensor is not registering anything) then after a short while i want to fade the sounds out, i think i can do this but i need something to test if the numbers are not changing.

can anyone help?

many thanks


February 3, 2009 | 11:55 pm

Hi, I didn’t see your original post, but I recently discovered the glory of the change object myself. What if you used it to trigger a timer? The change object would start the timer whenever the numbers change, and then you could put a "select" object after the timer, and have it trigger an adsr~ (or whatever it is you are using to fade your sound out). Have the select object look for the number 5000 for example. That way, if the numbers don’t change for 5 seconds (5000 ms) the select object will trigger an envelope – or whatever else you like, to change your audio. Anyway, hope this idea is what you’re looking for – I’m only a junior member, but maybe this will help.



pm
February 4, 2009 | 3:16 am

I think that’s what you are looking for…


February 4, 2009 | 7:13 am

yeah, I think your way is easier… I tend to go by the brute force method. nasty habit of mine.


February 4, 2009 | 10:59 am

doh! i forgot to mention that im only using max 4.5. is there any chance anyone can convert that inv change.maxpat so i can see it?

many thanks


February 4, 2009 | 11:40 am

this will do it!

#P button 273 223 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 273 195 61 196617 delay 5000;
#P newex 273 168 22 196617 b 1;
#P newex 273 136 40 196617 change;
#P number 273 109 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 2 0 3 0;
#P connect 1 0 2 0;
#P connect 3 0 4 0;
#P connect 0 0 1 0;
#P window clipboard copycount 5;

>
>doh! i forgot to mention that im only using max 4.5. is there any chance
>anyone can convert that inv change.maxpat so i can see it?
>
>many thanks


February 4, 2009 | 7:53 pm

In my experience, values from sensors are constantly changing. That’s why I love using them… So you might try tracking the difference between successive values. Then if the amount of change is within or beyond a certain range you can trigger something.


February 5, 2009 | 2:19 am

Quote: Holland Hopson wrote on Wed, 04 February 2009 13:53
—————————————————-
> In my experience, values from sensors are constantly changing. That’s why I love using them… So you might try tracking the difference between successive values. Then if the amount of change is within or beyond a certain range you can trigger something.
—————————————————-

yes, love and hate the inherent jitteriness of them… that’s been more of a pain than a pleasure for me. ah well. The "difference idea" is good for triggering something only when there’s a bigger change than the average noisiness that comes even when the sensor isn’t really sensing anything. Likewise, depending on the programming on the sensor side, you can prevent some of the jitter from coming in in the first place (only send out if it jumps by 2, etc).

Also you might check out the "sensor tamer" in the Extras–Examples Overview, could give some ideas.


February 5, 2009 | 2:38 am

On Feb 4, 2009, at 11:53 AM, Holland Hopson wrote:

> In my experience, values from sensors are constantly changing.

When I want clean sensor data, I have used this abstraction, which I
call flatline :

– Pasted Max Patch, click to expand. –

Chris Muir
cbm@well.com

http://www.xfade.com


February 5, 2009 | 2:54 am

Chris, that is a great solution which solved a bunch of rather unsuccessful fiddling I’ve tried. Very nice!


February 5, 2009 | 7:55 am

I use filtering something like this:

– Pasted Max Patch, click to expand. –

February 5, 2009 | 11:01 am

Yet another solution, originally built by Trond Lossius and modified a tad over here. A bit bigger, but it does some nifty things.

Uses lp.stacey from Litter Starter Pack, available at the URI below.

– Pasted Max Patch, click to expand. –

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