liveBook · Manning

Musical event

As explained in Learn Generative AI with PyTorch

A token-like symbolic unit representing a note or control information in a music sequence used for model training and generation.

A musical event is a token-like unit that represents a note action, timing information, or playing force in a music sequence. Treating music as events lets a GPT-style Transformer predict the next event from the preceding sequence, rather than generating a complete multidimensional music object at once. section 14.0 section 14.1

A performance-based representation reduces musical notes to four event types:

  • Note-on starts a note and specifies its pitch. section 14.1
  • Note-off ends a note and tells the instrument to stop playing it. section 14.1
  • Time-shift records the amount of time between two musical events. section 14.1
  • Velocity records how forcefully or quickly a note is played; higher values produce stronger, louder sound. section 14.1

From performance to model input

A performance can be represented as a sequence such as note-on, velocity, time-shift, and note-off events. Because each event type has multiple possible values, every unique event maps to an index. The resulting index sequence becomes input for a decoder-only music Transformer, which learns to predict the next event and can later convert generated events into a playable MIDI file. section 14.1 section 14.0

This approach differs from treating music as a 4D object: it follows performance events in time, making the task resemble text generation. Temperature can then regulate the creativity of generated sequences. section 14.1 section 14.5

How Learn Generative AI with PyTorch covers it

How deep it goes
Defines four event types, explains their values and index mapping, and stops short of detailed encoding implementation.
Examples
Uses note-on, note-off, time-shift, and velocity events, then maps unique events to indexes and MIDI output.
What it assumes
Assumes familiarity with Transformer-based sequence prediction while teaching event representation and indexing explicitly.
What you can do after
Build it from scratch: convert music into event indexes and prepare sequences for a trained music Transformer.
How it connects
Connects performance-based music representation with control messages, velocity, tokenization, MIDI, and 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.