MCC
Loading...
Searching...
No Matches

Written pitch primitives: letters, accidentals, note names and pitches. More...

Collaboration diagram for Pitch:

Classes

class  MCC::Accidental
 Chromatic alteration of a letter, from -4 (quadruple flat) to +4 (quadruple sharp). More...
class  MCC::PitchClass
 Pitch class 0-11 with spelling discarded (C = 0). More...
class  MCC::ChromaticIndex
 Absolute semitone position of a pitch, with origin C-1 = 0. More...
class  MCC::Pitch
 Written absolute pitch: a note name plus an octave. More...
class  MCC::NoteName
 Written note name: a letter plus an accidental, without octave. More...

Enumerations

enum class  MCC::Letter : uint8_t {
  C = 0 , D = 1 , E = 2 , F = 3 ,
  G = 4 , A = 5 , B = 6
}
 Diatonic letter name. More...

Functions

constexpr uint8_t MCC::DiatonicIndex (Letter letter) noexcept
 Returns the diatonic index of letter: C = 0 ... B = 6.
MCC_CONSTEXPR14 uint8_t MCC::NaturalSemitone (Letter letter) noexcept
 Returns the semitone offset of the natural letter above C: 0 2 4 5 7 9 11 (SPEC-ORD-1).
constexpr Letter MCC::MoveLetter (Letter letter, int32_t steps) noexcept
 Moves letter by steps diatonic letters, wrapping around the octave: MoveLetter(Letter::B, 1) == Letter::C.
constexpr bool MCC::IsEnharmonic (Pitch a, Pitch b) noexcept
 Returns true when a and b are valid and have the same chromatic index (SPEC-EQ-2): B#3 and C4 are enharmonic, B#3 and C3 are not. Any invalid operand yields false (SPEC-ERR-6).
MCC_CONSTEXPR14 bool MCC::IsLowerThan (Pitch a, Pitch b) noexcept
 Pitch-height order (SPEC-ORD-6): true when a sounds lower than b, with enharmonic ties broken by written order so that sorting is deterministic. The invalid pitch sorts last.
constexpr bool MCC::IsEnharmonic (NoteName a, NoteName b) noexcept
 Returns true when a and b are valid and share a pitch class (SPEC-EQ-2). IsEnharmonic(C#, Db) is true; any invalid operand yields false (SPEC-ERR-6).

Variables

constexpr uint8_t MCC::LetterCount = 7
 Number of diatonic letters.

Detailed Description

Written pitch primitives: letters, accidentals, note names and pitches.

MCC::Letter + MCC::Accidental form a MCC::NoteName, which keeps its written spelling, and a note name plus an octave forms a MCC::Pitch (middle C is C4). MCC::PitchClass and MCC::ChromaticIndex discard the spelling and are obtained explicitly. Written equality and order are separate from enharmonic equivalence and pitch height; see Music-Domain Specification.

All types are trivially copyable, allocation-free and constexpr. Available when MCC_PITCH is defined.

Enumeration Type Documentation

◆ Letter

enum class MCC::Letter : uint8_t
strong

Diatonic letter name.

Closed enumeration ordered C D E F G A B with diatonic indices 0-6 (SPEC-ORD-1). Every enumerator is valid; Letter has no invalid state (SPEC-ERR-1). Values produced by casting integers outside 0-6 are not letters: NoteName rejects them and the queries below treat them as Letter::C.