microtonal MIDI: cents to pitch bends


    Feb 21 2014 | 8:31 am
    hi - i was hoping someone here could explain the relationship between cents and pitch bend information in Max. i'd like to be able to implement microtonal scales with MIDI information.
    thanks!

    • Feb 21 2014 | 9:18 am
      well, you can't send floating points midi notes through midi communication prootcol, to a midi vst~, for example so when you have a midi note with flaoting point, you separate the full part and the floating part, the full part is the midi note, and the floating part is sent as a pitchbend value. The pitchben "bends" the midi value with midicents precision iirc. A midi cent is a 100th of a midi note, and most of the pitch bends are able to finely tune a midi note at that precision. What might be tricky is polyphony. It may happen that several notes are sent on several different midi channels, because there can be only one pitchben tunong for each channel at a time, so that you can have multiple notes at the same time with different pitchbended values. There is actually not really a standard for that, and it varie sfrom one instrument to the other ; microtonality in MIDI can be indeed tricky... If you want to invest time in microtonality, i strongly recommend that you give attention to Scala ; a free and powerful software for microtonality : http://www.huygens-fokker.org/scala/
    • Feb 21 2014 | 12:01 pm
      At the risk of stating the obvious: many modern MIDI implementations allow you define a custom tuning, typically including presets for things like Werckmeister, Meantone, Kirnberger, as well as a variety of non-European tunings like Maqam, Pelog, Slendro. The limitation is that the tuning in based on some kind of 12-step (not necessarily equal) division of the octave. This can be the simplest approach, but may not be what you're after.
      If you're going to use MIDI pitch bend, aside from the polyphony problem, also note that it's a two-step process. By default the maximum pitch bend is +/- a whole tone from the central pitch, in increments of 1/16,384 of the total range. But there's a MIDI command to define the maximum range to something else (if you need greater accuracy or, otoh, if you want a greater range and can live with less accuracy). With the default pitch bend range, you can detune in steps of approx. 1/40 of a cent, which is more than sufficiently precise for most purposes.
      The pitch bend information can also be divided into two components: coarse tuning and fine tuning. The coarse tuning divides the entire pitch bend range into 128 (relatively large) increments. See the Max reference for [bendout] and [xbendout].
      Just to confuse matters, in an attempt to simplify things, some implementations talk about a pitch bend range running from -8192 to +8191 with zero representing the original equal-tempered pitch, whereas others define the range in terms of 0 to 16,383 with the original pitch at a pitch bend value of 8,192. Max is working on the latter basis.
      The whole area is sufficiently deep that you really ought to spend some quality time with the MIDI spec (and a reference for the MIDI implementation you're using) and the Max reference. Once that's under your belt, there's just a little simple arithmetic to convert between cents and pitch bend. In the simplest case take your cent offset, and send it through something like [expr $i1 * 16384 / 400 + 8192] (the formula may need tweaking, depending on the implementation you're using).
      One way to finesse the polyphony issue would be to use MIDI aftertouch messages and map these to detuning (assuming your MIDI implementation supports this). But that's left as an exercise for the reader.
    • Feb 21 2014 | 4:10 pm
      fyi, the bach library contains an abstraction (bach.ezmidiplay) providing a basic implementation of microtonality through pitch-bend. aa