|top| | Midi2lua
: A pure Lua library for developers who want to write their own MIDI parsing and writing functions from scratch.
local eventType = status >> 4
MIDI is based on Ticks (Pulses Per Quarter Note). Games run on real-time seconds. A good midi2lua script will parse the meta-events (Microseconds per quarter note) and pre-calculate the absolute time in seconds for every event. midi2lua
: A VST/AU plugin that lets you write Lua scripts to process MIDI and audio in real-time within your DAW. How to Get Started Lua Scripting - MIDI FX Plug-In Scripts - Logic Pro Help : A pure Lua library for developers who
-- Helper: Read 16/32-bit Big Endian local function read16() local b1, b2 = file:read(2):byte(1,2); return (b1 << 8) | b2 end local function read32() local b1, b2, b3, b4 = file:read(4):byte(1,2,3,4); return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4 end A good midi2lua script will parse the meta-events
If existing tools don't fit your Lua dialect (e.g., you need vs Lua tables, or you need GMod specific syntax), writing your own midi2lua is surprisingly simple using the mido library.
name = "Drums", notes = time = 0.000, channel = 9, pitch = 36, velocity = 100 , -- Kick time = 0.500, channel = 9, pitch = 38, velocity = 90 , -- Snare time = 1.000, channel = 9, pitch = 36, velocity = 100 , -- Kick time = 1.500, channel = 9, pitch = 38, velocity = 95 , -- Snare