Detecting When a Value is Between Two Values (Split object?)
Hi,
I've just switched to max from PD and I'm struggling with the differences with the use of expressions.
what I want to do is - if inlet 1 is greater than 32 but less than 65 then output the value received by inlet 1, else output 0.
I can achieve this in PD using an expression quite easily but I'm stumped in Max, the expressions just don't seem to be behaving like I'd expect.
I've been using the split object which almost works but when the received value is out of range it does not return to 0 which is what I need here.
Any suggestions would be greatly appreciated, it's gone 3am here and I'm getting desperate. Thank you.
the example use an if-else statement
"if inlet 1 is greater than 32 but less than 65 then output the value received by inlet 1, else output 0."
condition-A logical-and condition-B, multiplied with the desired output for "true":
[expr (($f1>32.)&&($f1
you could also multiply the conditions, but i believe it is by far better readable this way.
i am curious how it looks in pd?
-110
Thanks for your replies.
It must have been the lack of sleep that made me think that I'd know how to do it in PD because I actually don't. I'm useless with expressions.
I've ran into another issue but I didn't want to make a new post.
Does simple math work the same way in max as it does in pd?
I'm trying to divide an incoming midi signal by 127 to get a value between 0 and 1 but [ctlin] into [/ 127] into [flonum] will only give me either a 0 or a 1. Am i missing something incredibly basic?
Edit: Got it in the end, I didn't realise you needed a . after the number, I got confused because pd doesn't use integers so there's no need to specify.
Yes.
Max/MSP distinguishes between ints and floats, whereas Pd only has floats.
In Max/MSP, if you want floating point arithmetic, you must instantiate the object in question with a floating point object, viz: [/ 127.] (note the decimal point). Otherwise you get integer arithmetic, which behaves (correctly) the way you observed.
Always instantiate objects with float arguments if you want float results!
For that matter, no matter how experienced you are with Pd, you will benefit from perusal of the Max/MSP documentation and tutorials. There are plenty of other gotchas.
Thanks for the clarification, there are a few more minor differences than I was led to believe but Max seems to be far more intuitive when you don't quite know what you're doing (like me). Despite a few hiccups I'm enjoying myself and am looking forward to properly getting to grips with max once I get this last minute project out of the way (I'm doing things backwards as per usual).
Max and Pd are sort of like identical twins that were separated shortly after birth and then meet up in their mid-twenties. They manage to have some things in common, but there are plenty of differences!
Good luck with your project. FWIW, as someone whose background is Max/MSP, I've found working with Pd to be full of little surprises.