(max) mapping midi to groove~ controls

example patcher

mapping continuous controllers to groove~ parameters

The example patcher shares the vast bulk of its functionality with the [waveform~] examples in a previous post. The only differences are two subpatchers, [p midiControls] and [p kbControl], located in the blue border in the upper right portion of the patcher.

[p midiControls] has CC’s assigned to control the playback ratio (pbRatio), half-steps converted to cents (centShift), and loop start and loop end points (loopStartDisp and loopEndDisp). pbRatio and centShift are the result of simple scaling operations. For the loop start and end, the scale objects must know the size of the file in the buffer~ in order to know the full range of possible time values. The [buffer~] size is reported whenever a new file is loaded. When a file finishes loading, [buffer~] sends a bang out its right outlet. That bang causes the [info~] object to report information about the file, including its length in milliseconds. That length is sent to the [scale] objects in [p midiControls].

It’s important to note that mapping a CC to a large buffer size will not give you very fine control over your loop points.

controlling playback pitch/ratio

[p kbControl] shows two ways to handle pitch shifting with a MIDI keyboard, sending back either pitch shift as a ratio, or pitch shift as half steps (for shifting by cents in this patcher). Both methods assume a unity key (middle C – 60, unless a different key is chosen). The ratio method subtracts the unity key from the MIDI key pressed and sends that to an [expr] object. The [expr] object allows you to use a C-like math expression. In this case we use pow, which takes two arugments (x, y). The result is x to the power of y. In our expression uses 2 to the y/12 power, which results in equal tempered pitch ratios. Negative y values (half steps down from unity) produce ratios less than 1., lower than unity pitch playback. This ratio method is the only one that works if the timestretch attribute is off.

The other method only works with timestretch on, because it uses the pitchshiftcent method. With this method, you can take the half-step distance from unity, multiply it by 100. (in the parent patcher), and send via pitchshiftcent to [groove~].


Leave a Reply