liveBook · Manning

Performance-based representation of music

As explained in Learn Generative AI with PyTorch

A music encoding that represents a piece as a sequence of performance events while preserving details such as timing and velocity.

Performance-based representation encodes music as a sequence of performance events rather than as a 4D object. It preserves note timing and playing intensity through control messages and velocity values, making musical behavior suitable for sequence modeling. section 14.1

Reduce each performance to four event types:

From performance to Transformer input

Assign every distinct event value an index, then arrange the indexes into a token sequence. Standardize sequences to 2,048 indexes, shift the window one position to create input x and output y, and batch the pairs for training a decoder-only music Transformer. section 14.2 section 14.1

!pip install pretty_midi music21

Install pretty_midi and music21 to process MIDI files before tokenization. section 14.2

How Learn Generative AI with PyTorch covers it

How deep it goes
Defines four event types and follows indexing into fixed-length training pairs, without detailing event-value encoding internals.
Examples
Uses note-on, note-off, time-shift, and velocity events, plus 2,048-index input and output sequences.
What it assumes
Assumes familiarity with musical notes and sequence modeling while introducing event tokenization from the representation level.
What you can do after
Build it from scratch by converting MIDI performances into indexed event sequences with pretty_midi and music21.
How it connects
Connects control messages, velocity, tokenization, MIDI, sequence modeling, and decoder-only Transformers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Generative AI with PyTorch. The section links point to the parts of the book it draws on.