liveBook · Manning

Pitch

As explained in Learn Generative AI with PyTorch

The perceived highness or lowness of a musical sound, determined here by the note’s frequency and encoded by pitch numbers.

Pitch is the perceived highness or lowness of a musical sound. A note’s frequency determines its pitch: higher frequencies sound higher, while lower frequencies sound lower. Middle C (C4) is about 262 hertz. section 13.1.1

Pitch connects note names, octaves, and semitones. Each octave contains 12 semitones, and frequency doubles between adjacent octave levels. A pitch number combines octave and semitone information into a value from 0 to 127; C4 is 60 and F3 is 53. section 13.1.1

In MIDI-style performance data, pitch is carried by note events:

  • A note_on event starts a note at a pitch value, such as 74 for D5. section 14.1.1
  • A note_off event releases a note, such as pitch 60 for C4. section 14.1.1
  • Pitch differs from velocity: pitch identifies the note’s height, while velocity represents loudness or playing force. section 14.1.1

Pitch in a performance sequence

A note_on event with value 74 starts D5, while a later note_on event with value 73 starts the neighboring pitch. These values can become note_on tokens before a music Transformer receives them. section 14.1.1

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 relationship figure to look up how octave levels, 12 semitones, note names, and pitch numbers correspond. section 13.1.1

How Learn Generative AI with PyTorch covers it

How deep it goes
Explains frequency, octaves, semitones, and 0–127 pitch numbers, then applies them to MIDI events and tokenization.
Examples
Uses C4, F3, A4, A5, D5, and numbered note_on and note_off events.
What it assumes
Builds from musical notes and frequency, introducing octaves, semitones, and pitch numbers before performance encoding.
What you can do after
Apply it via MIDI pitch values and distinguish note height from velocity when representing music for sequence models.
How it connects
Connects musical notes, frequency, octaves, semitones, MIDI, velocity, and tokenization.

Also explained in

Compare how 2 books explain pitch →

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.