MCC
Loading...
Searching...
No Matches
MCC::PitchClass Class Reference

Pitch class 0-11 with spelling discarded (C = 0). More...

#include <PitchClass.h>

Collaboration diagram for MCC::PitchClass:
Collaboration graph

Public Member Functions

constexpr PitchClass () noexcept
 Creates the invalid pitch class (SPEC-ERR-2).
constexpr PitchClass (int32_t value) noexcept
 Creates the pitch class value; values outside [0, 11] produce the invalid value (SPEC-ERR-3).
constexpr bool IsValid () const noexcept
 Returns true unless this is the invalid class.
constexpr uint8_t Value () const noexcept
 Returns the class in [0, 11], or InvalidValue for the invalid class (SPEC-ERR-7).
MCC_CONSTEXPR14 PitchClass Transposed (int32_t semitones) const noexcept
 Returns this class moved by semitones, reduced modulo 12. An invalid class stays invalid (SPEC-ERR-4).

Static Public Member Functions

static constexpr PitchClass Invalid () noexcept
 Returns the invalid pitch class.

Static Public Attributes

static constexpr uint8_t Count = 12
 Number of pitch classes in an octave.
static constexpr uint8_t InvalidValue = 0xFF
 Sentinel returned by Value() for the invalid class (SPEC-ERR-7). Do not rely on it; check IsValid().

Friends

constexpr bool operator== (PitchClass a, PitchClass b) noexcept
 Equality; all invalid classes are equal (SPEC-ERR-6).
constexpr bool operator!= (PitchClass a, PitchClass b) noexcept
constexpr bool operator< (PitchClass a, PitchClass b) noexcept
 Orders by value; invalid sorts last.
constexpr bool operator> (PitchClass a, PitchClass b) noexcept
constexpr bool operator<= (PitchClass a, PitchClass b) noexcept
constexpr bool operator>= (PitchClass a, PitchClass b) noexcept

Detailed Description

Pitch class 0-11 with spelling discarded (C = 0).

Default construction and out-of-range input produce the single invalid value (SPEC-ERR-2, SPEC-ERR-3): the constructor checks its input and does not reduce it. Use Transposed() for modular arithmetic. Classes are ordered by value; the invalid value sorts after every valid class.


The documentation for this class was generated from the following file: