A piano roll represents music as a grid: time runs horizontally, pitch vertically, and note blocks show when notes begin and how long they last. It supports both visualization and digital processing, especially with MIDI sequencing software and DAWs. section 13.1.3 section 13.0
For computation, each note can become a pitch number and then a one-hot vector. A training example uses shape (4, 2, 16, 84): four tracks, two bars, sixteen time steps per bar, and 84 possible pitches at each step. section 13.0
The representation preserves several musical properties:
- Vertical position identifies pitch, while horizontal position identifies timing. section 13.1.3
- Block length represents note duration; quantized note output exposes successive time offsets. section 13.1.3
From MIDI notes to a piano-roll tensor
Using music21, inspect notes with their offsets and MIDI pitches, then map each pitch into the 0–83 range and encode it at its quantized time step. The resulting tensor can later be converted back into a MIDI file for playback. section 13.1
