Pitch Reference

This document describes how pitches are represented in MuseScore, including MIDI pitch values and Tonal Pitch Class (TPC) values.

Source Files

  • docs/pitch.md
  • docs/tpc.md

MIDI Pitch Values

Note pitches are internally expressed with their respective MIDI pitch values (0-127). This corresponds to the absolute height of the note, regardless of enharmonic spelling.

Pitch Table by Octave

NoteOct -1Oct 0Oct 1Oct 2Oct 3Oct 4Oct 5Oct 6Oct 7Oct 8Oct 9
C01224364860728496108120
C#11325374961738597109121
D21426385062748698110122
D#31527395163758799111123
E416284052647688100112124
F517294153657789101113125
F#618304254667890102114126
G719314355677991103115127
G#820324456688092104116--
A921334557698193105117--
A#1022344658708294106118--
B1123354759718395107119--

Note: Middle C (C4) = 60

Common Reference Pitches

DescriptionPitch
Middle C (C4)60
Concert A (A4)69
Lowest piano note (A0)21
Highest piano note (C8)108
Bass clef middle line (D3)50
Treble clef middle line (B4)71

Pitch Calculation Formula

// Calculate pitch from note name and octave function pitchFromNote(noteName, octave) { var noteOffsets = { 'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11 }; return (octave + 1) * 12 + noteOffsets[noteName.toUpperCase()]; } // Examples: pitchFromNote('C', 4); // 60 (Middle C) pitchFromNote('A', 4); // 69 (Concert A) pitchFromNote('G', 3); // 55 // Convert pitch to note name function noteFromPitch(pitch) { var noteNames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']; var octave = Math.floor(pitch / 12) - 1; var noteName = noteNames[pitch % 12]; return noteName + octave; } // Examples: noteFromPitch(60); // "C4" noteFromPitch(69); // "A4"

Tonal Pitch Class (TPC)

