[pitch] object for Max

ricky's icon

Hi Guys,

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.

Cheers,

Ricky

3653.pitch.maxhelp
maxhelp
Roman Thilenius's icon

with expr: [expr min(max($i1,127),0)]

with clip: [clip 0 127]

choose one.

i have chosen -110.

Roman Thilenius's icon

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"

Roman Thilenius's icon

send "$0" must read "send #0" in max or you cant instantiate the abstraction.

ricky's icon

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?

Best,

Ricky

brendan mccloskey's icon

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

but not

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.

Brendan

ricky's icon

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?

R

brendan mccloskey's icon

Try [zmap 0 127 0 127] too;

QUB coffee on Monday perhaps

ricky's icon

Sure. I will drop you a mail.

R

Roman Thilenius's icon

"So, [expr] cannot take an [if] statement in Max? and [if] cannot take multiple/nested instances?"

exactly.

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

[expr min(max($i1,127),0)]

you could write

[expr ($i1>=0) && ($i1

-110

ricky's icon

"(dont tell me there is one in pd!) "

Yes, there is! :)

Thanks for the clarification, Roman.

Ricky

Roman Thilenius's icon

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.

ricky's icon

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.