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

Chromatic alteration of a letter, from -4 (quadruple flat) to +4 (quadruple sharp). More...

#include <Accidental.h>

Collaboration diagram for MCC::Accidental:
Collaboration graph

Public Member Functions

constexpr Accidental () noexcept
 Creates the invalid accidental (SPEC-ERR-2).
constexpr Accidental (int32_t semitones) noexcept
 Creates the accidental semitones; values outside [Minimum, Maximum] produce the invalid value (SPEC-ERR-3).
constexpr bool IsValid () const noexcept
 Returns true unless this is the invalid accidental.
constexpr int8_t Semitones () const noexcept
 Returns the alteration in semitones, or InvalidValue for the invalid accidental (SPEC-ERR-7).
MCC_CONSTEXPR14 Accidental Altered (int32_t semitones) const noexcept
 Returns this accidental altered by semitones.

Static Public Member Functions

static constexpr Accidental Invalid () noexcept
 Returns the invalid accidental.
static constexpr Accidental QuadrupleFlat () noexcept
 Returns the quadruple flat (-4).
static constexpr Accidental TripleFlat () noexcept
 Returns the triple flat (-3).
static constexpr Accidental DoubleFlat () noexcept
 Returns the double flat (-2).
static constexpr Accidental Flat () noexcept
 Returns the flat (-1).
static constexpr Accidental Natural () noexcept
 Returns the natural (0).
static constexpr Accidental Sharp () noexcept
 Returns the sharp (+1).
static constexpr Accidental DoubleSharp () noexcept
 Returns the double sharp (+2).
static constexpr Accidental TripleSharp () noexcept
 Returns the triple sharp (+3).
static constexpr Accidental QuadrupleSharp () noexcept
 Returns the quadruple sharp (+4).

Static Public Attributes

static constexpr int8_t Minimum = -4
 Lowest supported alteration (quadruple flat).
static constexpr int8_t Maximum = 4
 Highest supported alteration (quadruple sharp).
static constexpr int8_t InvalidValue = 127
 Sentinel returned by Semitones() for the invalid value (SPEC-ERR-7). Do not rely on it; check IsValid().

Friends

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

Detailed Description

Chromatic alteration of a letter, from -4 (quadruple flat) to +4 (quadruple sharp).

Natural (0) is a distinct written accidental (SPEC-ACC-1, SPEC-ACC-2). Default construction and out-of-range input produce the single invalid value (SPEC-ERR-1..3). Written order is by semitone value; the invalid value sorts after every valid accidental.

Member Function Documentation

◆ Altered()

MCC_CONSTEXPR14 Accidental MCC::Accidental::Altered ( int32_t semitones) const
inlinenoexcept

Returns this accidental altered by semitones.

The result is invalid when this accidental is invalid (SPEC-ERR-4) or when it would leave [Minimum, Maximum] (SPEC-ACC-3, SPEC-ERR-5).


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