New Tuning Method

From Xenharmonic Wiki
(Redirected from Tuning RPNs)
Jump to navigation Jump to search

Update June 2016:

This tuning method is currently only implemented in alt-tuner and bounce. It only works with one synth, Kontakt, via a user-installed script. Contact the makers of alt-tuner and bounce for implementation details.

A new microtuning method for midi synths:

As we're all painfully aware, the midi spec isn't very microtonal-friendly. The powers that be decided that pitch bend messages would affect the whole channel, not individual notes, so retuning most synths requires dividing the midi stream among multiple channels. That increases setup time for the user and reduces polyphony, and generally complicates matters. The powers that be did create the Midi Tuning Specification (MTS) sysexes, http://www.midi.org/techspecs/midituning.php. The single-note real-time sysex is the most powerful and useful one. MTS sysexes haven't been widely adopted, except for high-end Roland keyboards which use the considerably less powerful non-realtime Scale/Octave Tuning sysex.

Sysexes have the disadvantage of being poorly supported in many environments:

  • Abelton Live filters out sysexes from the midi stream and keeps them from any VST it hosts.
  • FL Studio also does not allow VST plugins it hosts to receive sysex data. (see footnote)
  • Studio One doesn't allow recording or playback of sysexes.
  • Kontakt does not provide sysex support in its scripting language.
  • CSoundAV (CSound in real time) can't receive sysexes.
  • SonicBirth (an AU maker) doesn't even mention sysexes in its manual.

This means that synths created with CSoundAV or SonicBirth can't implement MTS. Any synth that does implement MTS won't do so if hosted in Abelton Live or FL Studio or Studio One. Also, Kontakt instruments can't be scripted to respond to MTS. For these reasons microtonalists have been considering alternatives to MTS sysexes.

The powers that be will probably never change the midi spec to give us what we want, a non-sysex method for tuning individual notes. So we've decided to simply create a new unofficial microtuning method. The plan is to have the new method supported by all the major midi tuning software packages, aka retuners: Alt-tuner, Bounce, Custom Scale Editor, Fractal Tune Smithy, LMSO, Scala, etc.

The obstacle to any retuning method is convincing the developers of VSTi's and other softsynths, as well as the designers of hardware sound modules and keyboards, who generally have no personal interest in microtonalism, to invest their time and energy in implementing it. To this end, any new tuning method should be as easy to implement by synth developers and designers as possible. Even small impediments like converting pitch bends from the usual midi format to the MTS format should be avoided. The sysex format should be avoided entirely because of the poor support and because of the added difficulties of parsing variable-length midi messages.

The new tuning method is currently still being hashed out on the facebook group https://www.facebook.com/groups/xenharmonic2/. Once completed, we will have a more enticing sales pitch for synth developers and designers: Add this simple easy method of retuning and you will sell more synths to microtonalists.


Design:

There are 3 parts to a tuning message: the input note, the output note, and the pitch bend. The input note is a midi note number which specifies a physical key on the controller. The output note is a midi note number which specifies a pitch in the standard A-440 12-ET tuning. The pitch bend specifies how much to bend the output pitch. Upon receiving the input note, the synth produces this frequency:

frequency = 440 * 2 ^ [ (outputNote - 69) / 12 + (pitchBend / 8192 - 1) / 24 ]

The pitch bend range is "hard-wired" to 1/2 of a semitone = 50¢, one twenty-fourth of an octave, hence the 24 at the end of the equation. If the physical pitch bend wheel is moved, that bend would be added onto the tuning bend. The physical pitch bend wheel is not hard-wired to 2 semitones and is governed by the usual pitch bend range.

Because microtonalists use array keyboards, there may be a full 128 keys in use. Any input key can be mapped to any output frequency. Because alternate tunings can have more than 12 notes per octave, more than one input note may be be mapped to the same output note. Therefore the pitch bend is associated with the input note, not the output note. Specifying an output note is optional. If none is specified, the output note is understood to be the same as the input note.

The retuning is immediate (real-time), just like the standard pitch bend. One aim of the tuning method is to make extremely wide pitch glides possible. The synth should be able to retune a note as it's being played. Specifically, a tuning message that changes the output note number should not trigger a new ADSR envelope. That should only happen in response to note-ons.

