|
MCC
|
Text formatting and parsing for note names, pitches and intervals. More...
Typedefs | |
| using | CodePointSink = void (*)(uint32_t codePoint, void* context) |
| Receives one Unicode code point of formatted text. | |
Functions | |
| template<typename CharT> | |
| 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). | |
| template<typename CharT> | |
| size_t | Format (CharT *destination, size_t capacity, Pitch pitch, NotationOptions options=NotationOptions()) noexcept |
| Writes C4, F#-1, Bb10. | |
| template<typename CharT> | |
| size_t | Format (CharT *destination, size_t capacity, Interval interval, NotationOptions options=NotationOptions()) noexcept |
| Writes quality and number: P5, M3, m7, AA4, d12; a descending interval is prefixed with - (-m3). | |
| size_t | Format (CodePointSink sink, void *context, NoteName noteName, NotationOptions options=NotationOptions()) noexcept |
| Sends a note name to sink; returns the number of code points. | |
| size_t | Format (CodePointSink sink, void *context, Pitch pitch, NotationOptions options=NotationOptions()) noexcept |
| Sends a pitch to sink; returns the number of code points. | |
| size_t | Format (CodePointSink sink, void *context, Interval interval, NotationOptions options=NotationOptions()) noexcept |
| Sends an interval to sink; returns the number of code points. | |
| template<typename CharT> | |
| NoteName | ParseNoteName (const CharT *text) noexcept |
| Parses C, f#, Ebb, Gx, Bn; up to four accidentals. | |
| template<typename CharT> | |
| Pitch | ParsePitch (const CharT *text) noexcept |
| Parses a note name followed by a signed octave: C4, bb-1, Unicode accidentals. | |
| template<typename CharT> | |
| 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, +AA4. | |
Text formatting and parsing for note names, pitches and intervals.
The buffer's character type selects the encoding (SPEC-TXT-5):
| Buffer | Encoding |
|---|---|
| char | ASCII with NotationSymbols::Ascii, otherwise UTF-8 |
| char16_t | UTF-16, with surrogate pairs for the double sharp and double flat |
| char32_t | UTF-32 |
Every buffer Format function writes with snprintf semantics measured in code units: it returns the number of code units the full text needs, stores only whole characters that fit before the terminator, and terminates whenever capacity > 0, so a truncated result never ends in a partial UTF-8 or UTF-16 sequence (SPEC-TXT-1..2). The sink overloads pass each Unicode code point to a callback instead, for output without a buffer (for example straight to a serial port). Invalid values format as "(invalid)".
Parsing reads the same three encodings and accepts both symbol sets: a letter in either case, then #/U+266F (+1), x/U+1D12A (+2), b/U+266D (-1), U+1D12B (-2), or a single n/U+266E. Malformed text returns the invalid value (SPEC-TXT-4).