What Is a MIDI Track Transform Script?
A MIDI track transform script is a programmable tool used within digital audio workstations (DAWs) to systematically process, filter, and alter MIDI event data in a musical sequence. This article explains the core purpose of MIDI track transform scripts and details how they inspect, parse, and manipulate polyphonic note data—such as chords and overlapping melodic lines—to automate complex musical behaviors, voice assignments, and expressive timing adjustments.
Understanding MIDI Track Transform Scripts
A MIDI track transform script is an algorithmic sequence of instructions that intercepts, analyzes, and rewrites MIDI messages either in real time or offline. Found in DAWs via tools like Apple Logic Pro’s Scripter, Cockos Reaper’s JSFX, or Steinberg Cubase’s Logical Editor, these scripts operate directly on raw event arrays.
A standard MIDI data stream contains distinct status bytes and data
bytes defining events such as Note On,
Note Off, pitch number (0–127), velocity (0–127), and
timestamp. A transform script listens for these incoming events, runs
them through user-defined mathematical or logical operations, and
outputs a modified MIDI stream to the instrument or track.
The Challenge of Polyphonic Note Data
Monophonic data consists of single notes played sequentially, making it straightforward to process. Polyphonic data, by contrast, consists of multiple distinct notes occurring simultaneously or with overlapping durations.
In a raw MIDI stream, there is no native "chord" event. A three-note
chord is simply transmitted as three independent Note On
messages with identical or near-identical timestamps. Because the MIDI
specification processes messages linearly, a transform script must
establish structural context to treat simultaneous events as a unified
polyphonic structure rather than unrelated notes.
How Transform Scripts Process and Manipulate Polyphony
To manipulate polyphonic data, a transform script employs specific computational techniques to organize, evaluate, and alter concurrent notes.
1. Temporal Windowing and Chord Aggregation
To handle human performance variations where chord notes do not land
on the exact same millisecond, scripts implement a time window (often 10
to 30 milliseconds). When the first Note On event arrives,
the script buffers incoming notes during this window. Once the window
elapses, the script groups these notes into an array representing a
single harmonic unit (a chord) before executing transformations.
2. Pitch Sorting and Voice Allocation
Once a group of polyphonic notes is collected, the script sorts the array by pitch values from lowest to highest. This allows the script to identify specific chord roles:
- Bass Isolation: The lowest note (index 0) can be duplicated or routed to an independent MIDI channel or lower octave.
- Top-Note Voicing: The highest pitch in the array can be boosted in velocity, ensuring the lead melody cuts through the accompaniment.
- Voice Splitting: Each element in the sorted array can be reassigned to separate MIDI channels, allowing a single polyphonic track to drive a multi-timbral orchestra (e.g., voice 1 to violin, voice 2 to viola, voice 3 to cello).
3. Time Manipulation (Strumming and Arpeggiation)
Polyphonic scripts frequently alter the playback timing of grouped notes to create humanization or performance effects:
- Strum Simulation: By modifying the timestamp parameter of each note in a sorted chord array, the script introduces progressive micro-delays (e.g., adding 15ms per ascending or descending note) to simulate the physical sweeping of a guitar pick.
- Algorithmic Arpeggiation: The script can break simultaneous notes apart completely, scheduling them to trigger sequentially on sub-beat divisions according to specific patterns (up, down, random, or chord-inversion orders).
4. Harmonic and Interval Transformations
Scripts can evaluate the interval relationships within a chord array and rewrite the pitch values:
- Inversions: Transposing the lowest note up an octave (adding 12 to the pitch value) or transposing upper notes down.
- Scale and Mode Snapping: Checking each note against a predefined musical scale array and quantizing out-of-key notes to the nearest valid interval.
- Chord Density Modification: Dynamically dropping specific voices (such as removing the 5th or doubling the 3rd) based on incoming velocity or external automation parameters.
5. Independent Expression and Polyphonic Velocity
Before the widespread adoption of MIDI Polyphonic Expression (MPE), standard MIDI applied control change (CC) messages globally to all notes on a single channel. Polyphonic transform scripts overcome these limitations by dynamically mapping individual notes within a chord to separate virtual channels. This enables independent pitch bends, custom velocity curves, or filter envelopes to be applied to individual voices inside a single polyphonic performance.