Processing Raw MIDI Arrays in Max/MSP

Modular software environments like Max/MSP provide a flexible framework for intercepting, manipulating, and retransmitting MIDI data at the lowest programmatic level. By treating MIDI events as structured byte arrays or sequential numerical lists, users can bypass standard musical interface constraints to implement custom algorithmic modifications, generative routing, and non-linear data mapping. This overview outlines how raw incoming MIDI messages are parsed into accessible lists, manipulated through array-processing objects, and reconstructed for real-time performance.

Ingesting and Parsing Raw Streams

Standard MIDI communication operates via multi-byte serial streams, typically consisting of a status byte (indicating message type and channel) followed by one or two data bytes (such as pitch and velocity).

In Max/MSP, raw MIDI enters through objects like midiin or sysexin. The midiin object outputs raw, unformatted decimal bytes. To structure this continuous stream into intelligible arrays:

Array Deconstruction and List Processing

Once an incoming message is captured as a list, it can be parsed using native list-handling objects, primarily the zl object family.

Algorithmic Transformations

After decomposing raw arrays, mathematical transformations are applied to pitch, velocity, or timing vectors.

  1. Pitch Inversion and Scaling: Mathematical operators (+, -, *, %) apply matrix transformations across pitch arrays. Modulo operators (% 12) isolate pitch-class sets, enabling real-time quantization to custom microtonal or non-Western scales.
  2. Dynamic Modification: Velocity values within lists can be mapped non-linearly using objects like scale or function tables (function), converting standard linear response curves into logarithmic or inverted dynamic responses.
  3. Lookup Tables and Collections: Arrays can be stored and cross-referenced in memory structures such as coll, table, or dict. A raw input pitch array can serve as an index address that retrieves an entirely new array of harmonic or control data.

Procedural Scripting with JavaScript and Gen

For complex multi-dimensional array operations that exceed standard visual patching, Max provides procedural programming layers:

Message Reconstruction and Dispatch

Once transformations are computed, the modified arrays must be re-serialized into valid MIDI specifications to interface with hardware or digital audio workstations (DAWs).