1#ifndef MCC_PITCH_PITCH_CLASS_H
2#define MCC_PITCH_PITCH_CLASS_H
4#include <MCC_BuildSettings.h>
8#include <Foundation/Math/Arithmetic.h>
24 static constexpr uint8_t
Count = 12;
44 : _value((value >= 0 && value <
Count)
45 ?
static_cast<uint8_t
>(value)
60 constexpr uint8_t
Value() const noexcept {
return _value; }
71 _value + Foundation::Math::FloorMod(semitones,
Count),
Count));
76 return a._value == b._value;
85 return a._value < b._value;
Pitch class 0-11 with spelling discarded (C = 0).
Definition PitchClass.h:21
constexpr uint8_t Value() const noexcept
Returns the class in [0, 11], or InvalidValue for the invalid class (SPEC-ERR-7).
Definition PitchClass.h:60
constexpr PitchClass(int32_t value) noexcept
Creates the pitch class value; values outside [0, 11] produce the invalid value (SPEC-ERR-3).
Definition PitchClass.h:43
static constexpr uint8_t InvalidValue
Sentinel returned by Value() for the invalid class (SPEC-ERR-7). Do not rely on it; check IsValid().
Definition PitchClass.h:30
friend constexpr bool operator==(PitchClass a, PitchClass b) noexcept
Equality; all invalid classes are equal (SPEC-ERR-6).
Definition PitchClass.h:75
static constexpr uint8_t Count
Number of pitch classes in an octave.
Definition PitchClass.h:24
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)...
Definition PitchClass.h:66
friend constexpr bool operator<(PitchClass a, PitchClass b) noexcept
Orders by value; invalid sorts last.
Definition PitchClass.h:84
constexpr bool IsValid() const noexcept
Returns true unless this is the invalid class.
Definition PitchClass.h:54
constexpr PitchClass() noexcept
Creates the invalid pitch class (SPEC-ERR-2).
Definition PitchClass.h:37
static constexpr PitchClass Invalid() noexcept
Returns the invalid pitch class.
Definition PitchClass.h:49
Music Composition Core public namespace.
Definition Version.h:4