Forums > MaxMSP

So simple its not documented?

April 29, 2008 | 4:45 pm

Max is, for me, the most difficult programming language.

I cannot make it loop or execute working if statements.

For example [if $i1 > 0 $i1-1] does not deincrement.

If someone could patch the equivalent of if(i<0){i++;} and for(int i=0;i<3;++i){print(i);} I would be super-super-super grateful!! :)


April 29, 2008 | 5:18 pm

Attached is my effort. Is this the most elegant solution?


April 29, 2008 | 5:22 pm

On 29 avr. 08, at 18:45, Glen wrote:

> If someone could patch the equivalent of if(i<0){i++;}

Something like that?

———-begin_max5_patcher———-
478.3ocyV00SBCCE84seEMM9lfY8iACiu3uCiwrwpPMasj0RD0v+c6taCACB
Mvf3Ks4d6s8dNmcus6qv.bldkvfQ2idBED7UXP.3p1QPqc.tLc0zhTCDFVsr
LSTgGzrzhT6z4R0rWpDSsMGCMJ9tnAH5XXJNBLbinma2idosPXserPzrArTY
wCP3rT0L7lnj4P5zYuMbRW1dUqrpzRXe3GqjoEauhQ9IrBg5RYiaGXkJWx.n
S5vbkvHT1TqTq1B2D1X.pifon1gM3wcTM.GNKZsy0gg0CC7T4xVZsZ0wUNNo
SxNlv8mJVB9PBvtTgbBTQId2kltjXEq.FfKzo4kBiAML9.zjDk.UF75wwiNN
M2KEG0uEEWLMwUssPnxQFg8Pe5oS.cf.Si4mnnv+2IJddaAIJputsfcI0.Z+
UXbKhb7BBRBTJvn2E6itrO8f1O5A8R2nHeEcijfd.EgryEpZCOpa37lxG5I1
wPtVcLPxwER0uetEHWs+ckLidY0zNn2hTzOrKWXrRE7F1VwLYmXlKyyEvxcX
tTluP6JTZg.54894yWDk3AhXWUDM5eGhXdfHxUEQ79WinrD39oX3OWXLFzLt
iURSCJgWGXswYxBpGrfeU0Ue5OomAhbFqC+FjFypGB
———–end_max5_patcher———–

> and for(int i=0;i<3;++i){print(i);} I would be super-super-super
> grateful!! :)

[uzi 4 0] + [print]

Otherwise, you can do all those kind of things easily in JavaScript
with the js object.

ej


April 29, 2008 | 5:47 pm

I’m quite strong with JS and its ilk. However, I am forced to use max/msp/jitter as patches.

How can I save the example? I copied it to an empty text file, and Max opens it as a text file – lol (I’m using a Macintosh)


April 29, 2008 | 5:51 pm

On Apr 29, 2008, at 12:45 PM, Glen wrote:

> If someone could patch the equivalent of if(i<0){i++;} and for(int
> i=0;i<3;++i){print(i);} I would be super-super-super grateful!! :)

[rtcmix~] — http://rtcmix.org/rtcmix~
[chuck~] — http://music.columbia.edu/~brad/chuck~
[maxlispj] — http://music.columbia.edu/~brad/maxlispj
[ajm.ruby] — http://compusition.com/web/software/maxmsp/ajm-objects
[mxj] — (included w/ max/msp)
[js] — (included w/maxmsp)

and I’m probably forgetting some obvious ones…

brad

http://music.columbia.edu/~brad


April 29, 2008 | 6:14 pm

On Apr 29, 2008, at 9:45 AM, Glen wrote:
> Max is, for me, the most difficult programming language.
>
> I cannot make it loop or execute working if statements.
>
> For example [if $i1 > 0 $i1-1] does not deincrement.
>
> If someone could patch the equivalent of if(i<0){i++;} and for(int
> i=0;i<3;++i){print(i);} I would be super-super-super grateful!! :)

In Max, looping == counting. The main objects you’ll use for this are
counter and uzi, although there are other possibilities.

It takes a while to get out of a traditional language mindset when
starting out with Max. Once you get used to the Max way of doing
things, you may even like the way max iterates. If not, you can
probably cobble up a couple of abstractions that work the way you
think iteration should work.

Here are a couple examples of Max looping:

