How craftycode121/musicgeneration works
MIDI Generator is a CLI-driven autoregressive piano-music system: it obtains and parses MAESTRO MIDI, trains a Transformer+CfC model to predict pitch, velocity, and duration, generates events from a seed, and exports them as MIDI and optionally WAV. It also supports checkpoint reuse and loss/audio analysis. The README documents data download and parsing modules that are absent from the supplied tree; their node is therefore left without a source path. The sampled files establish the main orchestration and model/training/export details.
Main entry points: main.py Pipeline CLI · train.py Training loop · export.py MIDI and WAV export · loss.py Loss and optimizer
Components 16
CLI Workflow
- Pipeline CLI
main.py - MAESTRO ingest
Model and Training
- Parameter init
src/model/params.py - Windowed dataset
src/training/dataset.py - Training loop
src/training/train.py - Loss and optimizer
src/training/loss.py - Transformer + CfC
src/model/forward.py
Generation and Output
- Checkpoint I/O
src/checkpoint.py - Event generation
src/generate.py - MIDI and WAV export
src/export.py
Analysis
- Generated WAV
- Audio analysis
src/analysis/audio_analysis.py - Loss plots
src/analysis/loss_curves.py
Other components
- CLI user
- fluidsynth
- Local audio player
Connections 19
- CLI user → Pipeline CLI: chooses stage
- Pipeline CLI → MAESTRO ingest: downloads and parses
- Pipeline CLI → Windowed dataset: builds windows
- Pipeline CLI → Parameter init: initializes
- Pipeline CLI → Training loop: starts training
- Training loop → Windowed dataset: batches data
- Training loop → Loss and optimizer: updates and evaluates
- Loss and optimizer → Transformer + CfC: computes predictions
- Training loop → Pipeline CLI: returns best params and history
- Pipeline CLI → Checkpoint I/O: saves or loads
- Pipeline CLI → Loss plots: plots history
- Pipeline CLI → Event generation: generates from seed
- Event generation → Transformer + CfC: predicts next event
- Pipeline CLI → MIDI and WAV export: exports events
- MIDI and WAV export → fluidsynth: renders MIDI
- MIDI and WAV export → Generated WAV: writes WAV
- Pipeline CLI → Audio analysis: analyzes WAV
- Generated WAV → Audio analysis: reads samples
- Pipeline CLI → Local audio player: requests playback