Manual: MIDI Reference

From OpenMPT Wiki
Jump to: navigation, search


In 1982, a protocol was standardized to allow the use of commands or other digital messages to manage synthesizer data in a more-or-less universal format. It was dubbed the Musical Instrument Digital Interface, or MIDI for short. MIDI transmissions are only event messages rather than audio signals, and are designed so that synthesizers may each produce and process audio in their own way, but also allow external control through a system ideally understood by all relevant devices. Playing notes, bending their pitch, controlling panning position, and synchronizing timers between synthesizers of different makes and models were possible, all within a single set of short messages.

In the 1980s, MIDI allowed for digital composition to be done on computers or specialized electronic devices called sequencers. Sequencing used the MIDI language to make it easy to record and edit events that would control MIDI synthesizers, and even trigger it to play back audio which could be recorded to an appropriate medium. While file sizes are small and the commands can be understood by any MIDI-compatible device, the disadvantage is that a song was likely to sound different on different synthesizers, because each has its own means of producing sounds.

General MIDI, or GM, was an attempt to address this problem. It is a simple set of pre-defined “preset” instrument programs and control messages any sequencer file can use to produce a synthesizer-independent playback sound (differences in instruments' timbre across synths aside). The GM standard not only assigned specific instruments to particular program numbers, but also mapped many MIDI controllers to important synth effects and set minimums for polyphony and number of channels. GM is still in use today, and has even been expanded into different formats like Roland’s GS and Yamaha’s XG, as well as the more recent GM2 specifications present in many newer synthesizers.

Many of the synthesizer parameters that can be manipulated are done so using MIDI messages that work in each one of 16 channels, with each of those channels assigned one instrument. In effect, this means only 16 instruments can be played at a time, but Program Change messages can be used to switch instruments out for others in real-time. MIDI channel messages such as this are only a few bytes in length, which make for excellent translation speed between the event and the parameter control.

For an action as simple as playing a note on a MIDI keyboard, the following could (and in many cases does) happen:

  • The Note On message is sent, which is a data package that contains the note (within a range of 0 to 127, the range of notes on the MIDI keyboard) and key velocity, or strength at which the key was struck.
  • Aftertouch is activated (if pressure to the synth keys is held), which sends messages that may affect each key (poly pressure) or the entire keyboard (channel pressure).
  • The Note Off message is sent, which contains the key’s release velocity, or the strength at which the key was released.

Not all synthesizers pass or understand all of these parameters; the only ones that are truly universal are the note values for Note On and Note Off messages. Furthermore, many synthesizers offer ways of affecting the instrument settings as they are being processed, such as Pitch Bend and Modulation wheels, joysticks, data sliders, knobs and buttons, foot controllers and pedals, breath controllers, and ribbon controllers. All of these send their own messages using their own controller numbers, which can sometimes be assigned by the user, depending on the synth model.

MIDI Messages[edit]

The data blocks commonly referred to as MIDI Messages are sent serially in one-way paths from one MIDI device’s “MIDI Out” connector to the other device’s “MIDI In” connector (“MIDI Thru” passes on the MIDI-In signal to another device). The messages are simple but specific, often taking the form of commands that not only control various synth settings like pitch, volume, key pressure, and filters, but also change programs or banks or toggle arpeggiations or on-board effects. Many of these messages have a universal scope of application, but not all do; each company can set its own use for the MIDI controller messages, and even different devices from the same company will use the same controller assignments to manipulate different parameters.

At a basic level, there are eight types of MIDI messages:

  • Notes: MIDI has 128 notes represented, from C-1 to G9 (scientific pitch, the equivalent of C-0 to G-10 in OpenMPT’s octave range; notes above B-9 are not available), or 0 to 127. Assuming Western tuning, this is the range from 8.176 Hz to 12,544 Hz.
Sending a note value with velocity greater than 0 is considered a Note On message.
  • Key Pressure: An aftertouch message is sent when active notes are under continuous, non-static pressure.
Most keyboards still use Channel Pressure messages that apply aftertouch to the entire keyboard, while some more expensive keyboards send Poly Pressure (also called Polyphonic Aftertouch) messages from each pressed key. These two types of aftertouch are usually not found together in the same controller.
  • Pitch Bend: In OpenMPT, this is called portamento and increases or decreases the pitch of the note in 64ths of a semitone, while in MIDI, pitch bends are defined to work in a given pitch wheel range. These messages bend the synthesizer notes by a pre-defined amount of semitones up or down in one event.
There is a standardized but not universally supported way of controlling the pitch bend range through General MIDI Registered Parameter Number messages; relatively few MIDI devices understand this mechanism. In OpenMPT, you have to define the synth’s pitch bend range to properly utilize portamento effects with MIDI gear and instrument plugins.
  • Control Change: For all other instrument parameters that can be manipulated, MIDI CC messages are assigned by the manufacturer to control certain settings. While there is a standardized set of controls, there is a certain amount of flexibility by each synth maker, so do not assume that a standard CC command will control a listed parameter. Read the synthesizer’s MIDI implementation table to find out which MIDI CCs it responds to.
  • Program Change: These special messages call up another program (or patch) from the synthesizer’s current bank. Many synths also support a MIDI CC to change banks. One bank may contain up to 128 programs.
  • System: These are specialized messages such as MIDI clock ticks or Active Sense that keep inactive MIDI devices connected to each other.
  • System Exclusive (SysEx): These messages usually contain data dumps or device settings that each manufacturer defines for its devices.
This type of message is often used for transmitting entire patches or banks (e.g. for backup purposes), or synth parameters that exceed the complexity provided by Control Changes (such as tuning scale setup). Some synths also use SysEx messages instead of MIDI CCs to update their parameters.
  • Real-Time System Exclusive: These are the newer type of MIDI messages that control the interaction and communication of MIDI-compatible equipment which activate lights or other devices, usually designed for stage shows and concerts.

OpenMPT Setup[edit]

Enabling MIDI Input[edit]

Setup icon
MIDI Record icon
  1. Plug your MIDI device into your computer.
    • Unless the device has a PC-specific port (serial or USB), or your computer has a MIDI-specific input, you will probably need a special converter plug to transfer MIDI messages between the two. Check your device’s manual to make sure you have the correct connection. Many newer computer models no longer use serial ports, but some older MIDI synths provided them.
    • If you are planning to purchase a MIDI device for use with OpenMPT, it is advisable to get one with USB connections; they are generally better supported and have higher data exchange speed and reliability.
  2. Click on the Setup icon in the Main toolbar, or alternatively, select the Setup menu item from the View menu). The Setup dialog will open.
  3. Click on the MIDI tab to see the MIDI Setup page.
  4. In the “MIDI Input Device” list, make sure the correct input for your MIDI device is selected.
  5. In the Main Toolbar, select the “MIDI Record” button, depicted on the right. Check Enable MIDI recording in the MIDI Setup to have this enabled by default.
  6. Now, while editing in the Pattern Editor, keys played on your MIDI keyboard will result in the corresponding notes being placed into the pattern.

