Work / personal

RNN Pop Music Generation

PyTorch RNN that generates pop music as readable sheet music, using an interval-based token system that cuts vocabulary size by 80%.

Kind
personal
Status
complete
Role
solo
Period
Jan 2025 – Dec 2025
domains
generative audio symbolic-music
methods
rnn sequence-modeling tokenization
stack
python pytorch music21

Problem

Symbolic music generation usually tokenizes absolute pitch, which means the model has to learn the same melodic shape separately in every key. That inflates the vocabulary, splits the training signal across redundant tokens and wastes capacity on a transformation that is musically trivial.

Data

  • Source: POP909, 909 pop songs in MIDI, converted through an automated tokenization pipeline
  • Representation: interval-based tokens: the distance between notes rather than absolute pitch
  • Output format: generated tokens are piped back to sheet music via music21, so results are immediately readable and playable

Approach

A recurrent network over interval tokens. Instead of emitting the pitch ptp_t directly, the sequence is re-expressed as the difference between consecutive notes:

Δt=ptpt1\Delta_t = p_t - p_{t-1}

Encoding transitions rather than positions makes the representation key-invariant: a phrase transposed into a different key is the same token sequence, so every training example teaches the model about every key at once. That change alone reduced vocabulary size by 80%.

The pipeline is end-to-end automated: MIDI in, packaged training sequences out, generated sheet music at the other end.

Experiments

MetricDatasetValueBaselineDelta
vocabulary size reductionMIDI training corpus80%n/an/a

What didn’t work

Artifacts