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

Absolute semitone position of a pitch, with origin C-1 = 0. More...

#include <ChromaticIndex.h>

Collaboration diagram for MCC::ChromaticIndex:
Collaboration graph

Public Member Functions

constexpr ChromaticIndex () noexcept
 Creates the invalid index (SPEC-ERR-2).
constexpr ChromaticIndex (int32_t value) noexcept
 Creates the index value; values outside [Minimum, Maximum] produce the invalid index (SPEC-ERR-3).
constexpr bool IsValid () const noexcept
 Returns true unless this is the invalid index.
constexpr int16_t Value () const noexcept
 Returns the semitone position, or InvalidValue for the invalid index (SPEC-ERR-7).
MCC_CONSTEXPR14 MCC::PitchClass PitchClass () const noexcept
 Returns the pitch class Value() mod 12 (SPEC-ORD-4); the invalid index yields the invalid class (SPEC-ERR-4).
MCC_CONSTEXPR14 ChromaticIndex Transposed (int32_t semitones) const noexcept
 Returns this index moved by semitones. The result is invalid when this index is invalid or the result leaves [Minimum, Maximum] (SPEC-ERR-4, SPEC-ERR-5).

Static Public Member Functions

static constexpr ChromaticIndex Invalid () noexcept
 Returns the invalid index.

Static Public Attributes

static constexpr int16_t Minimum = -1528
 Lowest valid index: Cbbbb in octave -128.
static constexpr int16_t Maximum = 1551
 Highest valid index: B#### in octave 127.
static constexpr int16_t InvalidValue = 32767
 Sentinel returned by Value() for the invalid index (SPEC-ERR-7). Do not rely on it; check IsValid().

Friends

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

Detailed Description

Absolute semitone position of a pitch, with origin C-1 = 0.

C0 = 12, C4 = 60 and A4 = 69 (SPEC-CHR-1). Valid values cover every writable pitch, from Cbbbb-128 = -1528 to B####127 = 1551 (SPEC-CHR-2); they are not restricted to any protocol range (SPEC-CHR-3).

Default construction and out-of-range input produce the single invalid value (SPEC-ERR-2, SPEC-ERR-3). Indices are ordered by value; the invalid value sorts after every valid index.


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