Forums > MaxMSP

recognize analog button

June 23, 2009 | 2:05 pm

index.php?t=getfile&id=3084&private=0

I read analog signal from arduino and, MaxMsp play sound file.
those signal from pressure sensor.

it play sound when is smaller than 900.
but there are some problem. the analog signal is continuous.
so I wanted to play sound just one time but, there are several time play.

is there any solution for this?
plz help me.


June 23, 2009 | 3:32 pm

The short answer is [change]. There’s no long answer.

_
johan


June 23, 2009 | 3:44 pm

you need to use a [gate] or similar so that it will play just once, then not play again until you allow it (maybe the end of the file, maybe after a given amount of time). lots of ways to do this. look at [trigger] to fire multiple commands right away: so it could play the sfplay~, then shut a gate, then sometime later the gate re-opens.


June 23, 2009 | 4:15 pm

thanks for reply.
I think I couldn`t explain well.

I`m making sort of instrument.
there are many analog port, and read value from sensors.
so each sensor plays different sound.
sometime many sound plays at same time.
so I dont want check sound files time or etc.

I just want to check values.
I could make code by processing.but I couldn`t make it MaxMsp.


int state=1
draw(){
if (state=1){
if (val < 190) {
play();
state=2;
}
}
}
if (val > 190) {
state=1;
}

this is exactly what i want

I don`t know how can I do it on Max.


June 23, 2009 | 6:40 pm

As usual with Max, there are many ways to do this. Using [< 900] -> [change] -> [sel 1] -> [t 1] is an easy way. Below is a solution that comes closer to the code you provided. Both will only trigger once when the input is < 900 and won't trigger again until the input goes above 900.

When I’m working with data from sensors I’ll often make the "reset" value somewhat more than the trigger value to avoid a situation where you get multiple triggers because the input fluctuates wildly around the trigger condition. In psuedo-code this is something like:
trigger once when input < 900
reset when input > 950 (or some other appropriate value)

– Pasted Max Patch, click to expand. –

June 24, 2009 | 2:07 pm

thanks Holland Hopson.

onebang
it`s really simple idea!!

I know. there are many simple and strong objects in Max.
but so many, and too difficult, and really hard to find T.T

anyway. thanks guys again.
I have to study more
have a nice day//


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