Pitch and Pitch Class

In this module, we’ll find the pitch class for each pitch of a melody.

In post-tonal music, we draw a distinction between pitch and pitch class. Pitch refers to a specific note in a specific range. Pitch class refers to a class of notes that share the same name, plus enharmonic equivalents. A good analogy is that pitch refers to one of the 88 keys on a piano keyboard, while pitch class refers to all verisons of that same key, in all octaves.

There are twelve notes to the octave, and therefore twelve pitch classes (the classes start over with each octave). Pitch classes are numbered 0 to 11, by convention. Pitch class 0 is equivalent to C (or B-sharp), pitch class 1 is equivalent to C-sharp (or D-flat, or B-double-sharp), and so on.

If we represent pitches as numbers, we can use a simple mathematical operation to convert from pitch to pitch class. (Check out this module if you’re not sure how to convert your melody into MIDI note numbers.)

Middle C on the piano can be represented as the number 60. The pitch class of middle C is 0. The same is true of any C anywhere on the piano: C3 (48), C5 (72), C2 (36), etc. They all have the same pitch class because they all have the same name.

The mathematical operation we use to convert pitches to pitch classes is called modulo. (See this module on basic math in Python.) The modulo operation gives the remainder of a division. Since there are twelve pitch classes, we divide the MIDI note number by 12. But instead of using the division symbol (/), we use the modulo symbol (%):

60 % 12
> 0

If we try a different C, like C3 or C5, we get the same result:

48 % 12
> 0

72 % 12
> 0

Now let’s try a note that’s not a C. If we take C#4, for example, we get pitch class 1:

61 % 12
> 1

You can try this with any note. Now let’s turn to a real-life melody from Alban Berg’s Violin Concerto (1935), a staple of the post-tonal repertoire. The melody in question is the violin’s statement at rehearsal 16 from 1:16-1:30 in the video below:

The melody would be represented in MIDI note numbers like this:

melody = [55, 58, 62, 66, 69, 72, 76, 80, 83, 85, 87, 89, 64, 63]

If we wanted to print the pitch class for each pitch in the melody in sequence, we might use a for loop:

for x in melody:
 x = x % 12

It’s often more readable and convenient to generate a list of results, rather than simply printing them. To generate a new list of pitch classes, we can use a list comprehension:

pitch_classes = [x % 12 for x in melody]

> [7, 10, 2, 6, 9, 0, 4, 8, 11, 1, 3, 5, 4, 3]


  1. Do any of the pitch classes repeat? If so, which ones? And where?
  2. What information would we be collecting if we used the / (division) operator instead of the % (modulo) operator?
  3. How does the interval between each note compare when talking about pitches or pitch classes?

Further Reading

For a more detailed look at this topic, see the Open Music Theory entry.