Forums > Max For Live

"If .. Then" type functions?

February 13, 2012 | 6:01 pm

Trying to build a scene looping patch – the ‘loop length’ bit is still not quite working (see here – http://forum.ableton.com/viewtopic.php?f=35&t=176480 … But should be soon – for the next bit -

How can I get Max to select for integer numbers? To make an expression something like –

If Newscene >= EndScene then set Currentscene=Masterscene

– Pasted Max Patch, click to expand. –

February 13, 2012 | 6:07 pm

[if $i1 >= $i2 then $i3]

provides 3 inputs, where third is your currentscene (or masterscene, i´m not sure what should becomes what).


February 13, 2012 | 6:11 pm

Nice one thanks, will try it now


February 13, 2012 | 6:19 pm

xidance probably has the best solution for you there.

But I’ve found (for the way I think about things, anyway) sometimes it’s easier to implement/easier to understand what you did later (depending on the situation) if you use [>=]

EndScene into right inlet
NewScene into left inlet

so then, when NewScene >= EndScene, it sends a 1

so I would do either a toggle to trigger the next thing or a [sel 1] to send a bang to trigger the next thing

But like I said, only sometimes it’s easier (for me personally).


February 13, 2012 | 6:23 pm

Alright, thanks, great, got this working with

[if $i1 >= $i2 then $i3 else $i1]

But… I’ve just realized I need to do something else to properly reset it… I need something more like

if $i1 >= $i2 then [SEND RESET MESSAGE TO START OF CHAIN] else $i1

How can I do that?

Please take a look at this patch – problem bit is on left with notes!

– Pasted Max Patch, click to expand. –

February 13, 2012 | 6:26 pm

[if $i1 >= $i2 then out2 reset else $i1]

provides 2 inputs and 2 outputs, sending "reset" (or whatever) to output #2.

sorry don´t have time to look at the patch right now.


February 13, 2012 | 6:27 pm

AH ok thanks I’ll try that


February 13, 2012 | 7:02 pm

Use gate 2 1. You can execute whatever logic you want in the two outlets.

I find that if-then is not a great solution for most things because it is so limited, and IMHO, I avoid it in all but the simplest cases.


February 13, 2012 | 7:07 pm

Ok I got the IF bit working, not sure the best way to reset this patch though to make it ‘loop’ – much obliged if anyone can help.

– Pasted Max Patch, click to expand. –

February 14, 2012 | 12:14 am

Ok well, figured a more elegant way of getting this working would be to just make it look ahead for the next ‘master’ scene – if it’s there and it receives another ‘next scene’ command, it loops back to the start…

I’ve got the ‘look if next scene=master’ bit working, but I’m such a noob at this I have no idea how to set up the loop back to start bit, any advice very welcome!

– Pasted Max Patch, click to expand. –

February 14, 2012 | 2:08 am

what peter talks is true, [if] is like a habit from old days. in max you’re more with gates/switches/routings (or even splitters) and logic/math-operators. i think they are also processed much quicker internally even though you’d sometimes need three+ objects instead of one [if].


February 14, 2012 | 7:18 am

Ok, thanks… if anyone can give me a tip on resetting the above scene ‘looper’ I’d much appreciate it. It’s nearly there now, just need an elegant way of getting it back to the master scene once it ‘sees’ the next master.


February 14, 2012 | 5:47 pm

Ok, in the end I went for a system that would just look for ‘mstr’ in the next scene and then loop on the next ‘scene advance’ command… it’s not quite as dependable if I use my MIDI controller but its seamless for my drummer to loop through scenes, so it’ll do for now.

What it could really do with is something that looks ahead x scenes, spots the next master scene, and then sets a loop length based on that. But no way I know how to write that one! This’ll do for now – working code! :D

Here’s the current version in case it’s useful to anyone:

– Pasted Max Patch, click to expand. –

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