Lesson 3 of 15

Note Names

MIDI to Note Name

MIDI note 60 is "C4". But how do we compute that from the number?

The 12 Pitch Classes

Within every octave, there are 12 pitch classes:

Index: 0  1   2  3   4  5  6   7  8   9  10  11
Note:  C  C#  D  D#  E  F  F#  G  G#  A  A#  B

Computing Name and Octave

pitchClass = n % 12         → index into the names array
octave     = Math.floor(n / 12) − 1   → C4 is MIDI 60

Wait — why subtract 1? Because MIDI octave numbering starts at C−1 (MIDI 0), so C4 is in the 5th octave from zero (index 4+1 = 5, then 60/12 = 5 − 1 = 4).

Examples

MIDIPitch classOctaveName
600 (C)4C4
699 (A)4A4
720 (C)5C5
7111 (B)4B4

Your Task

Implement noteName(n) that returns the note name as a string like "C4", "A#3", etc.

Run your code to see note names printed as the scale plays.

Web Audio API loading...
Loading...
Click "Run" to execute your code.