The TPC differentiates between notes with the same MIDI pitch but different enharmonic spellings (e.g., C# vs Db).

TPC Values by Note Name

TPCNoteTPCNoteTPCNoteTPCNoteTPCNote
-1Fbb6Fb13F20F#27F##
0Cbb7Cb14C21C#28C##
1Gbb8Gb15G22G#29G##
2Dbb9Db16D23D#30D##
3Abb10Ab17A24A#31A##
4Ebb11Eb18E25E#32E##
5Bbb12Bb19B26B#33B##

TPC Pattern

The TPC follows the circle of fifths pattern:

  • Natural notes: 13-19 (F, C, G, D, A, E, B)
  • Single flat: 6-12 (Fb, Cb, Gb, Db, Ab, Eb, Bb)
  • Double flat: -1 to 5 (Fbb, Cbb, Gbb, Dbb, Abb, Ebb, Bbb)
  • Single sharp: 20-26 (F#, C#, G#, D#, A#, E#, B#)
  • Double sharp: 27-33 (F##, C##, G##, D##, A##, E##, B##)

TPC and Pitch Relationship

PitchTPC Options
11 (B/Cb)19 (B), 7 (Cb), 31 (A##)
10 (A#/Bb)24 (A#), 12 (Bb), 0 (Cbb)
9 (A)17 (A), 29 (G##), 5 (Bbb)
8 (G#/Ab)22 (G#), 10 (Ab)
7 (G)15 (G), 27 (F##), 3 (Abb)
6 (F#/Gb)20 (F#), 8 (Gb), 32 (E##)
5 (F/E#)13 (F), 25 (E#), 1 (Gbb)
4 (E/Fb)18 (E), 6 (Fb), 30 (D##)
3 (D#/Eb)23 (D#), 11 (Eb), -1 (Fbb)
2 (D)16 (D), 28 (C##), 4 (Ebb)
1 (C#/Db)21 (C#), 9 (Db), 33 (B##)
0 (C/B#)14 (C), 26 (B#), 2 (Dbb)

Working with TPC

// Access note TPC var note = cursor.element.notes[0]; console.log("TPC: " + note.tpc); console.log("TPC1 (concert): " + note.tpc1); console.log("TPC2 (transposing): " + note.tpc2); // Common TPC values for reference var TPC = { // Natural notes C: 14, D: 16, E: 18, F: 13, G: 15, A: 17, B: 19, // Single sharps Cs: 21, Ds: 23, Es: 25, Fs: 20, Gs: 22, As: 24, Bs: 26, // Single flats Cb: 7, Db: 9, Eb: 11, Fb: 6, Gb: 8, Ab: 10, Bb: 12 };

Note Properties

When working with notes, these properties are available:

var note = cursor.element.notes[0]; // Read properties var pitch = note.pitch; // MIDI pitch (0-127) var tpc = note.tpc; // Tonal pitch class var tpc1 = note.tpc1; // TPC in concert pitch var tpc2 = note.tpc2; // TPC in transposing pitch // Modify properties curScore.startCmd("Change Pitch"); note.pitch = 62; // Change to D note.tpc1 = 16; // Set TPC to D natural note.tpc2 = 16; // Same for transposing curScore.endCmd();

Key Signature Values

Key signatures use the number of accidentals:

  • Negative values = flats
  • Zero = C major / A minor
  • Positive values = sharps
Key SignatureValue
C major / A minor0
G major / E minor1
D major / B minor2
A major / F# minor3
E major / C# minor4
B major / G# minor5
F# major / D# minor6
C# major / A# minor7
F major / D minor-1
Bb major / G minor-2
Eb major / C minor-3
Ab major / F minor-4
Db major / Bb minor-5
Gb major / Eb minor-6
Cb major / Ab minor-7
// Get key signature var keySig = cursor.keySignature; // Number of sharps/flats // Key signature names var keyNames = { '-7': 'Cb major', '-6': 'Gb major', '-5': 'Db major', '-4': 'Ab major', '-3': 'Eb major', '-2': 'Bb major', '-1': 'F major', '0': 'C major', '1': 'G major', '2': 'D major', '3': 'A major', '4': 'E major', '5': 'B major', '6': 'F# major', '7': 'C# major' };

Example: Transposing Notes

function transposeSelection(semitones) { var selection = curScore.selection; if (!selection) return; curScore.startCmd("Transpose"); var elements = selection.elements; for (var i = 0; i < elements.length; i++) { var el = elements[i]; if (el.type == Element.NOTE) { el.pitch += semitones; // Note: TPC may need adjustment for proper spelling } } curScore.endCmd(); } // Transpose up a perfect fifth (7 semitones) transposeSelection(7); // Transpose down an octave (12 semitones) transposeSelection(-12);

Example: Building Chords by Pitch

// Build a major chord from root pitch function addMajorChord(cursor, rootPitch) { curScore.startCmd("Add Major Chord"); cursor.addNote(rootPitch, false); // Root cursor.addNote(rootPitch + 4, true); // Major 3rd (+4 semitones) cursor.addNote(rootPitch + 7, true); // Perfect 5th (+7 semitones) curScore.endCmd(); } // Build a minor chord function addMinorChord(cursor, rootPitch) { curScore.startCmd("Add Minor Chord"); cursor.addNote(rootPitch, false); // Root cursor.addNote(rootPitch + 3, true); // Minor 3rd (+3 semitones) cursor.addNote(rootPitch + 7, true); // Perfect 5th (+7 semitones) curScore.endCmd(); } // Build a dominant 7th chord function addDom7Chord(cursor, rootPitch) { curScore.startCmd("Add Dom7 Chord"); cursor.addNote(rootPitch, false); // Root cursor.addNote(rootPitch + 4, true); // Major 3rd cursor.addNote(rootPitch + 7, true); // Perfect 5th cursor.addNote(rootPitch + 10, true); // Minor 7th (+10 semitones) curScore.endCmd(); } // Usage addMajorChord(cursor, 60); // C major chord addMinorChord(cursor, 69); // A minor chord addDom7Chord(cursor, 55); // G7 chord