MCC
Loading...
Searching...
No Matches
MCC::Chords Namespace Reference

Reviewed catalog of named chords stored in program memory. More...

Classes

struct  ScaleChord
 One chord found on a scale degree. More...

Enumerations

enum class  Id : uint8_t {
  Major = 0 , Minor , Augmented , Diminished ,
  Sixth , MinorSixth , DominantSeventh , MajorSeventh ,
  MinorSeventh , HalfDiminishedSeventh , DiminishedSeventh , DominantNinth ,
  DominantMinorNinth , MajorNinth , MinorNinth , DominantEleventh ,
  MajorEleventh , MinorEleventh , DominantThirteenth , MajorThirteenth ,
  MinorThirteenth , SuspendedSecond , SuspendedFourth , MinorMajorSeventh ,
  AugmentedSeventh , AddedNinth , SeventhSuspendedFourth , Power ,
  Invalid = 0xFF
}
 Stable catalog identifier.

Functions

ChordPattern Pattern (Id id) noexcept
 Returns the pattern of id, or the invalid pattern.
size_t CopyName (Id id, char *destination, size_t capacity) noexcept
 Copies the canonical name of id with snprintf semantics and returns its length; an invalid id writes an empty string.
size_t CopySymbol (Id id, char *destination, size_t capacity) noexcept
 Copies the chord symbol of id ("", "m", "maj7", ...) with snprintf semantics and returns its length.
size_t CopyAlias (uint8_t index, char *destination, size_t capacity, Id &target) noexcept
 Copies alias index (0-based, below AliasCount) and returns its length, also reporting the chord it names; out of range writes an empty string and reports Id::Invalid.
Id Find (const char *name) noexcept
 Finds a chord by exact canonical name or alias; returns Id::Invalid when nothing matches.
Chord Make (NoteName root, Id id) noexcept
 Spells catalog entry id from root.
size_t FromScale (const Scale &scale, ScaleChord *chords, size_t capacity) noexcept
 Lists every catalog chord whose tones are all written in scale (SPEC-CHD-5).

Variables

constexpr uint8_t Count = static_cast<uint8_t>(Id::Power) + 1
 Number of catalog entries.
constexpr uint8_t AliasCount = 7
 Number of aliases.
constexpr size_t NameCapacity = 28
 Buffer size that fits every name and alias with its terminator.
constexpr size_t SymbolCapacity = 8
 Buffer size that fits every symbol with its terminator.

Detailed Description

Reviewed catalog of named chords stored in program memory.

Every entry is read from flash on AVR through Foundation::Utils::Flash (SPEC-EMB-5); identifiers are stable and never reused (SPEC-CHD-4).

Function Documentation

◆ FromScale()

size_t MCC::Chords::FromScale ( const Scale & scale,
ScaleChord * chords,
size_t capacity )
noexcept

Lists every catalog chord whose tones are all written in scale (SPEC-CHD-5).

Chords are ordered by scale degree, then by catalog identifier. Writes at most capacity results and returns the number found, so a larger result means the buffer was too small. Spell a result with Make(scale.NoteAt(degree), id).