MCC
Loading...
Searching...
No Matches
Scales.h
1#ifndef MCC_SCALE_SCALES_H
2#define MCC_SCALE_SCALES_H
3
4#include <stddef.h>
5#include <stdint.h>
6
7#include <MCC/Pitch/NoteName.h>
8#include <MCC/Scale/Scale.h>
9#include <MCC/Scale/ScalePattern.h>
10
11namespace MCC {
12
20namespace Scales {
21
23 enum class Id : uint8_t {
24 Chromatic = 0,
25 ChromaticFlats,
26 Major,
27 Minor,
28 HarmonicMinor,
29 MelodicMinor,
30 HarmonicMajor,
31 MajorPentatonic,
32 MinorPentatonic,
33 MinorBlues,
34 MajorBlues,
35 Dorian,
36 Phrygian,
37 Lydian,
38 Mixolydian,
39 Locrian,
40 Algerian,
41 Arabic,
42 Augmented,
43 Pelog,
44 Byzantine,
45 Chinese,
46 Diminished,
47 Egyptian,
48 EightToneSpanish,
49 Enigmatic,
50 Hindu,
51 Hirajoshi,
52 Iwato,
53 HungarianMinor,
54 Japanese,
55 Oriental,
56 WholeTone,
57 RomanianMinor,
58 SpanishGypsy,
59 SuperLocrian,
60 Invalid = 0xFF
61 };
62
64 enum class Family : uint8_t {
65 Western,
66 Modal,
67 Symmetric,
68 Exotic,
69 Invalid = 0xFF
70 };
71
73 constexpr uint8_t Count = static_cast<uint8_t>(Id::SuperLocrian) + 1;
74
76 constexpr uint8_t AliasCount = 9;
77
79 constexpr size_t NameCapacity = 24;
80
82 ScalePattern Pattern(Id id) noexcept;
83
85 Family FamilyOf(Id id) noexcept;
86
91 size_t CopyName(Id id, char* destination, size_t capacity) noexcept;
92
98 size_t CopyAlias(uint8_t index, char* destination, size_t capacity, Id& target) noexcept;
99
104 Id Find(const char* name) noexcept;
105
107 inline Scale Make(NoteName root, Id id) noexcept {
108 return Scale(root, Pattern(id));
109 }
110
111} // namespace Scales
112
113} // namespace MCC
114
115#endif // MCC_SCALE_SCALES_H
Written note name: a letter plus an accidental, without octave.
Definition NoteName.h:29
Root-independent scale structure: up to twelve ascending degrees.
Definition ScalePattern.h:32
A scale pattern spelled from a root note name.
Definition Scale.h:28
Reviewed catalog of named scales stored in program memory.
Definition Scales.h:20
Scale Make(NoteName root, Id id) noexcept
Spells catalog entry id from root.
Definition Scales.h:107
constexpr uint8_t AliasCount
Number of aliases.
Definition Scales.h:76
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 scale it na...
Family FamilyOf(Id id) noexcept
Returns the family of id, or Family::Invalid.
Id Find(const char *name) noexcept
Finds a scale by exact canonical name or alias; returns Id::Invalid when nothing matches.
constexpr size_t NameCapacity
Buffer size that fits every name and alias with its terminator.
Definition Scales.h:79
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 ...
Family
Grouping inherited from the historical catalog arrays.
Definition Scales.h:64
constexpr uint8_t Count
Number of catalog entries.
Definition Scales.h:73
ScalePattern Pattern(Id id) noexcept
Returns the pattern of id, or the invalid pattern.
Id
Stable catalog identifier.
Definition Scales.h:23
Music Composition Core public namespace.
Definition Version.h:4