Trigger is a humble but profoundly useful object. It doesn't make amazing sounds or images, but it will keep you sane while you do.

Let's say you have a working patch. You decide that its layout could be a little clearer, so you start moving things around, not changing any patch cords, just moving objects. Then it doesn't work! This can happen because, when an object's outlet goes to more than one destination object, the order of those messages is determined by the position of the destination objects. Layout matters.

bangbangbang.gif

Look at the prints in the Max window to see how moving the print objects changes the message order. That can really mess things up in a complex patch. To bring some law and order to this Wild West of a patch, just type “trigger bang bang bang” into a Max object box. Or, if you’re not feeling all King of the Cowboys, you just can abbreviate with “t b b b”. Now the patch works, no matter how much you move things around. Sanity!

tbbb.gif

Trigger works not only with bang, but with all Max data types. Each argument (b, i, f, l, s) specifies a data type (bang, integer, float, list, symbol) and results in an outlet. Not only that, trigger converts messages from one message type to another. So each type argument results in an outlet of that type, and each incoming message produces a message of that type out of that outlet.

Changing the type of a a message can be tricky, but there’s usually some logic to it. For starters, any message of any type will result in a bang coming out of a “b” outlet. And if you send the trigger object a float, any “i” outlets you have created will output the number with the floating part truncated. So 3.14159 becomes 3. If you input a list that begins with a number, trigger will output the first number only, retyped if necessary, out of both the “i” and “f” outlets.

Here’s a very common use for trigger’s order-forcing and type conversion:

jumpy.gif

When calculating a result from two numbers, normally only the left inlet will produce an output. If you want the calculation to happen for either input, you’ll need a trigger object. Use “t b f” to set the right inlet, then bang the left inlet.

Unfortunately, there are some type conversions that aren’t as obvious. A bang results in a zero from the integer and float outlets. A symbol (a text string) emerges unmodified from the list outlet, as does a list out the symbol outlet. But an integer or float seems to produce no output at all from a symbol outlet. What going on? Well, actually it outputs a message consisting of the null symbol “”, the most Zen of all Max messages. The null message clears the message box and it can trigger a button object, but it doesn’t do anything particularly useful.

typecast.gif

Big takeaway: “t l” will pass anything unchanged! So you can use it to group all kinds of messages together to help declutter your patch. And one more thing: you can use any number or unreserved word as a “constant” argument. Trigger will output that number or symbol regardless of the incoming message.

It’s not a bad idea to use trigger anytime an object has more than one patch cord coming from a single outlet. In fact, if you’re patch is complicated, putting in a long trigger object at the top can be a way to define the main components in an orderly way. And if you change your mind later–say you need to add one more process at the end–you can just type in the new argument. After that (noticing the updated outlet assistance), use option-drag (alt-drag on Windows) to select all the patch cords to the right, then drag them the right so that the outlets line up again:

edit.gif

We noted above that “t l” passes any message. That also goes for pointers, like jit_matrix and jit_gl_texture. And since these messages are just symbols, using the trigger object for openGL textures doesn't result in reading back from the GPU to the CPU. So you can use trigger freely to organize your texture processing.

Finally, here’s a little fact that will amaze your friends. Trigger will actually pass audio through its list and symbol outlets, with a bang coming out all the outlets every time you turn on audio! As far as I know, no one has ever found a use for this mysterious feature.

If, like me, you’re totally in love with the trigger object, and if, like me, you know a tiny bit of JavaScript, then you’re ready to explore the jstrigger object in Ben Bracken’s recent article. Trigger warning: it’s fun.