Skip to content
Back to projects
Active

ai-piano-midi-generator

An autoregressive Transformer for generating piano MIDI with velocity, note timing, note duration, and sustain pedal control.

GitHub topics

  • Midi
  • Music
  • Python
  • Pytorch
  • Transformers
Repository
AidenCarrera/ai-piano-midi-generator
Created
July 20, 2026
AI-generated jazz piano MIDI displayed in Ableton Live.

Highlights

  • Trained a Transformer on 289 human-played jazz piano performances and more than 2.8 million tokens.
  • Models notes, timing, velocity, and sustain pedal movement to preserve musical expression.
  • Generates original performances or continues from an existing MIDI prompt.
  • Built the complete pipeline for dataset preparation, tokenization, training, evaluation, and MIDI reconstruction.
  • Includes constrained sampling, checkpoint management, training diagnostics, and visual reports.

AI Piano MIDI Generator is a generative music project I built to explore whether a Transformer could learn the structure and expression of human-played jazz piano. It generates original MIDI performances while modeling not only the notes being played, but also their timing, velocity, and sustain pedal movement.

My main goals were to preserve the expressive details of the original performances and build a reliable pipeline from raw MIDI files to generated music. The project inspects and cleans piano tracks, groups related performances to prevent data leakage, and converts each performance into sequences of musical events for training.

The decoder-only Transformer is built with Python and PyTorch and trained on 289 performances containing more than 2.8 million tokens. It uses up to 2,048 tokens of context and can generate an original performance from scratch or continue from an existing MIDI prompt. I was especially proud of building the complete system myself, including the dataset preparation, tokenization, model training, constrained sampling, and MIDI reconstruction.

The project also includes reproducible train, validation, and test splits, automated evaluation, checkpoint management, training diagnostics, and visual reports. Generated performances can be exported as standard MIDI files for playback, further editing, or use in a DAW.