MCC
Loading...
Searching...
No Matches
Notation.h
1#ifndef MCC_NOTATION_NOTATION_H
2#define MCC_NOTATION_NOTATION_H
3
4#include <stddef.h>
5#include <stdint.h>
6
7#include <MCC/Interval/Interval.h>
8#include <MCC/Pitch/NoteName.h>
9#include <MCC/Pitch/Pitch.h>
10
11#if __has_include(<MCC/Scale/Scales.h>)
12 #include <MCC/Scale/Scales.h>
13#endif
14#if __has_include(<MCC/Chord/Chords.h>)
15 #include <MCC/Chord/Chords.h>
16#endif
17#if __has_include(<MCC/Key/Key.h>)
18 #include <MCC/Key/Key.h>
19#endif
20
21namespace MCC {
22
27enum class NotationSymbols : uint8_t {
30};
31
42
69namespace Notation {
70
72 using CodePointSink = void (*)(uint32_t codePoint, void* context);
73
75 template <typename CharT>
76 size_t Format(CharT* destination, size_t capacity, NoteName noteName,
77 NotationOptions options = NotationOptions()) noexcept;
78
80 template <typename CharT>
81 size_t Format(CharT* destination, size_t capacity, Pitch pitch,
82 NotationOptions options = NotationOptions()) noexcept;
83
88 template <typename CharT>
89 size_t Format(CharT* destination, size_t capacity, Interval interval,
90 NotationOptions options = NotationOptions()) noexcept;
91
93 size_t Format(CodePointSink sink, void* context, NoteName noteName,
94 NotationOptions options = NotationOptions()) noexcept;
95
97 size_t Format(CodePointSink sink, void* context, Pitch pitch,
98 NotationOptions options = NotationOptions()) noexcept;
99
101 size_t Format(CodePointSink sink, void* context, Interval interval,
102 NotationOptions options = NotationOptions()) noexcept;
103
105 template <typename CharT>
106 NoteName ParseNoteName(const CharT* text) noexcept;
107
109 template <typename CharT>
110 Pitch ParsePitch(const CharT* text) noexcept;
111
116 template <typename CharT>
117 Interval ParseInterval(const CharT* text) noexcept;
118
119#if __has_include(<MCC/Scale/Scales.h>)
121 template <typename CharT>
122 size_t Format(CharT* destination, size_t capacity, NoteName root, Scales::Id id,
123 NotationOptions options = NotationOptions()) noexcept;
124
126 size_t Format(CodePointSink sink, void* context, NoteName root, Scales::Id id,
127 NotationOptions options = NotationOptions()) noexcept;
128#endif
129
130#if __has_include(<MCC/Chord/Chords.h>)
132 template <typename CharT>
133 size_t Format(CharT* destination, size_t capacity, NoteName root, Chords::Id id,
134 NotationOptions options = NotationOptions()) noexcept;
135
137 size_t Format(CodePointSink sink, void* context, NoteName root, Chords::Id id,
138 NotationOptions options = NotationOptions()) noexcept;
139#endif
140
141#if __has_include(<MCC/Key/Key.h>)
143 template <typename CharT>
144 size_t Format(CharT* destination, size_t capacity, Key key,
145 NotationOptions options = NotationOptions()) noexcept;
146
148 size_t Format(CodePointSink sink, void* context, Key key,
149 NotationOptions options = NotationOptions()) noexcept;
150#endif
151
152} // namespace Notation
153
154} // namespace MCC
155
156#endif // MCC_NOTATION_NOTATION_H
Directed interval: a diatonic step count and a chromatic semitone count (SPEC-INT-1).
Definition Interval.h:30
A tonic and a diatonic mode, with the key signature they imply.
Definition Key.h:46
Written note name: a letter plus an accidental, without octave.
Definition NoteName.h:29
Written absolute pitch: a note name plus an octave.
Definition Pitch.h:35
NotationSymbols
Accidental symbols used in text output (SPEC-TXT-3).
Definition Notation.h:27
@ Ascii
#, b and n, repeated for multiples.
Definition Notation.h:28
@ Unicode
U+266F sharp, U+266D flat, U+266E natural, U+1D12A double sharp and U+1D12B double flat.
Definition Notation.h:29
Reviewed catalog of named chords stored in program memory.
Definition Chords.h:21
Id
Stable catalog identifier.
Definition Chords.h:24
Text formatting and parsing for note names, pitches and intervals.
Definition Notation.h:69
Interval ParseInterval(const CharT *text) noexcept
Parses an optional + or -, a quality (P M m A d, A/d repeated) and a number: M3, -P8,...
Pitch ParsePitch(const CharT *text) noexcept
Parses a note name followed by a signed octave: C4, bb-1, Unicode accidentals.
size_t Format(CharT *destination, size_t capacity, NoteName noteName, NotationOptions options=NotationOptions()) noexcept
Writes C, F#, Bbb (or the Unicode sharp and flat signs).
NoteName ParseNoteName(const CharT *text) noexcept
Parses C, f#, Ebb, Gx, Bn; up to four accidentals.
void(*)(uint32_t codePoint, void *context) CodePointSink
Receives one Unicode code point of formatted text.
Definition Notation.h:72
Reviewed catalog of named scales stored in program memory.
Definition Scales.h:20
Id
Stable catalog identifier.
Definition Scales.h:23
Music Composition Core public namespace.
Definition Version.h:4
Options for text output (SPEC-TXT-3).
Definition Notation.h:36
NotationSymbols symbols
Accidental symbols; ASCII by default.
Definition Notation.h:38
bool explicitNatural
Write the natural sign explicitly (Cn, or U+266E with Unicode symbols).
Definition Notation.h:40