trigger

Ducking when changing delay time

Whenever you change the delay time, you're asking MSP to look at a new location in the delay buffer, which can cause a click in the output if the new sample value is very different from the previous one. One way to get around that is to quickly fade the output amplitude down to 0 whenever you make a change, then quickly fade it back up once the change has been made.

Using gate to route messages

You can assign input data to have a different function at different times, simply by sending it to different parts of your program. For example, if you have a control device such as a MIDI keyboard or other MIDI controller with a limited number of keys, buttons, knobs, or faders, you can assign one control element to be the mode selector that changes the functionality of all the other elements.

Using key presses and releases

Using both the key and keyup objects, you can tell when a key was pressed and when it was released. The split object allows you to isolate a range of numbers; it passes only the specified range of numbers out its left outlet, and passes all other numbers out its right outlet. The numbered keys 0 to 9 correspond to ASCII codes 48 to 57, so it's easy to isolate those keys, and subtracting 48 brings those numbers down into the range 0 to 9.

Linear interpolation over time

The line object sends out a periodic series of numbers that progress to some new value over a certain amount of time. The input to line is a destination value (where it should eventually arrive), a transition time (how long it should take to get there), and a time interval between outputs (how often it should send out intermediate values along the way). The left part of this patch shows the use of line to generate integers that are used as pitches.

Message ordering in Max

Even though Max is graphical, object-based, and event-driven (responds to user events like mouse clicks, key strokes, MIDI data, etc.), it's still sequential. Every message is sent (or scheduled to be sent) at a specific time, and nothing happens truly simultaneously. Therefore, it's important to be conscious of the precise order in which things occur. Study the example above to be sure you understand the way that Max orders messages.