expr

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.

Sinusoidal events

To generate a series of numbers in Max that outline a sinusoidal shape, you can use the sin() function in the expr object. As the argument in the sin() function goes from 0 to 2π (6.283185), the output will be the sine of that value, going from 0 up to 1, down to -1, and back up to 0. So, by feeding a series of numbers into expr, you can generate numbers that follow that sinusoidal pattern.

Tap Tempo for Ableton Live

Following the “Tap Tempo” example, this is a translation of that patch it into a Max for Live device that controls the Live transport (using the mouse instead of the t key). For the purpose of the example demonstration the code that would reside inside an amxd file is included here inside a Max patch, so you can just see in Max without having to load it into Live.

Tap Tempo

This example shows a super simple tap tempo implementation. The patch alters the transport tempo based on the rate at which you tap the “t” key. This method simply takes the average of the most recent three time intervals between the most recent four taps. So once you tap four times, it will set the transport tempo to your tempo, and if you keep tapping it responds to your changes but takes a couple beats to move gradually to your new tempo.