———-begin_max5_patcher———-
995.3oc0YtsaihCFG+5jmhOg1KZUSF4CDBYZ2QZeGVs2rZzJRvswiBlHvrsy
T0280XSRmlBXmC3syEEDFp8e+yemryyiGErL+IVY.7Y3ugQidd7nQ5lpaXTy
yiBxRdZ0ljR8mErrRJyEASLuRTkkWI2vj5WhaZ0zj76aYldNXYh3g.3qMulm
p6o7keaZ3hc8z1D4p0bwC+SAakz7uQC+DZBPI35aDztq66G0fyE6G651dY73
5KSbbtrJOKiIj6jfj8jdjC9SVojBSg6yKthKj.+2Q2xuid6M2vu94sEplthe
8suzNDPMsdetPJRxzHH3uXEoIhj8S1BVoZfSj7bw6mvH8MTyk8S25Nrj+CcG
hq+j2QSpcZRhiM2H5agWRbJXOpTw6noFXfloGAw9iBdxlf1l5j1l5gH6FRwZ
jFM+xaH0wLu5GbfBn1m0Tqy51cil75cEWCZ27ncFEZmQyz1EgQ8yHxkiQIKK
6OXxQvmijGzY8viYlvNXL13S5MiFUuxypx5xrgbZX43sVnD6zIRGLIZg2rVT
eyGC3fs5JYBzNmd4YSWos3v+lnlqK2vN03rcjWJVGNfpQgk7RsRKRulRFDEZ
b2l4OGsWyKQFt7RDpcuHBIZvRLUksjUbpNK8VlRHItUygt7vdaMfNPtPGhNu
PyrAwnY3HGESOCxoDRIqZ6goHs.yH6vLjLXrryxiN0Ri5muyQtw2yrdJxbGr
PoK7bAUqxqDxtrbCO4Dj696XYTrCLxD4agEFM6BuCOhZGd76uheG55m42byP
reNylrhom394HHGfmdLvM0YD5isGe2THkskIRUBBxEviqSjv2yqfGSTITk4P
Z9DPtlWBY7GVKgkLHiIKxgG4x0PBrgKUzEdXSECl9kgK2KtO+yE5rW3Pjo3i
H+c5BmeYZNL06aqMlx4hnCVAW840g0dcvuwwvW.T88o3S2wytODlZsRc7hAy
ExZom3AzFv9dTHj4eLq77RUDIF4vpermq6QBbf++7FXmamKMm7A4Sy9Uz13j
JSNxJUhB+0oH4K94GZ2loIcp2q1EvpbIjOH075PFGyAmgQH2K4U+EAa3hC+8
ZziRc6ukdk4UEq1Mg1c7u.Y+.kpx9vE5RV+4OREvDdUMq4ooLwOmQJimtMWA
jFQ.es00Rm0zh2LbcnoPupo5iE1plp26mO0DwEME+lEXqZZFEUGauI+m4Tbq
e3L0pVFV0peWSOX4pG98AaM8.iwAmSQtnIhW0jSRB62kNrCZxuQHNvgpCKbp
W0DF4flv9coyEL4WJUamfcPQGSj84lydbl9GhJb+CmqYuKKmHuCOq0ObFJR8
vKi+OzB5cPN
———–end_max5_patcher———–

Chris Muir
cbm@well.com

http://www.xfade.com


April 30, 2008 | 1:33 pm

Quote: administrated wrote on Tue, 29 April 2008 19:47
—————————————————-
> I’m quite strong with JS and its ilk. However, I am forced to use max/msp/jitter as patches.
>
> How can I save the example? I copied it to an empty text file, and Max opens it as a text file – lol (I’m using a Macintosh)
>
—————————————————-

Copy (**including** the begin_max5_patcher and end_max5_patcher lines in their entirety) and Paste.

Regarding if: the if object does not evaluate expressions in the then/else blocks. Period. It sends something out an outlet and you do whatever you need with patching. The tutorials demonstrate this, and the ref page explains it, too, but people keep on insisting on writing [if ($i1 > 0) then sqrt($i1) + 42 * $i2^38 - asin($i3) / pow($f4,j0($f6) else send foo baz] and wondering whydonitwork.

Max don’t work like that.

Max is not a difficult programming language. You do have to learn the mindset. People coming from FORTRAN-based languages can’t imagine how to program without gotos while ignoring the utility of the switch/case construct used in C and Algol-based languages. Java doesn’t make sense unless you grasp OOP. GPLs seem weird until you grok dataflow. But none of these things make a language difficult. What makes any language difficult is insisting on it behaving like something it isn’t.

Spend some time with the tutorials and you’ll save yourself a lot of heartache.



kjg
April 30, 2008 | 4:53 pm

Quote: Peter Castine wrote on Wed, 30 April 2008 15:33
—————————————————-
What makes any language difficult is insisting on it behaving like something it isn’t.
>
> Spend some time with the tutorials and you’ll save yourself a lot of heartache.

Amen!


May 1, 2008 | 3:55 am

yep, looping is counting… use counter, uzi, modulus if you need, inc-dec, etc. hook several uzi’s together to make nested for loops. The "if" is ok for some things but I usually find that select works as well or better in most cases. expr and sprintf are also very handy.

Agreed, some things are easier (or work better) in text-based code, so stick in a javascript for those. However, you’ll find a ton of other things like some methods of list management, presets, saving and loading files, automation, etc. etc. that are so easy in Max you’ll wonder why you ever tried it in code. Not to mention all the customizable interface objects that are made for you. unless you’re some kind of code genius and already know all that ;)

It’s really worth the effort, particularly with 5, so stick with it!

–CJ


May 1, 2008 | 3:59 am

I got nothing when I copy and try to paste the code… grayed-out….?


May 1, 2008 | 4:38 am

Quote: seejayjames wrote on Wed, 30 April 2008 20:59
—————————————————-
> I got nothing when I copy and try to paste the code… grayed-out….?
—————————————————-

Are you copying everything including the lines:
———-begin_max5_patcher———-
———-end_max5_patcher———-

You should be.

-C

p.s.
You do have 5.0.1, don’t you?

This post seems to contain a broken pasted patch. This can happen if you don’t copy the entire "———-begin_max5_patcher———-" or "———–end_max5_patcher———–" for each and every patch you paste; perhaps you missed a preceding or trailing "-" when you copied the patch? Please notify the Cycling 74 web team if you think it is a bug.


May 2, 2008 | 8:17 am

Seejay James schrieb:
> yep, looping is counting… use counter, uzi, modulus if you need,
> inc-dec, etc. hook several uzi’s together to make nested for loops.
> The "if" is ok for some things but I usually find that select works
> as well or better in most cases. expr and sprintf are also very
> handy.

I found the help file to [until] in Pd instructive, I made an abhaXion
called "until". The Max 5 version attached…

save as until.maxpat:

– Pasted Max Patch, click to expand. –

and the until.maxhelp:

– Pasted Max Patch, click to expand. –


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


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