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

A written pitch combined with an exact written note value. More...

#include <Note.h>

Collaboration diagram for MCC::Note:
Collaboration graph

Public Member Functions

constexpr Note () noexcept
 Creates the invalid note (SPEC-ERR-2).
constexpr Note (MCC::Pitch pitch, MCC::NoteValue value=MCC::NoteValue::Quarter()) noexcept
 Creates pitch with value; the default value is a quarter.
constexpr Note (MCC::NoteName noteName, int32_t octave, MCC::NoteValue value=MCC::NoteValue::Quarter()) noexcept
 Creates noteName in octave, with a quarter by default.
constexpr Note (MCC::Letter letter, int32_t octave, MCC::NoteValue value=MCC::NoteValue::Quarter()) noexcept
 Creates natural letter in octave, with a quarter by default.
constexpr Note (MCC::Letter letter, MCC::Accidental accidental, int32_t octave, MCC::NoteValue value=MCC::NoteValue::Quarter()) noexcept
 Creates letter + accidental in octave, with a quarter by default.
constexpr bool IsValid () const noexcept
 Returns true unless this is the invalid note.
constexpr MCC::Pitch Pitch () const noexcept
 Returns the written pitch, or the invalid pitch.
constexpr MCC::NoteValue Value () const noexcept
 Returns the written note value, or the invalid value.
constexpr MCC::NoteName NoteName () const noexcept
 Returns the written note name, or the invalid note name.
constexpr MCC::Letter Letter () const noexcept
 Returns the written letter.
constexpr MCC::Accidental Accidental () const noexcept
 Returns the written accidental, or the invalid accidental.
constexpr int8_t Octave () const noexcept
 Returns the written octave, or 0 for the invalid note.
MCC_CONSTEXPR14 MCC::PitchClass PitchClass () const noexcept
 Returns the pitch class, or the invalid pitch class.
MCC_CONSTEXPR14 MCC::ChromaticIndex ChromaticIndex () const noexcept
 Returns the chromatic index, or the invalid chromatic index.
constexpr Note WithPitch (MCC::Pitch pitch) const noexcept
 Returns the same note value with a new written pitch.
constexpr Note WithValue (MCC::NoteValue value) const noexcept
 Returns the same written pitch with a new note value.
constexpr Note WithDots (int32_t dots) const noexcept
 Returns the same written pitch and base with a new dot count.
MCC_CONSTEXPR14 Note MovedDiatonically (int32_t steps) const noexcept
 Moves the pitch diatonically and preserves the note value.
MCC_CONSTEXPR14 Note Altered (int32_t semitones) const noexcept
 Alters the pitch and preserves the note value.
MCC_CONSTEXPR14 Note MovedByOctaves (int32_t octaves) const noexcept
 Moves the pitch by octaves and preserves the note value.

Static Public Member Functions

static constexpr Note Invalid () noexcept
 Returns the invalid note.

Friends

constexpr bool operator== (Note a, Note b) noexcept
 Written equality of both pitch and note value.
constexpr bool operator!= (Note a, Note b) noexcept
MCC_CONSTEXPR14 bool operator< (Note a, Note b) noexcept
 Written order by pitch, then exact note-value duration; invalid notes sort last.
MCC_CONSTEXPR14 bool operator> (Note a, Note b) noexcept
MCC_CONSTEXPR14 bool operator<= (Note a, Note b) noexcept
MCC_CONSTEXPR14 bool operator>= (Note a, Note b) noexcept

Detailed Description

A written pitch combined with an exact written note value.

Note preserves the pitch spelling (C#4 remains distinct from Db4) and the rhythmic spelling (base plus augmentation dots). Constructors that omit the note value use a quarter note. Invalid pitch or value input produces the single invalid note.

MIDI conversion deliberately does not live here: a MIDI note number has no written spelling. MIDILAR must provide a key or another spelling policy and then construct an MCC note from the resulting MCC::Pitch.


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