denigma 4.0.0
Loading...
Searching...
No Matches
articulations.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 <variant>
27#include <vector>
28
29#include "denigma/classify/classifier_common.h"
30#include "musx/musx.h"
31
32namespace denigma {
33
36namespace classify {
37
38namespace articulation {
39
43{
46 enum class Type
47 {
48 Accent,
49 BrassDoit,
50 BrassFalloff,
51 BrassPlop,
52 BrassScoop,
53 SoftAccent,
54 Spiccato,
55 Staccatissimo,
56 Staccato,
57 Stress,
58 StrongAccent,
59 Tenuto,
60 Unstress
61 };
62
67};
68
72{
74 std::vector<ArticulationMark> marks;
75};
76
80{
83 enum class Type
84 {
85 BrassBend,
86 BrassFlip,
87 BrassHalfMuted,
88 BrassLift,
89 BrassOpen,
90 BrassSmear,
91 BrassStopped,
92 BuzzPizzicato,
93 Fingernails,
94 LeftHandPizzicato,
95 SnapPizzicato,
96 ThumbPosition,
97 UpBow,
98 DownBow,
99 StringHarmonic
100 };
101
106};
107
111{
114 enum class Qualifier
115 {
116 Closed,
117 HalfLeft,
118 HalfRight,
119 Open
120 };
121
126};
127
131{
134 enum class Type
135 {
136 Damp,
137 DampAll
138 };
139
144};
145
149{
152 enum class Type
153 {
154 On,
155 Off
156 };
157
162};
163
167{
170 enum class Style
171 {
172 Measured,
173 Unmeasured
174 };
175
179 int marks{};
182};
183
187{
190 enum class Shape
191 {
192 Normal,
193 Angled,
194 DoubleAngled,
195 Square,
196 DoubleSquare,
197 HalfCurve,
198 DoubleDot,
199 Curlew
200 };
201
204 enum class Duration
205 {
206 Auto,
207 VeryShort,
208 Short,
209 Long,
210 VeryLong
211 };
212
219};
220
224{
227 enum class Type
228 {
229 Unspecified,
230 Comma,
231 Tick,
232 Upbow,
233 Salzedo
234 };
235
240};
241
245{
248 enum class Type
249 {
250 Normal,
251 Curved,
252 Short,
253 Thick,
254 Chant,
255 SingleStroke
256 };
257
262};
263
267{
270 enum class Type
271 {
272 VerticalSegment,
273 Normal,
274 Up,
275 Down
276 };
277
282};
283
287{
290 enum class Accidental
291 {
292 Unspecified,
293 Flat,
294 Natural,
295 Sharp
296 };
297
300 enum class Type
301 {
302 InvertedMordent,
303 InvertedTurn,
304 Mordent,
305 Shake,
306 Trill,
307 Turn
308 };
309
313 {
317 musx::dom::VerticalPlacement placement{};
318 };
319
325 std::vector<AccidentalMark> accidentals;
326};
327
335
339{
342 enum class Side
343 {
344 Left,
345 Right
346 };
347
351 musx::dom::NoteInfoPtr note;
354};
355
359{
362 enum class Category
363 {
364 Articulation,
365 PerformanceTechnique
366 };
367
372};
373
374} // namespace articulation
375
377using ArticulationValue = std::variant<
382
386{
390 musx::dom::VerticalPlacement placement{ musx::dom::VerticalPlacement::NotApplicable };
392 std::optional<std::string> glyphName;
393
395 explicit operator bool() const noexcept
396 { return !std::holds_alternative<std::monostate>(value); }
397
399 template <typename T>
400 const T* as() const noexcept
401 { return std::get_if<T>(&value); }
402
404 template <typename T>
405 bool is() const noexcept
406 { return std::holds_alternative<T>(value); }
407};
408
411 const musx::dom::MusxInstance<musx::dom::details::ArticulationAssign>& assignment,
412 const musx::dom::EntryInfoPtr& entryInfo);
415 const musx::dom::MusxInstance<musx::dom::FontInfo>& fontInfo, char32_t symbol);
416
417} // namespace classify
418} // namespace denigma
ArticulationClassification classifyArticulationSymbol(const musx::dom::MusxInstance< musx::dom::FontInfo > &fontInfo, char32_t symbol)
Classifies an articulation symbol from a font and character code.
std::variant< std::monostate, articulation::ArticulationMarks, articulation::TechniqueMark, articulation::HarmonMute, articulation::PluckedDamp, articulation::StringMute, articulation::Tremolo, articulation::Fermata, articulation::BreathMark, articulation::Caesura, articulation::Arpeggio, articulation::Ornament, articulation::VerticalEntryBracket, articulation::Parenthesis, PseudoTie, articulation::OtherMark > ArticulationValue
Variant payload for articulation classification.
Definition articulations.h:381
ArticulationClassification classifyArticulation(const musx::dom::MusxInstance< musx::dom::details::ArticulationAssign > &assignment, const musx::dom::EntryInfoPtr &entryInfo)
Classifies an articulation assignment for an entry.
Core public API for the Denigma conversion libraries.
Definition articulations.h:32
Result returned by articulation classification.
Definition articulations.h:386
const T * as() const noexcept
Returns the classified payload as T, or nullptr when it has another type.
Definition articulations.h:400
ArticulationValue value
Classified articulation payload, or std::monostate when no articulation was recognized.
Definition articulations.h:388
bool is() const noexcept
Returns true when the classified payload has type T.
Definition articulations.h:405
musx::dom::VerticalPlacement placement
Resolved placement of the assigned articulation, when classified from an assignment.
Definition articulations.h:390
std::optional< std::string > glyphName
SMuFL glyph name associated with the recognized symbol, when available.
Definition articulations.h:392
Visual style encoded by the source glyph variant.
Definition classifier_common.h:32
A source shape used as a stand-in for a laissez-vibrer tie or tie end.
Definition classifier_common.h:49
Classification for arpeggio articulation marks.
Definition articulations.h:267
Type
Arpeggio type.
Definition articulations.h:271
Type type
Classified arpeggio type.
Definition articulations.h:279
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:281
Classification for one articulation mark represented by a musx articulation symbol.
Definition articulations.h:43
Type
Articulation mark type recognized by the classifier.
Definition articulations.h:47
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:66
Type type
Articulation mark type.
Definition articulations.h:64
Classification for one or more articulation marks represented by a musx articulation symbol.
Definition articulations.h:72
std::vector< ArticulationMark > marks
One or more articulation marks represented by the source symbol.
Definition articulations.h:74
Classification for breath marks.
Definition articulations.h:224
Type
Breath mark type.
Definition articulations.h:228
Type type
Classified breath mark type.
Definition articulations.h:237
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:239
Classification for caesura articulation marks.
Definition articulations.h:245
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:261
Type
Caesura type.
Definition articulations.h:249
Type type
Classified caesura type.
Definition articulations.h:259
Classification for fermata articulation marks.
Definition articulations.h:187
Shape shape
Visual fermata shape.
Definition articulations.h:214
Shape
Visual fermata shape.
Definition articulations.h:191
Duration duration
Playback-duration class.
Definition articulations.h:216
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:218
Duration
Finale playback-duration class associated with the fermata.
Definition articulations.h:205
Classification for one note-attached Harmon mute technique symbol with qualifier state.
Definition articulations.h:111
Qualifier
Distinguishes the displayed stem / closed state of the Harmon mute symbol.
Definition articulations.h:115
Qualifier qualifier
Harmon mute qualifier encoded by the source glyph.
Definition articulations.h:123
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:125
Accidental sign attached to an ornament.
Definition articulations.h:313
Accidental accidental
Accidental sign shown with the ornament.
Definition articulations.h:315
musx::dom::VerticalPlacement placement
Placement of the accidental relative to the ornament sign.
Definition articulations.h:317
Classification for ornament articulation marks.
Definition articulations.h:287
Type type
Classified ornament type.
Definition articulations.h:321
std::vector< AccidentalMark > accidentals
Accidentals attached to the ornament sign.
Definition articulations.h:325
Accidental
Accidentals attached to an ornament sign.
Definition articulations.h:291
Type
Ornament types recognized by the classifier.
Definition articulations.h:301
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:323
Classification for recognized articulation symbols that have no more specific Denigma classification.
Definition articulations.h:359
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:371
Category
Broad notation category for preserving a known but unclassified mark.
Definition articulations.h:363
Category category
Broad notation category for the mark.
Definition articulations.h:369
Classification for a single notehead parenthesis mark attached to one side of a note.
Definition articulations.h:339
Side
Which side of the note the parenthesis mark appears on.
Definition articulations.h:343
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:353
Side side
Side of the note the parenthesis mark is on.
Definition articulations.h:349
musx::dom::NoteInfoPtr note
The note this parenthesis is associated with, per ArticulationAssign::calcAssociatedNote....
Definition articulations.h:351
Classification for a plucked-string damping symbol.
Definition articulations.h:131
Type type
Damping scope encoded by the source glyph.
Definition articulations.h:141
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:143
Type
Distinguishes damping selected strings from damping all strings.
Definition articulations.h:135
Classification for a string mute on/off symbol.
Definition articulations.h:149
Type type
Mute state encoded by the source glyph.
Definition articulations.h:159
Type
Whether the source symbol applies or removes the string mute.
Definition articulations.h:153
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:161
Classification for one note-attached technique mark represented by a musx articulation symbol.
Definition articulations.h:80
Type type
Technique mark type.
Definition articulations.h:103
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:105
Type
Technique mark type recognized by the classifier.
Definition articulations.h:84
Classification for tremolo articulation marks.
Definition articulations.h:167
int marks
Number of tremolo strokes.
Definition articulations.h:179
Style style
Tremolo style.
Definition articulations.h:177
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:181
Style
Distinguishes measured from unmeasured tremolo marks.
Definition articulations.h:171
Classification for Finale vertical entry bracket shapes.
Definition articulations.h:331
GlyphStyle glyphStyle
Visual style encoded by the source glyph variant.
Definition articulations.h:333