feat(midi): import Standard MIDI Files with transactional undo (phase 104)

This commit is contained in:
Johannes Findeisen 2026-11-06 02:28:25 +01:00
commit f37ad8987a
9 changed files with 234 additions and 5 deletions

View file

@ -60,3 +60,25 @@ are cropped and notes outside the trim are omitted. Trailing silence remains.
Export does not edit the project or undo history. Audio clips reject. Only note
messages are exported: instruments, opaque plugin data, controller maps,
automation and audio are excluded. Export is unavailable during recording.
## Import MIDI files
File → Import MIDI (also in the sequencer Create menu) adds a clip at the cursor
on the selected non-bus track, or creates a track when none is selected. Import
is one undoable prepared edit; malformed files, capacity errors and failed
backend preparation retain the old project and IDs.
The reader supports Standard MIDI File types 0 and 1 with PPQN timing, including
running status and velocity-zero note-offs. File tracks merge into one clip;
channels and velocities remain. Timing rounds to 960 ticks per quarter note,
with positive sub-tick notes given one tick. Trailing silence remains. The project
tempo is retained: tempo maps, time signatures, CC/sustain, program changes,
pitch bend, SysEx and other metadata are not imported. This is a notes workflow,
not full-song or instrument reconstruction.
Limits are 1 MiB per file, 64 file tracks, 65,536 parsed events and 4,096 notes
within the project's total note capacity. SMPTE timing and type 2 reject explicitly.
Unterminated notes, zero source duration and malformed events reject rather than
silently dropping notes. Unmatched note-offs are harmless and ignored. Overlapping
same-pitch notes pair FIFO within each file track/channel. Project save/reload
uses the existing format; no format migration or extra dependency is required.