complex conditional statements in max with JAVA?

Oct 28, 2012 at 2:37pm

complex conditional statements in max with JAVA?

Hi everyone,

I really need a good system to do complex conditional statements in max.
I need to have several inlets and outlets as variables.

I thought the best would be JAVA (?)

How do I have to write for example this in JAVA:

if $i1 == 0 && $i1 < $i2 && $i1 < $i3 then 1 else out2 $i2

thank you!

#64966
Oct 28, 2012 at 4:02pm

you can just use the if object, all you need to do is bracket your statement

– Pasted Max Patch, click to expand. –
#234272
Oct 28, 2012 at 4:20pm

Hi,

thanks but I really need to use another language like java.

Thanks

#234273
Oct 28, 2012 at 4:23pm

AFAIK : It works fine without brackets.

#234274
Oct 28, 2012 at 4:28pm

For language specific questions and to get better responses you should :

- ask in the java forum,
- read a good book,
- search in http://www.stackoverflow.com ;-)

#234275
Oct 28, 2012 at 4:33pm

Java is overkill for this, especially since the edit/compile/load process is cumbersome. If you can’t do what you need via expr, then go for Python. (If it doesn’t need to run in overdrive, then maybe Javascript?)

#234276
Oct 28, 2012 at 4:40pm

to nick rothwell / cassiel: what about C ?
thank you

#234277
Oct 28, 2012 at 5:13pm

Hi,

If (Java is overkill for this) then (C is overkill for this) !

#234278
Oct 28, 2012 at 6:31pm

the expression in question should be done im max.

but if you need something [if] can not do, then it seems logical to ask for a java solution.

(of course you can do quite some complexity with several if, expr, and gate obejcts
and that might be still less CPU hungry and better to program, read and maintain.)

-110

p.s.: to correct myself, he asked about “several outlets”, so it can of course not be done with only [if].

#234279
Oct 28, 2012 at 6:59pm

Thanks everybody!

I was actually looking for a smart and easy system to write in a row several conditional statements in one object without creating several if/expr/gate and other objects and connect all them together…
Something like a conditional tree.

I just kind of needed to write a few conditional statements like this “if $i1 == 0 && $i1 < $i2 && $i1 < $i3 then 1 else out2 $i2" in JAVA.
I really don’t know quite anything about JAVA but, I thought somebody could write me this condition in Java so I could maybe do some more complex conditions just in one js object…

Maybe it doesn’t make really sense…

Never mind!

Thanks!

#234280
Oct 28, 2012 at 7:17pm

see my post scriptum above.

actually i dont think it will be that easy in java to be able to write such expression in one line.

in java you will also need to define variables and then nest several if abstractions with brackets and returns to make something complex. :)

i also often wish to have three outlets or the possibilty to have operators and math stuff behind the “then” in [if] but i have never found a solution, at least none which gives a nice way of generalizing that for an abstraction.

#234281
Oct 29, 2012 at 11:01am

You could do this stuff as Java one-liners, but it would look a little untidy. (I didn’t suggest C because of the hassle of setting up the tool chain, and all the boilerplate code, the lack of portability, and the lack of any ability to reload changes into the Max session.)

But really: Python. Really. https://github.com/cassiel/net.loadbang.jython

#234282
Oct 29, 2012 at 11:31am

thanks guys!

My actual purpose is to write a software for midi elaboration and I am just using Max as a surface to write and order all my ideas I have in mind.
I will need to rewrite the project in a common language used for music software.
So what I basically will need is a language which makes all my conditional operations fast and without using to much CPU.
I know most of the music softwares are written in C but my software is just about midi so I do not really know what would be good.

So, what I thought is to start writing some ideas already in the language I will use to write the software and embed them in Max.
That’s why I thought about Java or C.

I will try Python but I don’t know if I will use this for the software.

I don’t want to bother you guys anymore with this…

Thank you!

#234283
Oct 29, 2012 at 11:51am

Hi,

- Do your prototype in the language (MaxMSP included) that you know the best.
- Learn a bit of C / Java / C++ / Python / Ruby… to understand pro and cons of each.
- Then rewrite everything in the language you have choosed.

“So, what I thought is to start writing some ideas already in the language I will use to write the software and embed them in Max.”

I did exactly what you try to do and i regret ;-)

My 2 cents.

#234284

You must be logged in to reply to this topic.