[pitch] object for Max
First post, long time Pd user. Using Max for some teaching. I created an abstraction based on the [pitch] object available in Pd by Olaf Matthes, which organises incoming MIDI note numbers into pitch-class, pitch-class distance and register. So, I thought I’d share:
Rather than using the two [if] statements, I would like to know how to program this function in one [expr]-based statement.
with expr: [expr min(max($i1,127),0)]
with clip: [clip 0 127]
i have chosen -110.
weird. in the above post i first forgot the commas in the formula – after sending it to the forum the zero had vanished – the forum does not like "backslash 0"
send "$0" must read "send #0" in max or you cant instantiate the abstraction.
Good to know. Thanks Roman. I have updated the patch. So, [expr] cannot take an [if] statement in Max? and [if] cannot take multiple/nested instances?
Hi Ricky and welcome to the forum
Sometimes we WANT our objects to do stuff, which they won’t and it’s frustrating to have Max tell you "sorry, won’t work dood"; in my experience the [if] object can only have ‘binary’ output
if apples or bananas then pig else goat
if apples then pigs, elseif bananas then goats.
I’m almost 99.9% sure [if] in Max doesn’t do elseif.
But an [expr] ninja will surface soon with a solution; Roman’s [clip] is simplest.
Cheers, good sir. Yes, I have gathered all of the points above through "enactive research." Actually, using min and max within inspector is the easiest solution for that particular statement, but I would like to get [expr] working beyond what I have already implemented (if possible).
I should add, when I enter a backslash into an [expr] object in Max 6, it disappears completely (much like like Roman’s issue with this forum).
Nice to meet your virtual Max-based acquaintance. Coffee soon?
Try [zmap 0 127 0 127] too;
QUB coffee on Monday perhaps
Sure. I will drop you a mail.
"So, [expr] cannot take an [if] statement in Max? and [if] cannot take multiple/nested instances?"
there is absolutely no if in [expr] (dont tell me there is one in pd!) and you cannot have nested outputs with [if].
the only thing what works is using multiple conditions on the input of if:
[if $i1>100 && ($i1+5)%12>$i2 then bang]
what you of course can do in expr is using boolean/comparison operators to sum up conditions.
so instead of
you could write
[expr ($i1>=0) && ($i1< =127)] … and control a [gate] with it.
"(dont tell me there is one in pd!) "
Yes, there is! :)
Thanks for the clarification, Roman.
so i learned something new about PD, thats fine. i wish there would be some kind of expr overview or tutorial, i have gathered everything by trial error and sometimes i think i still miss something.
btw, using min and max to the numberbox is the worst you can do. GUI objects have nothing to do inside abstractions, they need to much CPU.
Yep, sure. GUI objects are expensive no matter what the environment. I said it was the easiest solution, not the best solution ;) Thanks again for your clarification.