Class: PitchClass

PitchClass

A PitchClass represents a set of all pitches that are octaves apart from each other. A PitchClass and an octave number defines a Pitch.

A PitchClass has a value and a name. PitchClasses operate in a "mod 12" modular arithmetic space, where 0, 12, 24, 36, etc are considered equal. The canonical PitchClass values are [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

The basic PitchClass names are "C", "D", "E", "F", "G", "A", "B". You can construct a PitchClass using a basic name, optionally followed by sharps "#" or flats "b". Sharps and flats increment or decrement the value respectively. See examples below.

Constructor

new PitchClass(nameOrValue)

Parameters:
Name Type Description
nameOrValue number | string

a PitchClass numerical value or string name.

Source:
See:
Example
// Constructing by name
new PitchClass('C')
new PitchClass('Db') // same as PitchClass('C#')
new PitchClass('D')  // Same as PitchClass('C##') or PitchClass('Ebb')
new PitchClass('Db') // same as PitchClass('D#')
new PitchClass('E')
new PitchClass('F')
new PitchClass('Gb')
new PitchClass('G')
new PitchClass('Ab')
new PitchClass('A')
new PitchClass('Bb')
new PitchClass('B')

// Constructing by value
new PitchClass(0) // same as PitchClass('C') or PitchClass(12)
new PitchClass(1) // same as PitchClass('Db')
...
new PitchClass(11) // same as PitchClass('B')

Members

(static) NAMES

The canonical names of all pitch classes, indexed by their value. Note that some names have aliases. For example: "C#" is equivalent to "Db", and "Fbb" is equivalent to "Eb"

Source:

(readonly) name :PitchClass

The canonical name of this PitchClass. See PitchClass.NAMES

Type:
Source:

(readonly) value :Number

The number of semitones above C. Used to compute MIDI pitch values. This is always the canonical value in the range 0-11 (inclusive). Assigning this property will convert to the equivalent canonical value.

Type:
  • Number
Source: