Forums > MaxMSP

complex conditional statements in max with JAVA?

October 28, 2012 | 2:37 pm

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!


October 28, 2012 | 4:02 pm

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

– Pasted Max Patch, click to expand. –

October 28, 2012 | 4:20 pm

Hi,

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

Thanks


October 28, 2012 | 4:33 pm

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?)


October 28, 2012 | 4:40 pm

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


October 28, 2012 | 6:31 pm

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].


October 28, 2012 | 6:59 pm

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!


October 28, 2012 | 7:17 pm

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.


October 29, 2012 | 11:01 am

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


October 29, 2012 | 11:31 am

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!


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