|
MCC
|
Written absolute pitch: a note name plus an octave. More...
#include <Pitch.h>

Public Member Functions | |
| constexpr | Pitch () noexcept |
| Creates the invalid pitch (SPEC-ERR-2). | |
| constexpr | Pitch (MCC::NoteName noteName, int32_t octave) noexcept |
| Creates noteName written in octave. An invalid note name or an octave outside [-128, 127] produces the invalid pitch (SPEC-ERR-3). | |
| constexpr | Pitch (MCC::Letter letter, MCC::Accidental accidental, int32_t octave) noexcept |
| Creates letter + accidental written in octave. | |
| constexpr | Pitch (MCC::Letter letter, int32_t octave) noexcept |
| Creates the natural letter written in octave. | |
| constexpr bool | IsValid () const noexcept |
| Returns true unless this is the invalid pitch. | |
| constexpr MCC::NoteName | NoteName () const noexcept |
| Returns the written note name; invalid for the invalid pitch. | |
| constexpr MCC::Letter | Letter () const noexcept |
| Returns the written letter, or Letter::C for the invalid pitch (SPEC-ERR-7). | |
| constexpr MCC::Accidental | Accidental () const noexcept |
| Returns the written accidental; invalid for the invalid pitch. | |
| constexpr int8_t | Octave () const noexcept |
| Returns the written octave, or 0 for the invalid pitch (SPEC-ERR-7). | |
| MCC_CONSTEXPR14 int16_t | DiatonicIndex () const noexcept |
| Returns octave * 7 + letterIndex (SPEC-ORD-2), or InvalidDiatonicIndex for the invalid pitch (SPEC-ERR-7). | |
| MCC_CONSTEXPR14 MCC::ChromaticIndex | ChromaticIndex () const noexcept |
| Returns (octave + 1) * 12 + letterSemitone + accidental (SPEC-ORD-3); the invalid pitch yields the invalid index. | |
| MCC_CONSTEXPR14 MCC::PitchClass | PitchClass () const noexcept |
| Returns the pitch class of the written note name (SPEC-ORD-4); the invalid pitch yields the invalid class. | |
| MCC_CONSTEXPR14 Pitch | MovedDiatonically (int32_t steps) const noexcept |
| Moves the letter by steps diatonic letters, changing octave between B and C, and keeps the written accidental: B#3 moved by 1 is C#4. | |
| MCC_CONSTEXPR14 Pitch | Altered (int32_t semitones) const noexcept |
| Keeps the letter and octave and alters the accidental by semitones; outside [-4, +4] the result is invalid and is never respelled (SPEC-ACC-3). | |
| MCC_CONSTEXPR14 Pitch | MovedByOctaves (int32_t octaves) const noexcept |
| Moves the pitch by octaves octaves, keeping its spelling. The result is invalid outside [-128, 127] (SPEC-OCT-4). | |
Static Public Member Functions | |
| static constexpr Pitch | Invalid () noexcept |
| Returns the invalid pitch. | |
Static Public Attributes | |
| static constexpr int8_t | MinimumOctave = -128 |
| Lowest supported octave. | |
| static constexpr int8_t | MaximumOctave = 127 |
| Highest supported octave. | |
| static constexpr int16_t | InvalidDiatonicIndex = 32767 |
| Sentinel returned by DiatonicIndex() for the invalid pitch (SPEC-ERR-7). Do not rely on it; check IsValid(). | |
Friends | |
| constexpr bool | operator== (Pitch a, Pitch b) noexcept |
| Written equality: letter, accidental and octave (SPEC-EQ-1). All invalid pitches are equal (SPEC-ERR-6). | |
| constexpr bool | operator!= (Pitch a, Pitch b) noexcept |
| MCC_CONSTEXPR14 bool | operator< (Pitch a, Pitch b) noexcept |
| Written order: octave, then letter, then accidental (SPEC-ORD-5). B#3 < Cb4 although B#3 sounds higher. The invalid pitch sorts last. | |
| MCC_CONSTEXPR14 bool | operator> (Pitch a, Pitch b) noexcept |
| MCC_CONSTEXPR14 bool | operator<= (Pitch a, Pitch b) noexcept |
| MCC_CONSTEXPR14 bool | operator>= (Pitch a, Pitch b) noexcept |
Written absolute pitch: a note name plus an octave.
MCC uses scientific pitch notation: middle C is C4 (SPEC-OCT-1). The octave belongs to the written letter, so B#3 is written in octave 3 and sounds as C4 (SPEC-OCT-3). Octaves range from -128 to 127 (SPEC-OCT-4).
operator== and operator< compare the written pitch (SPEC-EQ-1, SPEC-ORD-5); sounding pitch is compared through ChromaticIndex(), MCC::IsEnharmonic() and MCC::IsLowerThan() (SPEC-EQ-2, SPEC-ORD-6).
Default construction, an invalid note name or an out-of-range octave produce the single invalid value (SPEC-ERR-1..3). Operations on the invalid value, and operations whose result leaves the octave or accidental ranges, return the invalid value (SPEC-ERR-4, SPEC-ERR-5).
|
inlinenoexcept |
Moves the letter by steps diatonic letters, changing octave between B and C, and keeps the written accidental: B#3 moved by 1 is C#4.
The result is invalid when the octave leaves [-128, 127] (SPEC-OCT-4, SPEC-ERR-5).