This might be easier to understand if a hardware implementation is visualized. Imagine a 10-and-a-half octave keyboard with 128 keys. Behind each key is a tiny transposing slider and a tiny pitch bend wheel. The slider runs from 0 to 127 and sets that key's output pitch. The slider doesn't travel smoothly, rather it clicks into place on the whole numbers. The pitch bend wheel runs from -200¢ to 200¢ and sets the bend. When the keyboard is first turned on, all these wheels are set to center and all the sliders are set to match the key -- the lowest key's slider is 0, the 2nd one is 1, etc. Unlike the usual pitch bend wheel, which this keyboard also has, the tiny wheels don't have a spring that returns them to center. If one is moved to +30¢, it stays there until moved again. Using the sliders and wheels, any key on the keyboard can be set to play any pitch in the entire 10-and-a-half octave midi range. The synth's job is to produce whatever pitches are required by the keys and sliders and wheels, which may be further bent by the usual pitch bend wheel.

Sometimes the keyboard will actually be a touchscreen device, and instead of pressing a key, the musician simply touches the screen to play a note, with the touch's location determining the pitch. Dragging one's fingers along the surface generates ultra-wide pitch bends. This is a polyphonic device, with each finger being in effect a separate "key". There may be no retuner, because the controller (or iPad app) will generate its own tuning messages. The imaginary keyboard analogous to this device has no tiny wheels and each tiny slider can travel freely without clicks. From the synth's point of view, the midi stream is the same as from a keyed controller: note-ons and note-offs mixed with tuning messages and perhaps standard pitch bends. A touchscreen device may also be used with a retuner; thus there are 3 possible setups that would use this tuning method:

  • keyed controller --> retuner --> synth
  • touchscreen controller --> synth
  • touchscreen controller --> retuner --> synth

Multi-timbral synths should be able to handle as many as 16 of these keyboards at once, one per channel. A multi-timbral synth should be one of 3 types: mono-tunable, multi-tunable, or switchable. Mono-tunable synths force all channels to adhere to one tuning. Channel information in tuning messages is ignored, comparable to midi's omni mode. Multi-tunable synths permit all 16 channels to be tuned independently. Switchable synths can be switched between the two modes. The advantages of mono-tunable are a reduction in the volume of the midi traffic for the common situation of identical tunings in all channels, as well as easier implementation. The advantages of multi-tunable are the ability to combine different tunings, and also a pitch glide on one keyboard won't affect the tuning of another keyboard. For software synths, the advantages of multi-tunable can be achieved with mono-tunable synths by using multiple instances of the synth. Switchable synths will respond to a special tuning message that sets the synth to either mono-tunable or multi-tunable. Switchable synths should default to the multi-tunable setting. Mono-timbral synths will obviously be mono-tunable.


Implementation:

The new method uses keyswitches for the 5 highest keys, 123-127. If middle C is C4, these are notes D#9 to G9. These keyswitches are generated by software, not played by the musician. The velocity of the keyswitches is not actually a velocity, but 1 byte of tuning information. Keyswitch F#9's velocity is actually the input note, keyswitch F9's velocity is the output note, and keyswitches E9 and D#9's velocities are the pitch bend, in the exact same format as the 2 7-bit data bytes of the standard midi pitch bend message. This makes it easier for the synth developer or designer, because he has already written code that handles physical pitch bend wheel movement, and can just reuse it to handle tuning keyswitches. Because the keyswitch bend range is fixed at 50¢, the tuning resolution is 0.0061¢. Thus 00 00 = -50¢, 40 00 = 0¢, and 7F 7F = +49.9939¢.

Each keyswitch note-on needs to have a matching note-off, to avoid being misinterpreted and possibly blocked by the DAW or other environment. To this end, a zero-velocity note-on follows immediately. To bend note nn on channel x to note mm with bend of yyzz would take up to 4 note-on messages and 4 note-off messages. In hexadecimal the midi looks like this:

F#9 note-on/note-off: 9x 7E nn 7E 00 (input note, only needs to be sent when the input note changes)

F9 note-on/note-off: 9x 7D mm 7D 00 (output note, optional)

E9 note-on/note-off: 9x 7C yy 7C 00 (coarse bend, optional)

D#9 note-on/note-off: 9x 7B zz 7B 00 (fine bend, required)

These messages are always sent in this order. Some of the "9x" bytes can be omitted via running status. If the F#9 input note keyswitch is omitted, additional output note and bend messages continue to affect the current input note, overwriting previous output note and bend messages. If no F#9 keyswitch is received, the current input note defaults to note #0. The F9 output note keyswitch is optional and would generally be omitted for 12-notes-per-octave tunings. The E9 coarse bend could be omitted for slight pitch bends that don't change the MSB of the pitch bend. The required D#9 fine bend functions as an "end of tuning message" marker, and the synth waits until receiving this keyswitch to actually apply the new tuning. The midi stream for pitch glides will be reduced to mostly fine bends, with coarse bends whenever the MSB boundary is crossed, and output note updates whenever the note boundary is crossed.

