import_midi
Convert MIDI files into playable Strudel patterns. Supports drum and pitched tracks with chord merging and sample lane separation.
Instructions
Convert a .mid file into a playable Strudel pattern (Phase 1: literal transcription, #201). Use source="base64" with data= for inline bytes, or source="path" with data= to read from the patterns/midi/ directory (path traversal blocked). Drum tracks (MIDI channel 10) emit one s() lane per sample so simultaneous kicks/hats do not collide. Pitched tracks emit note("...").s("piano") with simultaneous notes merged into [a,b,c] chord tokens. Phase 2+ (structural compression, voice separation, LLM idiomatic pass) tracked in separate issues. Example: import_midi({ source: "path", data: "drumloop.mid", steps_per_cycle: 16 }). For the reverse direction (Strudel → MIDI) use the analyze tool with task="export_midi".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | How to interpret `data` — raw base64 bytes or a filename under patterns/midi/ | |
| data | Yes | For source=base64: base64-encoded .mid bytes (≤1MB decoded). For source=path: basename of a .mid file under ./patterns/midi/ (path-traversal blocked). | |
| steps_per_cycle | No | Grid resolution per bar (integer 1-64). Default 16. | |
| bars | No | Cap on bars to emit. Default: full file. | |
| drum_map | No | Optional override / extension to the default GM percussion map. Keys are MIDI note numbers (as strings, since JSON object keys), values are Strudel sample names. Example: { "60": "cp", "61": "rim" }. Unmapped drums fall back to rests and are surfaced in the result summary. |