denigma 4.0.0
Loading...
Searching...
No Matches
dynamics.h
1/*
2 * Copyright (C) 2026, Robert Patterson
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22#pragma once
23
24#include <optional>
25#include <string>
26#include <string_view>
27#include <vector>
28
29#include "musx/musx.h"
30
31namespace denigma {
32namespace classify {
33
34namespace dynamics {
35
38enum class Dynamic
39{
40 None,
41 Other,
42 pppppp,
43 ppppp,
44 pppp,
45 ppp,
46 pp,
47 p,
48 mp,
49 mf,
50 f,
51 ff,
52 fff,
53 ffff,
54 fffff,
55 ffffff,
56 fp,
57 ffp,
58 fz,
59 ffz,
60 pf,
61 sf,
62 sfp,
63 sfpp,
64 sfz,
65 sffz,
66 sfzp,
67 rf,
68 rfz,
69 n
70};
71
74enum class Change
75{
76 Absolute,
77 RelativeIncrease,
78 RelativeDecrease
79};
80
83enum class Reinforcement
84{
85 None,
86 Sforzando,
87 Rinforzando
88};
89
94enum class Level
95{
96 None,
97 Other,
98 pppppp,
99 ppppp,
100 pppp,
101 ppp,
102 pp,
103 p,
104 mp,
105 mf,
106 f,
107 ff,
108 fff,
109 ffff,
110 fffff,
111 ffffff,
112 n
113};
114
134{
136 Reinforcement reinforcement{ Reinforcement::None };
138 Level level{ Level::None };
140 bool forzato{};
143 Level subsequent{ Level::None };
144};
145
148struct Mark
149{
151 Dynamic dynamic{};
158 std::vector<std::string> glyphs;
159};
160
161} // namespace dynamics
162
166std::optional<dynamics::Mark> classifyDynamicRun(const musx::util::EnigmaTextChunk& chunk);
170dynamics::Composition dynamicComposition(dynamics::Dynamic dynamic);
177dynamics::Dynamic dynamicFromLevel(dynamics::Level level);
179std::string dynamicCanonicalText(dynamics::Dynamic dynamic);
181std::vector<std::string> dynamicCanonicalGlyphs(dynamics::Dynamic dynamic);
183std::vector<std::string> dynamicCanonicalLetterGlyphs(dynamics::Dynamic dynamic);
185std::vector<std::string> dynamicLettersToLetterGlyphs(std::string_view letters);
187std::string dynamicGlyphsToLetters(const std::vector<std::string>& glyphs);
188
189} // namespace classify
190} // namespace denigma
std::string dynamicGlyphsToLetters(const std::vector< std::string > &glyphs)
Returns the dynamic letters represented by known dynamic glyph names.
std::string dynamicCanonicalText(dynamics::Dynamic dynamic)
Returns the canonical text spelling for a dynamic.
dynamics::Composition dynamicComposition(dynamics::Dynamic dynamic)
Decomposes a dynamic into its constituent parts.
dynamics::Dynamic dynamicFromLevel(dynamics::Level level)
Returns the dynamics::Dynamic that names a level, so that a level can be passed to the functions keye...
std::vector< std::string > dynamicLettersToLetterGlyphs(std::string_view letters)
Returns per-letter SMuFL glyph names for recognized dynamic letters, omitting other characters.
std::vector< std::string > dynamicCanonicalGlyphs(dynamics::Dynamic dynamic)
Returns canonical SMuFL glyph names for a dynamic.
std::optional< dynamics::Mark > classifyDynamicRun(const musx::util::EnigmaTextChunk &chunk)
Classifies a source text chunk as a single plain dynamic mark.
dynamics::Composition dynamicCompositionFromLetters(std::string_view letters)
Decomposes dynamic letters such as "sffz" into their constituent parts, whether or not the spelling i...
std::vector< std::string > dynamicCanonicalLetterGlyphs(dynamics::Dynamic dynamic)
Returns canonical per-letter SMuFL glyph names for a dynamic.
Core public API for the Denigma conversion libraries.
Definition articulations.h:32
Structural decomposition of a dynamic marking.
Definition dynamics.h:134
bool forzato
Whether the marking carries the forzato "z", as in "fz", "sfz", "sffz", "rfz".
Definition dynamics.h:140
Level level
The sounding level, e.g. Level::f for "sfzp".
Definition dynamics.h:138
Level subsequent
The level after the attack, e.g.
Definition dynamics.h:143
Reinforcement reinforcement
Leading reinforcement syllable, if any.
Definition dynamics.h:136
Dynamic metadata attached to a source text run.
Definition dynamics.h:149
std::vector< std::string > glyphs
Glyph names that participated in the matched dynamic, in source order.
Definition dynamics.h:158
Dynamic dynamic
Classified dynamic.
Definition dynamics.h:151
Composition composition
Structural decomposition of the marking as it is spelled in the source.
Definition dynamics.h:155