Rebuild as a code-first MIDI composition toolkit

Replaces the April wreckage (fifteen 70-byte 'working' MIDIs, archived)
with a proper pipeline:

- lib/midikit.py: stdlib-only SMF format-1 writer + reader/verifier
- lib/songkit.py: composition helpers (bar-grid score DSL with a 4/4
  bar linter, OPL arps, driving bass, vibrato, drum patterns)
- tunes/: three original tunes - DOS adventure theme (Dm/132),
  N64 ambient (G/72), chiptune racing (Em/152) - all with LOOP_START/
  LOOP_END markers for game engines
- tools/build_all.sh + tools/check_wav.py: generate, verify, render
  via timidity+FluidR3, fail on clipping/dead air
- tests/smoke_test.py: round-trip verified against mido

All three tunes render clean: no clipping, no dead air, durations
match, chromaticism audited against the chord chart.
This commit is contained in:
Hermes Agent committed 2026-10-17 00:00:20 +00:00
1 parent 7ddabaff2a
commit 95480abdab
31 files changed
+1222 -31

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# build_all.sh — regenerate every tune, verify the MIDI, render WAVs,
# and run audio sanity checks. One command, from repo root:
#
# ./tools/build_all.sh
#
# Requires: timidity (with a GM soundfont, e.g. FluidR3_GM.sf2).
# WAVs land in build/ (gitignored); MIDI files land in midi/.
set -euo pipefail
cd "$(dirname "$0")/.."
mkdir -p midi build
for t in tunes/*.py; do
echo "== $t"
python3 "$t"
done
echo "== verifying MIDI"
python3 - <<'EOF'
import sys, glob
sys.path.insert(0, "lib")
from midikit import verify
for f in sorted(glob.glob("midi/*.mid")):
d = verify(f)
print(" %-40s %6.1fs %4d notes %d tracks" %
(f, d["duration_sec"], sum(len(t["notes"]) for t in d["tracks"]),
len(d["tracks"])))
EOF
echo "== rendering WAV (timidity)"
for f in midi/*.mid; do
out="build/$(basename "${f%.mid}").wav"
timidity -Ow -s 44 "$f" -o "$out" 2>/dev/null
python3 tools/check_wav.py "$out"
done
echo "ALL OK"