MIDI
MIDI stands for Musical Instrument Digital Interface. It's a method for exchanging information among compatible devices and programs. Originally created on top of a serial protocol, MIDI messages are often sent entirely within a computer, either between applications or from an application to a plug-in.
MIDI Setup
Choose MIDI Setup... from the Options menu to open the MIDI Setup Window.
The MIDI Setup window provides information on the availability and status of all available MIDI inputs and outputs, and lets you perform mapping between MIDI devices and names or numbers.
Max can receive MIDI on any MIDI Input Port, and can send MIDI to any MIDI Output Port. These ports have the following properties:
- Name - The unique identifier for the port
- Abbrev - An optional, single-letter abbreviation that acts as a shorthand for the port name.
- Offset - An optional channel offset, in multiples of 16.
- On - Whether or not the port is enabled
- Map - Whether the port is available for mapping
Enabling/disabling MIDI ports
Toggle the checkbox in the On column to enable and disable MIDI port. All ports are enabled by default.
Mapping mode
The checkbox in the Map column determines whether or not the given port is available for MIDI Mapping. Mapping output is disabled by default, see MIDI Output and Mapping for more details.
Abbreviation and channel offset
Use the Abbrev and Offset columns to configure the abbrevation and channel offset for each MIDI port. To create a letter mapping for a MIDI input or output, click in the Abbrev column for the row corresponding to a MIDI input or output and choose a letter from the pop-up menu that appears. The MIDI input or output device can now be identified using the letter abbreviation you have selected.
Additionally, you can set a channel offset for each MIDI port. To create a channel offset for a MIDI input or output, click in the Offset column for the row corresponding to a MIDI input or output and choose a channel offset value from the pop-up menu that appears. The MIDI input or output device can now be identified by sending or receiving a message whose MIDI channel number falls in the range Offset Value + 15. For example, if you configure a MIDI port to have an offset of 32, then setting the channel offset of 35 on a MIDI object will address that MIDI port on channel 3.
Objects for MIDI
The simplest objects for working with MIDI are midiin and midiout, which connect to a MIDI port and route MIDI byte streams to or from those ports. The MIDI objects midiparse and midiformat convert MIDI streams to and from Max messages. MIDI objects like notein/noteout, bendin/bendout, ctlin/ctlout, polyin/polyout, and pgmin/pgmout combine the functionality of midiin/midiout and midiparse/midiformat.
Receive MIDI real-time messages with rtin. This includes MIDI start
, stop
, and tick
messages.
To work with MIDI system-exclusive messages, use sysexin to receive sysex messages and sysexformat to format them.
MIDI Ports and Devices
A MIDI Port is a named MIDI source or destination. Often, a MIDI Device, or a physical or virtual system that can send or receive MIDI, will open a single MIDI port, whose identifier is simply the name of the device. Because of this, you'll sometimes see port and device used interchangeably in MIDI object help files.
MIDI sending and receiving objects all respond to the port
message, which configures them to bind to a particular MIDI port. The name of a MIDI port can also be an abbreviation, which can be configured in the _MIDI Setup Window, or using the portabbrev
message to Max. The midiinfo object can list MIDI devices.
MPE
MPE stands for MIDI Polyphonic Expression. The MPE specification assigns each voice its own MIDI Channel, so that expression messages like pitch bend and aftertouch can be applied to indivicual notes.
The mpeparse object will format an incoming MIDI stream into MPE message events, and the corresponding mpeformat object will convert message events into an MPE-compatible midi stream. The mpeconfig object will let you configure a MPE device, for example by defining zones. Finally, the polymidiin object works in conjunction with the poly~ object, facilitating working with MPE in the context of a polyphonic subpatch.
Default Devices for MIDI Objects
If you create a MIDI output object without specifying a device name, the object transmits MIDI to the first device (the default) in the list of output devices in the MIDI Setup window.
On the Macintosh, the default MIDI output is an AudioUnit DLS synthesizer. The AU DLS synth supports its own set of internal sounds as a General MIDI bank, and also provides support for Level 2 SoundFont files.
On Windows systems, the default MIDI output is the Microsoft GS Wavetable Synthesizer. (Note: the Microsoft GS Wavetable Synthesizer does not support SoundFont files)
If you don’t assign MIDI input or output to a specific destination or port (i.e., one that does not have a MIDI device name or abbreviation as an argument) , Max will automatically merge all input devices. This is useful if you want to treat all MIDI input identically regardless of its source, But this also means that the only way for a Max patcher to determine which device is actually the source of input to these objects is to compare the incoming MIDI channel number to the MIDI channel offset specified for each device.
Configuring the Built-in MIDI Synthesizers
Max uses your machine's built-in MIDI synthesizer as its default MIDI output destination. With the OS-provided, built-in synthesizer, you can make sound without any external MIDI gear.
On Macintosh, the default MIDI output is the AudioUnit DLS (Down-Loadable-Sounds) synthesizer. The AU DLS synth supports its own set of internal sounds as a General MIDI bank, and also provides support for Level 2 SoundFont files.
On Windows systems, the default MIDI output is the Microsoft GS Wavetable Synthesizer.
On both systems, you can configure the built-in synthesizer by sending messages to Max directly.
Creating a new port for a DLS synth (Mac only)
Only one port for the built-in synth is created by default. (augraph on Mac OS X or midi_mme on Windows). However, on Mac, you can work with more than one DLS synth by creating additional MIDI synthesizer ports and assigning new DLS sound bank files to each one. This feature is not available on Windows machines.
- Use the
createoutport
message. - The name of the driver will be
augraph
on macOS. For the port name, you can use the name you want to give to your virtual output port. - For example, the message
;#SM createoutport synth2 augraph
create a second DLS synth called “synth2”.
Deleting a DLS synth port (Mac only)
- Use the
deleteoutport
message. - Again, on macOS the name of the driver will be
augraph
. The port name will be the name of the virtual port (created withcreateoutport
) that you want to delete.
Loading a bank of sounds on a DLS Synth (type 1 or 2) (macOS only)
- Use the
driver loadbank
message. - The filename should be the name of an existing DLS bank file, and the port name will be the name of the port that will use this bank. If you omit the port name, the bank you specify will be loaded by all DLS ports. On macOS, the folder
/Library/Audio/Sounds/Banks
is added to the search path when looking for a DLS bank file (i.e. it is the default location for searching for sound bank files). - If you specify a zero (0) for the filename, the default GM (General MDI) sound bank will be loaded (e.g., ;#SM driver loadbank 0 <portname>).
Turning the DLS synth reverb on and off (Mac only)
- Use the
driver reverb
message.
Setting MIDI output latency (Windows only)
- The Windows midi_mme will let you configure the output latency.
- Use the message
driver latency
. - For example, the message
;#SM driver latency 10 midi_mme
will set the driver latency to 10 milliseconds.