To control plugin parameters using incoming MIDI data, you can set up parameter routing from the MIDI Mapping dialog.

It's also possible to quickly switch between several MIDI input devices from the main toolbar by clicking the drop-down button next to the MIDI Record icon.

Enabling MIDI Output[edit]

The MIDI Input / Output plugin is built into OpenMPT to allow for easy MIDI routing.

This plugin is more than just an instrument plugin to send out MIDI data; as the name suggests, it can also be used to capture incoming MIDI events. While this might seem redundant at first, in some cases it has advantages over the default MIDI input:

  • Several plugin instances can be opened at once, allowing multiple MIDI inputs.
  • The incoming MIDI events are only routed to the next chained plugin.

Combining these two previous points, one can use the plugin to control another instrument plugin exclusively using the MIDI data from the MIDI plugin. Only the selected output plugin of the MIDI plugin will receive this input. MIDI events captured by this plugin can also be recorded to the pattern editor by toggling the Record MIDI Out to Pattern Editor setting in the plugin window’s Options menu.

Plugin chains can be set up with several MIDI processing plugins. For example, MIDI events captured by this plugin can be sent to an arpeggiator plugin, followed by the arpeggiated MIDI data generated by that plugin being sent to another instance of the MIDI Input / Output plugin to control external gear that has no built-in arpeggiator.

Interface of the MIDI Input / Output plugin

Here is a short tutorial on setting up the MIDI Input / Output plugin to control external MIDI:

  1. Open or create a track in the XM, IT, or MPTM format (preferably MPTM).
  2. In the Plugin section at the bottom half of the General page, make sure the current plugin is empty, and click the “Select” button next to it. The “Plugin Manager” window will open.
  3. Select the MIDI Input / Output plugin in the instruments category and click the top button, “Put in FX01” (substitute “01” with the slot number you want to place the plugin into).
  4. Click the Edit button to see its interface, shown on the right, and then click the dropdown list under “MIDI Output Device” to choose the MIDI port to route MIDI data to.
  5. OpenMPT automatically creates an instrument to control the plugin. You can then use the newly created instrument to send note data to the MIDI Input / Output plugin on a specified MIDI channel, which in turn will send it to the port where your MIDI instrument receives its data. This should play the MIDI instrument.
  6. To assign a MIDI controller to a macro for output (so that you can manipulate MIDI parameters of an external MIDI device during playback), see the section on Zxx Macros.

Note: “Output Latency” delays the MIDI output relative to OpenMPT’s own audio output latency. A default value of 0 ms sends the MIDI signals at the same time as OpenMPT’s audio output. A positive value will delay the MIDI signals (in case they can be heard too early in comparison to the other audio), while a negative value (down to the duration of OpenMPT’s own output latency) will send the MIDI signals before the other audio (to compensate for any delays induced by the MIDI port or target MIDI device).

The following MIDI messages are transmitted when “Send timing messages” is checked:

  • Start (FA)
  • Stop (FC)
  • MIDI Clock Tick (F8)