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 None,
40 Other,
41 pppppp,
42 ppppp,
43 pppp,
44 ppp,
45 pp,
46 p,
47 mp,
48 mf,
49 f,
50 ff,
51 fff,
52 ffff,
53 fffff,
54 ffffff,
55 fp,
56 ffp,
57 fz,
58 ffz,
59 pf,
60 sf,
61 sfp,
62 sfpp,
63 sfz,
64 sffz,
65 sfzp,
66 rf,
67 rfz,
68 n
69};
70
73enum class Change {
74 Absolute,
75 RelativeIncrease,
76 RelativeDecrease
77};
78
81enum class Reinforcement {
82 None,
83 Sforzando,
84 Rinforzando
85};
86
91enum class Level {
92 None,
93 Other,
94 pppppp,
95 ppppp,
96 pppp,
97 ppp,
98 pp,
99 p,
100 mp,
101 mf,
102 f,
103 ff,
104 fff,
105 ffff,
106 fffff,
107 ffffff,
108 n
109};
110
130{
132 Reinforcement reinforcement{Reinforcement::None};
134 Level level{Level::None};
136 bool forzato{};
139 Level subsequent{Level::None};
140};
141
144struct Mark
145{
147 Dynamic dynamic{};
154 std::vector<std::string> glyphs;
155};
156
157} // namespace dynamics
158
162std::optional<dynamics::Mark> classifyDynamicRun(const musx::util::EnigmaTextChunk& chunk);
166dynamics::Composition dynamicComposition(dynamics::Dynamic dynamic);
173dynamics::Dynamic dynamicFromLevel(dynamics::Level level);
175std::string dynamicCanonicalText(dynamics::Dynamic dynamic);
177std::vector<std::string> dynamicCanonicalGlyphs(dynamics::Dynamic dynamic);
179std::vector<std::string> dynamicCanonicalLetterGlyphs(dynamics::Dynamic dynamic);
181std::vector<std::string> dynamicLettersToLetterGlyphs(std::string_view letters);
183std::string dynamicGlyphsToLetters(const std::vector<std::string>& glyphs);
184
185} // namespace classify
186} // 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:33
Structural decomposition of a dynamic marking.
Definition dynamics.h:130
bool forzato
Whether the marking carries the forzato "z", as in "fz", "sfz", "sffz", "rfz".
Definition dynamics.h:136
Level level
The sounding level, e.g. Level::f for "sfzp".
Definition dynamics.h:134
Level subsequent
The level after the attack, e.g.
Definition dynamics.h:139
Reinforcement reinforcement
Leading reinforcement syllable, if any.
Definition dynamics.h:132
Dynamic metadata attached to a source text run.
Definition dynamics.h:145
std::vector< std::string > glyphs
Glyph names that participated in the matched dynamic, in source order.
Definition dynamics.h:154
Dynamic dynamic
Classified dynamic.
Definition dynamics.h:147
Composition composition
Structural decomposition of the marking as it is spelled in the source.
Definition dynamics.h:151