The G9 keyswitch with velocity 1 resets the tuning of all notes. On receiving this message, the synth should reset all notes on that channel back to standard tuning. To reset all notes on channel x:

G9 note-on/note-off: 9x 7F 01 7F 00 (reset all notes on channel c)

Because note-ons with velocity zero are interpreted as note-offs, a message conveying a zero value for the note or the bend must be transmitted via the G9 keyswitch, using velocities 123 through 126, like so:

G9 note-on/note-off: 9x 7F 7E 7F 00 (set input note to #0)

G9 note-on/note-off: 9x 7F 7D 7F 00 (set output note to the C five octaves below middle-C)

G9 note-on/note-off: 9x 7F 7C 7F 00 (set coarse bend to -50¢)

G9 note-on/note-off: 9x 7F 7B 7F 00 (set fine bend to 0¢)

Thus 9x 7F 7B 7F 00 replaces 9x 7B 00 7B 00, 9x 7F 7C 7F 00 replaces 9x 7C 00 7C 00, etc.

To reset an individual note nn on channel x to standard pitch (assuming nn > 0), and using running status:

F#9 note-on/note-off: 9x 7E nn 7E 00 (set input note)

F9 note-on/note-off: 7D nn 7D 00 (set output note to input note)

E9 note-on/note-off: 7C 40 7C 00 (set coarse bend to 0¢)

G9 note-on/note-off: 7F 7B 7F 00 (set fine bend to 0¢)

Note that in this last example, the G9 keyswitch with a velocity of 7B indicates "end of tuning message".

To set a switchable multi-timbral synth to mono-tunable mode or multi-tunable mode:

G9 note-on/note-off: 9x 7F 06 7F 00 (set to mono-tunable)

G9 note-on/note-off: 9x 7F 07 7F 00 (set to multi-tunable)

Kontakt Scripts

Robert Walker has written a Kontakt script that implements this method for most Kontakt instruments. The script is still in beta:

http://robertinventor.com/ftswiki/Velocity_keyswitches_retuning

The most recent version of this script uses only two keyswitch notes, with note 127 for "instructions" and note 126 for "data" which you can read about on that page. This permits the program to send additional data, for instance it supports dynamic per note stereo panning and aftertouch style volume changes. It also lets the program update the name of the tuning on the Kontakt interface and also show the pitches as ratios relative to a 1/1 in the case of just intonation retuning.

However his script still supports the version described here using notes 123 to 127 as data. You can switch between the two methods using undefined controller 119. This aspect of the spec is still under discussion.

Kite Giedraitis has also adapted that script for Alt Tuner (adaptation of the earlier version of the script with key switches 123 to 127)


The future of MTS:

It is our hope that keyswitch tuning catches on and is implemented more widely than MTS has been. However MTS retuning is already supported by all the major retuners, and there are no plans to discontinue support. The two methods will coexist for quite some time. Synths that already support MTS may want to add support for keyswitch tuning as well, in order to be tunable in sysex-unfriendly environments. If someone is using a retuner able to output both MTS sysexes and tuning keyswitches, and also using a synth able to receive both, it's advised to use only one method at a time, and to avoid mixing them.


Footnote on FL Studio sysex incompatibility, which is undocumented.

http://forum.image-line.com/viewtopic.php?p=824112

(official FL Studio forum, must register to view the full thread)

Excerpted from a July 2013 conversation with "Reflex", a site admin:

user: "The Voyager PlugSE (VST plugin) from Moog... doesn't work [in FL studio]."

Reflex: "VST plugins can send sysex out of FL, but can't receive it."

user: "Yes I guess it also receives Sysex, and so a bidirectional communication can't be established."

Reflex: "Then I don't know of any way to make it work in FL."

user: "Is it planned to add support for VST plugin to send Sysex?"

Reflex: "They already can. But they can't receive them. And that's not planned."




Older Proposed Implementations, now obsolete:

These methods do not work well with Kontakt, as it can't read closely spaced CC messages.

Undefined CC method: uses CC #119 for input note, CC #118 for output note, CC #117 for coarse bend, CC #116 for fine bend, and CC #115 for reset, mode changes, etc. Disadvantages: possible conflict with hardware keyboards that use the same CC #s. This would cause accidental mistuning of all synths that use this method.

User-selected CC method: The user decides on 5 CC #s that don't conflict with any midi hardware he/she possesses. The user inputs these 5 CC #s into the retuner. This only needs to be done onc for a given midi setup. The synth must either provide for user input or accept a few RPNs from the retuner that convey this information. The synth must default to no tuning CC #s being in use, to avoid accidental retuning. Disadvantages: greater hassle for the user, more coding for the synth developer, and sacrifice of valuable screen real estate.

RPN method: The new method uses RPNs (Registered Parameter Numbers). The technical details: There are about 16,000 possible RPN parameters, and only about a dozen are in use. We can use a block of 128 RPNs, one for each input note number, for retuning. Data MSB and LSB messages for these RPNs contain the cents to retune by, in the exact same format as the standard midi pitch bend message. The retuning is immediate (real-time), just like the standard pitch bend. This makes it easier for the synth developer or designer, because he has already written code that deals with physical pitch bend wheel movement, and can just reuse it to deal with tuning RPNs. We use another block of 128 RPNs to define the output note. The RPN LSB is again the input note number. The data MSB is the output note number, and the data LSB is not used. If this RPN MSB is 100 = 64 hexadecimal, and the first RPN MSB is 101 = 65 hexadecimal, then to bend note nn on channel c to note mm with bend of yyzz would take up to 6 midi CC (Controller Change) messages. In hexadecimal the midi looks like this:

RPN MSB: Bc 65 64 (transpose, B means CC message, 65 means set RPN parameter MSB)

RPN LSB: Bc 64 nn (input note, 64 means set RPN parameter LSB)

data MSB: Bc 06 mm (output note, optional)

RPN MSB: Bc 65 65 (set the bend)

data MSB: Bc 06 yy (coarse tune, optional)

data LSB: Bc 26 zz (fine tune, required)

These messages are always sent in this order. The RPN MSB message need only be sent once (this sentence needs updating - Ed.) (NRPN exception below). The CC/channel byte for the other 4 messages can sometimes be omitted via running status. The RPN LSB message need only be sent once per note. As per the midi spec, aditional data MSB/LSB messages continue to affect the current RPN parameter, overwriting previous data messages. This is because the highest priority in designing this new method is to make the coding as easy as possible for the synth developer or designer. By overwriting instead of summing, he doesn't have to maintain an array of current transpositions for all notes on all channels. Similarly, it's the tuning software developer's responsibility to avoid transposing out of range. Thus nn + inc must always be <= 127 and nn - dec must always be >= 0.

The data inc/dec message is optional and would generally be omitted for 12-notes-per-octave tunings. The data MSB could be omitted for slight pitch bends that don't change the MSB. The required data LSB functions as an "end of tuning message" marker and the synth waits until receiving this message to actually apply the new tuning.

A possible conflict arises with NRPNs, which use the same data inc/dec/MSB/LSB messages. The solution is for the tuning software to monitor the midi stream for NRPNs, and if any are found, take these steps: Remember the current NRPN parameter number, never omit the RPN MSB and LSB when retuning, and send a NRPN MSB/LSB message after retuning to restore the current NRPN parameter. Similar steps should be taken if one of the few RPNs already defined are encountered.

An additional RPN of 102, 0 is for resetting the tuning of all notes. On receiving this RPN, the synth should reset all notes on that channel back to standard tuning. The data MSB/LSB/inc/dec messages are not needed. To reset all notes on channel c:

RPN MSB: Bc 65 66 (note reset RPN)

RPN LSB: Bc 64 0

RPN parameters currently in use:

RPN 0,0 pitch bend range

RPN 0,1 channel fine tuning

RPN 0,2 channel coarse tuning

RPN 0,3 tuning program change

RPN 0,4 tuning bank select

RPN 0,5 modulation depth range

RPN 61,0 to 61,8 three dimensional sound controllers http://www.midi.org/techspecs/rp49public.pdf

RPN 111 used by Fractal Tune Smithy

http://robertinventor.com/software/tunesmithy/help/midi_in.htm#more_midi_in_options

RPN 127,127 null parameter (disables all 4 data entry commands)

Possible extension:

An additional RPN block. MSB = 103, would reset the pitch of a single note. The RPN LSB specifies the note. The data MSB/LSB/inc/dec messages are not needed. To reset note nn on channel c:

RPN MSB: Bc 65 67 (note reset RPN)

RPN LSB: Bc 64 nn (note to reset)