Media midi

From damionrashford/media-os · View interactive version

Media midi is an AI agent skill from the GitHub repository damionrashford/media-os. MIDI 1.0 and 2.0 wire protocol, control surfaces, and SMF file authoring: sendmidi/receivemidi (macOS/Linux/Windows), ALSA amidi/aconnect/aplaymidi/arecordmidi/aseqdump (Linux), mido and python-rtmidi (cross-platform Python), SMF chunks (MThd/MTrk with VLQ delta times), Universal MIDI Packet (UMP) g

How to use this skill

Skill file

Media MIDI

Context: $ARGUMENTS

Wire-level MIDI 1.0 + 2.0, Standard MIDI Files (SMF), and control-surface plumbing. Not a DAW — for sequencing use a DAW; this skill is the CLI layer under it.

Quick start

When to use

Step 1 — Detect ports

midictl.py list-ports probes the platform and shells out to the appropriate tool:

uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py list-ports

Install tools (macOS/Linux/Windows cross-platform): brew install gbevin/tools/sendmidi (also installs receivemidi).

Step 2 — Send messages

# Note on/off at channel 1 (1-indexed in CLI, 0x90/0x80 on wire)
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send note-on \
    --port "IAC Driver Bus 1" --channel 1 --note 60 --velocity 100
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send note-off \
    --port "IAC Driver Bus 1" --channel 1 --note 60

# Continuous controller
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send cc \
    --port "IAC Driver Bus 1" --channel 1 --cc 74 --value 64

# Program change
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send program \
    --port "IAC Driver Bus 1" --channel 1 --program 42

# System Exclusive
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send sysex \
    --port "IAC Driver Bus 1" --hex 'F0 7E 7F 06 01 F7'  # Identity request

Step 3 — Monitor

uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py dump --port "MyController"
# or on Linux specifically via aseqdump
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py monitor --port 24:0

Step 4 — SMF files

# Parse .mid to human-readable events + JSON
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py smf-dump song.mid --format json

# Author .mid from a JSON event list
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py smf-write \
    --json events.json --out song.mid --ppq 480 --format 1

Input JSON schema (each entry = {delta_ticks, type, channel, data1, data2, [meta: name, tempo, time_sig, ...]}).

Gotchas

Examples

Example 1 — Trigger a C-major chord

for n in 60 64 67; do
    uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send note-on \
        --port "IAC Driver Bus 1" --channel 1 --note $n --velocity 100
done
sleep 1
for n in 60 64 67; do
    uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send note-off \
        --port "IAC Driver Bus 1" --channel 1 --note $n
done

Example 2 — Identity request (universal sysex)

uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py send sysex \
    --port "MyController" --hex 'F0 7E 7F 06 01 F7'

Example 3 — Dump events from a .mid

uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py smf-dump song.mid

Example 4 — Build a tiny SMF

cat > events.json <<'JSON'
[
  {"delta": 0, "type": "tempo", "bpm": 120},
  {"delta": 0, "type": "note-on", "channel": 1, "note": 60, "velocity": 100},
  {"delta": 480, "type": "note-off", "channel": 1, "note": 60}
]
JSON
uv run ${CLAUDE_SKILL_DIR}/scripts/midictl.py smf-write --json events.json --out c.mid

Reference docs

Troubleshooting

`port "X" not found`

Cause: Port name typo, IAC disabled (macOS), or ALSA sequencer subsystem not loaded.

Solution: Run list-ports to see the canonical names. On macOS enable IAC in Audio MIDI Setup. On Linux ensure snd-seq module is loaded.

Notes hang (never stop)

Cause: Missed note-off. Happens with aborted scripts.

Solution: Send CC 123 (All Notes Off) to the channel or power-cycle the synth.

`sendmidi` not found

Cause: Not installed.

Solution: brew install gbevin/tools/sendmidi. Helper falls back to ALSA amidi / Python mido/rtmidi if any is available.

Parser errors on SMF

Cause: Malformed VLQ or missing F7 terminator in an embedded sysex.

Solution: Inspect the file with od -c or xxd; compare against spec in references/.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.