Max

MIDI mapping to amplitude

Mapping one range of values to another needed range of values is a crucial technique in computer music. In this example, we want to map MIDI data values that range from 0 to 127 into a useful range for controlling the amplitude—and thus the loudness—of a sound in MSP.

MIDI note off messages

Every MIDI note-on message must be turned off at some time by a subsequent corresponding note-off message for the same pitch (or note-on message with velocity 0). This patch shows two ways to ensure that. One is a very simple way that's illustrative but not ideal; the second way is much more versatile and is the preferred way.

Linear control signal

The phasor~ object produces a linear control signal that goes repeatedly from 0 to 1. That's demonstrated in the upper left part of this patch. In general, a control signal that goes gradually in a straight line from one value to another is quite useful, but you don't always want it to repeat over and over the way that phasor~ does.

Abstraction for hexagonal constant-intensity panning

For speakers that are configured in a circle or in the vertices of a regular polygon, you can give a sense of localization of a sound by calculating the radial angle of the sound's desired virtual location relative to the center of the listening space, and then panning the sound between the speakers that are closest to that virtual location. In other words, for any virtual location that you want to imply, you need to calculate which speakers are closest to that location, and then pan the sound between those speakers.

Beat divisions with transport

In the MIDI specification, and in most DAW software, and in Max, the smallest unit of metric timing is expressed in "ticks", which is to say, partial units of a beat. Commonly the number of ticks used is 480 or 960 parts per quarter note. That number makes sense because it's divisible by 2, 3, 4, or 5 (and multiples of those).