Files
soundcraft/crates/midi
Zinadin Zidan 2688ccac88 io: import a MIDI file with stray bytes after its last track (#1528) (#1540)
* io: import a MIDI file with stray bytes after its last track (#1528)

Importing a MIDI file read it with craft-midi's strict read_smf, which
refuses any damage. The file in #1528 is whole, its one track ending with
End of Track at its declared length, but two line feeds follow it. The
strict reader took them for the start of another chunk and refused the
file with "unexpected end of data at byte 45281".

Read imported files with read_smf_lenient instead, as other MIDI readers
do: it reads a sound file exactly as read_smf does, ignores bytes after
the last chunk, and keeps what makes sense of a damaged track, bounded by
the same event and track limits. Its warnings are logged. Something that
is not a Standard MIDI File is still refused, and the file is still read
in full before the session changes (#911).

Test: a complete file followed by two line feeds imports its note; it
failed with the issue's error before.

* io: a MIDI file past the reader's limits stays refused (#1528)

Read leniently, a file with more events or tracks than craft-midi reads
kept what came before the limit and left the rest out with only a log
warning, where the strict reader refused it. Import now reads a file
strictly first: a sound file reads as before, a file past the event or
track limit is refused as before, and only other damage (stray bytes
after the last track) falls back to the lenient reader.

Test: a file one track past the limit, its last track holding a note and
stray bytes after it, is refused and leaves the session empty.

* io: refuse a MIDI file past the event limit after a damaged track (#1528)

The strict reader stops at the first damage. When a damaged track came
before the one that goes past MAX_EVENTS, the strict error was not a
limit error, the import fell back to the lenient read, and that read
kept what came before the limit and left the rest out with a warning:
the file was imported cut short.

The lenient read now says when a limit left part of the file out
(LenientRead::over_limit, storytold/craft-libs#1308), and the import
refuses such a file before the session changes, warnings full or not.

The six craft-libs crates pinned at 6a86adb move together to that PR's
commit, as craft-scraft-format uses craft-midi's and craft-audio's
types. They move to its merge commit once it merges.

* deps: keep only the craft-libs source changes in Cargo.lock (#1528)

Moving the craft-libs pins also re-resolved several windows-sys edges
(0.61.2 to 0.52.0) and tempfile's getrandom edge (0.4.3 to 0.3.4).
Restore main's resolution for those, so the lockfile only changes the
source of the craft-libs crates.

* deps: pin craft-libs to the merge of craft-libs#1308 (#1528)

Move the six craft-libs crates from the PR's commit 4db60c4 to its merge
into craft-libs main, 45a8e16. None of these crates, nor craft-zip which
craft-scraft-format uses, changed between the two.
2026-11-14 15:55:41 +01:00
..