Max les 3 – Programming Objects

Max Windows: console

Before going into the next objects it is important to see where Max sends its error messages for you to debug.

You will find the Console window on the right of any patcher, 4th from the top with the icon:

click on it and leave that side window open for the next object.

Programming means decision making.


The print object has only one function; writting things into the Max console window. The main reason for this is to see what data is coming through Max cables.

1 . Start a new patcher
2 . Add a number box
3 . Add a new object box underneath and type print and connect the two.
4 . Open the Max Console window and see what happens when you change the number box.
5 . Now add a slider on top of the number box, lock the patcher and drag the slider up/down. Do you see the console?


You might remember using the select object in the key example from Les 1.
select is the same as an If-statement. The only difference is in the output.

If the data-in matches the specified number then the output is a bang.

Make the following patch, click in the number box and use arrow keys to go up/down

If Statement

If-statements are more elaborate versions of the select object. You can make very specific If’s which you can’t do with select.


If statements can be found in every programming language, and in general the behave very similar to each other. Booleans are the conditions that an If-statement uses.

You can compare that two things are equal to each other:

This typical If-statement:

IF this IS EQUAL TO that THEN do this ELSE do that

Becomes this with the boolean operator ==:

IF this == that THEN do this ELSE do that

Then you add the values:

IF $i1 == 5 THEN 1 ELSE 0

$i1 is of course the input to the object. This should be a stream of numbers, and if it becomes 5 then it triggers 1 else it is sending 0 everytime the operation is triggered.

recreate the following example which replaces the select object with the if-statement

now we specify a different output

Other Booleans can be:

Other Boolean Operations:
AND &&
OR ||

Opdracht 3-1

Complete the following assignment

Complete the following example and fix the If Statements by using 3 different keys from your keyboard to start each of the 3 videos.

We will use th keys for 1, 2, 3 and space bar. When I look at the key help file and I press these keys I see that these keys are numbered: 49, 50, 51 and 32.

  1. Use an If statement that will send the number of the video when the key is pressed. Here is a hint:

if $i1 == 51 then 3

This should send a 3 when the key 3 is pressed. If you connect that to your Playlist then video 3 should play.

  1. Now repeat this process until you get all three videos playing and the space bar stops all videos by sending a 0

Save this as Opdracht 3-1 and bring it to your lesson