Midi2lua
midi2lua: A methodical guide
Overview
- Read MIDI file header to get format, number of tracks, and division (TPQN).
- For each track: iterate delta-time + events. Maintain absolute tick position by summing delta-times.
- Handle running status (reuse previous status byte when omitted).
- Convert meta events (especially Set Tempo) and sysex appropriately.
- Maintain current tempo map (list of tempo change events with tick position and microseconds per quarter-note).
- Convert absolute ticks to seconds using the active tempo for each tick span. If tempo changes occur between ticks, split conversion at tempo boundaries.
- Emit Lua event tables, choosing whether to output Note On/Off pairs as single note events with duration or keep as separate on/off events.
8.3 Time Signature Awareness
Incorporate metrical structure for loop points or measure‑based callbacks. midi2lua
Find a Converter: Tools like the MIDI2LUA web converter allow you to upload a .mid file and receive a Lua script output. midi2lua: A methodical guide
Overview
Features
LuaMidi Library (GitHub): A pure Lua library for reading and writing MIDI files. It provides an abstraction of MIDI data (NoteOn/NoteOff) into human-readable Lua objects. Read MIDI file header to get format, number
Learn about the technical side of reading and writing MIDI files with the LuaMidi library on GitHub
3. Input → Output Transformation
Input (MIDI file)
- Tracks, channels, notes, velocities, timestamps (ticks).
- Tempo changes, time signatures, controller events (CC), pitch bend.
If you want, I can: