Piano, pared back.
Aria’s tokenizer, trimmed to piano. 2,176 tokens, including 13 control tokens for density and loudness. A much larger dataset than MAESTRO’s few million tokens.
I’m building piano music that reacts to my game. From GPT-2 on a borrowed Mac to RWKV-7 with intensity controls.
Hear where it startedA quiet room. A chase. A moment to breathe. I wanted the piano in PhantomHunt to follow what was happening.
The idea came from a friend’s project at MIT. At first, the hardware it seemed to need was completely out of scope. So I started with a smaller question: could I train a model to continue a piano passage?
That became one project, in two chapters.
I borrowed a friend’s M1 Max and trained a 12-layer GPT-2 from scratch. No English model underneath. Just piano performances, turned into musical events.
Almost 200 hours of MAESTRO competition piano.
Validation loss went up after epoch 2, so I kept the earlier checkpoint. Loss is only part of the story. I also generated continuations to hear the difference.
A continuation from the best GPT-2 checkpoint. I chose it from a wider search and shortened the long pauses.
Played on Salamander Grand Piano by Alexander Holm, CC BY 3.0. The MIDI download retains the original pauses.
A continuation is not live game music. It has to arrive on time, leave room for the game, and respond when the mood changes. v1 couldn’t do that.
87M GPT shape, 2,048-token context, on an M1 Pro. The REMI budget came from 200 MAESTRO files. The PyTorch CPU path fell short even on average.
A 94M RWKV-7 step, with int8 weights.
4.2 ms at the 99th
percentile.
Aria’s roughly three tokens per note allow about 12 ms per token in the 99th-percentile second.
RWKV-7 carries a fixed-size state from one token to the next. A GPT carries an attention cache. Moving that cache was costly; keeping it inside the model did not compile for the Neural Engine in my tests.
Speed tests used random weights, batch one, on an M1 Pro. These are model timings, not an in-game benchmark or a judgement of the music. RWKV-7 was measured on 7 October; the REMI budget and GPT CPU result on 4 October.
I came back to the original goal with a recurrent model, much more music, and controls from the start. It trains on two AMD GPUs in my desktop.
RWKV-7 parameters
Pruned Aria-MIDI tokens
Training tokens / second
Aria’s tokenizer, trimmed to piano. 2,176 tokens, including 13 control tokens for density and loudness. A much larger dataset than MAESTRO’s few million tokens.
Every five seconds, controls describe the coming music: eight density levels and five loudness levels. Dropping controls 15% of the time enables classifier-free guidance.
A Radeon RX 9060 XT and a Radeon VII. ROCm, one process per card. About 43 hours for one epoch at the measured training speed.
The planned in-game loop. Controls take effect at the next five-second segment. A rule layer can change velocity or thin notes immediately.
The game idea left an intensity editor behind: a softer, sparser phrase or a louder, denser one.
The actual experiment works on short phrases. This preview illustrates the idea; it does not run either model.
These tests helped choose the architecture and training recipe. They do not tell me whether the full model makes music I want to hear.
Validation loss at about 28M parameters each, after 250M tokens on the same data. The GPT used rotary positions.
MIDI velocity in fresh-state tests. Density landed in the requested level 69–97% of the time.
Notes per second at minute 15, with guidance strength 1. Without guidance, “dense” faded from 9 to about 5 notes/s after 10–30 minutes.
The small runs compared requested and contrasting controls, running each token step twice. The full recipe adds control dropout for classifier-free guidance. That compares controlled and unconditioned predictions; its strength still needs tuning.
Two passes at 94M would cost about 7 ms per token on the Neural Engine. That is an estimate. It has not been measured as part of the game.
The first full epoch is running, expected to finish around 9 October. The next step is to hear what it learned.
v2 samples coming after the first epoch.
One pass through the pruned Aria-MIDI dataset.
Judge the music and tune the control strength.
Core ML for Macs. ONNX for the portable runtime.
Find out whether it follows the game.
Quality depends on the prompt and checkpoint. MAESTRO is small and stylistically narrow. My random file split can put related pieces on both sides, flattering validation loss. The demo is a selected sample. The intensity editor is experimental and not a note-preserving live editor.
Continuous notes do not make long-form structure. The game needs a conductor to bring themes back and set controls. Listening tests and the full game loop are still ahead. Both versions take musical context, not text prompts.
Split MIDI files → transpose only the training split → tokenize with MidiTok REMI → train on 2,048-token windows → compare checkpoints → generate MIDI.
The public repository contains the v1 workflow. Datasets and checkpoints stay local. The v2 code is not public.
Training and generation need your own local data and checkpoint. Start with the dependency smoke check:
python3 -m pip install -r requirements-smoke.txt
python3 -m unittest tests.test_dependency_smoke
Then prepare, train, and generate:
python3 scripts/prepare_12k_split.py
python3 scripts/augment_train_transpose.py
python3 scripts/tokenize_12k_augmented.py
python3 scripts/train_gpt2_piano_12k.py --train-from-scratch
python3 scripts/generate_piano_sample.py --checkpoint checkpoints/best
Read the full README ↗
Aria-MIDI is CC BY-NC-SA, so this v2 work is for non-commercial use. MAESTRO has separate CC BY-NC-SA terms too. The repository’s MIT license covers its code, not its training data.
The v1 clip uses Salamander Grand Piano by Alexander Holm under CC BY 3.0. Long pauses in the selected continuation were shortened. Future v2 samples will also use a freely licensed piano.