Midi2lua !new! ❲Edge❳
: Frequently used to intercept raw input from secondary keyboards and MIDI devices to trigger system-level Lua automations.
: These do not contain raw audio data. Instead, they function as a digital sheet music packet, logging sequential events like Note On , Note Off , Velocity (how hard a key is pressed), Pitch Bend , and Control Change (CC) automation.
A basic implementation involves reading a .mid file, parsing it, and iterating through the resulting note data:
The script generates a distributed playback system: multiple “server” computers control a pipe organ built using the Create mod, with three sets of pipes covering different octave ranges. A master controller downloads the generated Lua scripts onto each sub-controller, waits for them to initialize, then plays the entire piece of music. The system automatically clamps notes to the playable range and intelligently distributes them across the available pipes, handling tricky cases like tied notes by choosing the appropriate octave based on melodic context. midi2lua
A typical midi2lua translation turns complex binary streams into an explicit, editable Lua object array, similar to this structure:
: One of the largest pure Lua libraries for reading and writing MIDI files, featuring a friendly API. It is available through both GitHub and LuaRocks, and is often used for generative composition and DAW scripting.
This utility serves as a bridge between digital music composition and programmatic environments. Developers and game modders use it to automate virtual instruments, orchestrate in-game automation, and parse complex note data within lightweight runtime environments. : Frequently used to intercept raw input from
-- Note On with velocity 0 acts as Note Off if eventType == 0x9 and velocity > 0 then table.insert(eventList, type = "on", tick = currentTick, pitch = pitch, velocity = velocity ) else table.insert(eventList, type = "off", tick = currentTick, pitch = pitch ) end
A standard MIDI Control Change (CC) message consists of three bytes:
At its core, is a parser and converter. It takes a binary Standard MIDI File ( .mid ) and translates it into a human-readable (and machine-executable) Lua table. A basic implementation involves reading a
For Linux audio integration, MIDI.lua offers basic MIDI file handling while midialsa.lua provides a Lua interface to the ALSA sequencer library. These modules translate between Lua data structures and ALSA’s event format, enabling real-time MIDI processing on Linux systems.
Depending on your project, different libraries and tools provide the bridge between MIDI data and Lua code: