liveBook · Manning

Musical note

As explained in Learn Generative AI with PyTorch

A musical pitch event encoded in the dataset as one of a fixed set of possible pitch values.

A musical note represents a specific sound, identified by a note name such as C or A and associated with a frequency that determines its pitch. Octaves organize pitch levels: moving up one octave doubles the frequency, while each Western-music octave contains 12 semitones. For machine learning, a pitch number compactly records both the octave and semitone; for example, C4 is 60 and F3 is 53. section 13.1.1

Digital music uses notes in several related representations:

  • A step in a sequencer contains a note; in the JSB Chorales representation, each note is one of 84 possible pitches and becomes an 84-value one-hot vector. section 13.1.2
  • A piano-roll-style music object can arrange notes across four tracks, two bars, 16 steps per bar, and 84 pitch values, producing shape (4, 2, 16, 84). section 13.1 section 13.1.2
  • A performance representation can convert notes into note-on, note-off, time-shift, and velocity events, then map those events to integer indexes for Transformer training. section 14.2.2 section 14.2

From MIDI note to event

A MIDI performance may begin with note-on events such as pitch 74 and pitch 38, followed by a note-off event for pitch 74. Processing adds time-shift and velocity events, turning the performance into a sequence of tokens rather than a raw continuous-time note stream. section 14.2.2

Figure 13.1 The relationship between musical notes, octaves, and pitches (also known as note numbers). The first column displays the 11 octaves (ranging from –1 to 9), representing different levels of musical sound. Each octave is subdivided into 12 semitones, which are listed in the top row: C, C#, D, D#, ..., B. Within each octave, each note is assigned a specific pitch number, ranging from 0 to 127, as indicated in the figure.

Use the pitch map to relate octave levels, semitones, note names, and pitch numbers from 0 through 127. section 13.1.1

How Learn Generative AI with PyTorch covers it

How deep it goes
Defines pitch, octaves, semitones, and encodings, but defers detailed MIDI-event conversion mechanics.
Examples
Uses C4, F3, A4, MIDI note-on and note-off events, JSB Chorales, and 84-value one-hot pitch vectors.
What it assumes
Assumes basic familiarity with music data while teaching note names, frequencies, octaves, semitones, and pitch numbers from fundamentals.
What you can do after
Evaluate how a note moves from musical pitch to a one-hot value or indexed event used in model training.
How it connects
Connects musical notes with pitch, octaves, semitones, MIDI, piano rolls, one-hot encoding, tokenization, and music Transformers.

Also explained in

Compare how 3 books explain musical note →

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.