Quantization algorithm in Max _Olivier Pasquet _2019


One of the most important editing functions is quantization, which lets you clean up sloppy rhythms in several different ways. Basically, it shifts each selected event to coincide with the nearest user-specified rhythmic position. It’s usually applied to notes, but it can be applied to other MIDI messages in some sequencers.
For example, let’s say you apply quarter-note quantization to all the notes in a particular track. If a note starts right on a quarter-note position (beat 1, 2, 3, etc.), it is left alone. However, if the note starts slightly ahead of a quarter-note position, it is shifted back to coincide with that position. Similarly, a note that starts a bit late is shifted forward. This helps clean up slightly sloppy playing, but notes that are far off the mark might get shifted to an unintended position.
Quantization is almost always applied to Note On events. It can also be applied to Note Off events, although this sometimes changes the duration of the notes, and the result sounds like it was entered in step time. Most sequencers offer the option to preserve the performed duration of quantized notes by shifting Note Off events by the same amount as the Note On events.
In general, you should use a quantization value equal to the shortest note in the section to be quantized. If you have alternating triplet and duplet figures, you should quantize each figure separately. This is a tedious chore, but quantizing eighth-note triplets into straight eighth notes destroys the triplets.
In early sequencers, quantization was an all-ornothing proposition; the selected notes were shifted to coincide exactly with the nearest specified rhythmic position. However, the quantization function in modern sequencers includes a variety of parameters that let you apply partial quantization to improve the rhythmic accuracy of the part while retaining some of the human feel in the performance. For example, a strength parameter lets you specify how far each note should be shifted; if you specify a strength of 50%, the selected notes will be shifted halfway toward the quantized rhythmic position from their current location. Sensitivity lets you specify which events are shifted. If a note falls within a user-specified distance from the nearest quantization position, it is not shifted; if it falls outside this range, it is shifted.
The swing parameter shifts a string of notes with equal durations so that they correspond to a swing style. In swing jazz, for example, a string of eighth notes is played “long-short-long-short,” etc. The relationship between the long and short durations can be specified with the swing parameter; a value of 75% means that a pair of eighth notes will be played as a dotted eighth-sixteenth pair, which emulates the Lawrence Welk style of swing. A value of 66% turns a pair of eighth notes into a quarter-eight triplet, which corresponds to a more modern style of swing.
The quantization function in many sequencers also includes a randomization parameter, which randomly shifts the selected events away from the specified rhythmic position within a user-specified range to simulate the inaccuracy of human performance. However, most skilled musicians aren’t randomly inaccurate, they are consistently inaccurate, perhaps pushing or dragging the beat. As a result, randomization is not generally satisfying.
Quantizing to an absolute rhythmic position is often called grid quantization. However, many sequencers now offer an alternative called groove quantization. Instead of shifting events to a rhythmic position, groove quantization uses a previously recorded performance as its rhythmic reference. This shifts the quantized events to match the rhythmic “groove” of the reference performance. The rhythmic reference can be extracted from a sequenced part or a digital audio recording, and many sequencers include many groove templates to use in your music.
It is important to recognize when and where quantization should and shouldn’t be applied. If you quantize everything, your music will sound mechanical and uninteresting (unless you’re into techno, trance, and similar forms of music, in which case it will sound mechanical and interesting).

jtol.bach.quantize is part of jtol.
Or direct access to jtol.bach.quantize.maxhelp and jtol.bach.quantize.maxpat.