Routing integers depending on whether they are greater than a given number
Hi - I'm a Max beginner and am trying to write a patcher that can generate basic counterpoint. I have one basic problem so far: I have a steady output of numbers that I am printing. I want all numbers greater than 7 to have 7 subtracted from them, and for nothing to happen to the numbers under 7. I've tried the "greater than" object but this doesn't seem to be ideal because it passes on a bang, not the actual number. Thanks for your help - I've already gotten a lot from this community and I'm sure I'll continue to do so. You'll probably be hearing a lot from me - I hope that's okay!
Figured it out! Wasn't aware of the "if" object but that ended up being just what I needed. Sorry for the inconvenience.
That's good news. The expanded search on Max 8 makes problems like this a lot easier, since you're now searching your app, your stuff and the whole Forum....
noob version:
[split -500 7]
/ ..... /
.....[- 7]
nerd version:
[expr ($i1>=7)*($i1-7) + ($i1<7)*($i1)]
[if] stinks!
Roman those both sound like great solutions. Why do you dislike the "if" object, if you don't mind me asking?
it needs a lot of CPU and confuses beginners how to use it.
in the given case, you couldnt do the "...then input-7" part inside it, because operations are only allowed before the "then".
if $i1>=7 then $i1 else out2 $i1
you would only recreate the [split] object with it.
however as an exercise, you should build a version using [>=] and [gate], too.
Excellent suggestion on the >= and gate exercise, Roman.
Cool, thanks for the idea Roman! I tried setting up something like this, but I think I might have poorly explained what I need in the end. I wrote something using > and gate that indeed allows me to isolate numbers over 7 and subtract 7 from them, but in the end I want to be printing all the numbers: those that are below 7 and those that are above 7 with 7 subtracted from them. Using > and gate I can only get those numbers over 7.
If you want, I can paste my patch (not quite sure how to do that yet though...)
https://cycling74.com/forums/how-to-post-patches-to-the-forum/
perhaps something like this
little error on my part. you need to use
[gate 2]
to do this.
as seen in the gate helpfile. :)