MIDI

Random semitone trills

A trill can be thought of as a fast back-and-forth alternation between two pitches—or more generally as fast back-and-forth alternation between any two things or states. A back-and-forth or on-off switch can be implemented in any programming language by setting a boolean variable (a variable that's capable of having only one of two states) to its opposite state, with an expression in the form of "If it's 'X', set it to 'NOT X', otherwise, set it to 'X'."

Random voicings of a pitch class set

A chord can be described as a pitch class set. For example, a C dominant ninth chord is the pitch class set {0,2,4,7,10}. Depending on the octave transposition of each of those five pitch classes, many voicings of the chord are possible. This patch take applies a transposition of four, five, six, or seven octaves to each of the five pitch classes to create a random voicing of the chord.

MIDI-DMX conversion

DMX data is encoded with “channel” information similarly to MIDI so that each receiving device can pay attention only to particular information. Each channel can carry a value from 0-255. Note that it’s therefore easy to convert the standard MIDI range 0-127 to the DMX range 0-255 just by multiplying values by 2 (or by shifting the number one bit to the left).

Routing MIDI to other applications

The easiest way to establish MIDI connection between Max and other applications on the same computer is via the "virtual" MIDI ports Max provides. Max creates two virtual input ports and two virtual output ports that can be accessed by other MIDI applications. (You can see those virtual ports listed in Max's MIDI Setup, by choosing MIDI Setup... from the Options menu.)

Delaying MIDI notes

There are many objects available for delaying events (i.e., for scheduling events to happen at a specific future moment). For timing and scheduling events, the most common object is the metro object (send bang periodically at a specified time interval), which can be used to trigger events, start/stop entire processes, or trigger a counter to step through a table or a coll or any sort of sequence of things.

Play a sinusoidal melody

How would you go about playing a melody (or arpeggio) that has a sinusoidal shape? Using a steadily increasing number, you can step repeatedly through a sine function stored in a lookup table, and then scale and offset the result to be in the desired pitch range.

Play a list of notes

The coll object stores an indexed collection of messages. You can trigger those messages to be sent out, just by sending coll the index of the desired message. One way that this can be useful is that you can make an entire musical score in the format of a collection of note messages, each of which contains whatever information you consider vital for describing a note. That’s similar to the way that languages like csound and cmusic read a score file to play notes.