denigma 4.0.0
Loading...
Searching...
No Matches
chords.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 <vector>
27
28#include "musx/musx.h"
29
30namespace denigma {
31namespace classify {
32
33namespace chord {
34
40enum class Quality
41{
42 Major,
43 Minor,
44 Augmented,
45 Diminished,
46 Dominant,
47 MajorSeventh,
48 MinorSeventh,
49 DiminishedSeventh,
50 HalfDiminished,
51 MajorMinor,
52 MajorSixth,
53 MinorSixth,
54 DominantNinth,
55 MajorNinth,
56 MinorNinth,
57 DominantEleventh,
58 MajorEleventh,
59 MinorEleventh,
60 DominantThirteenth,
61 MajorThirteenth,
62 MinorThirteenth,
63 SuspendedSecond,
64 SuspendedFourth,
65 Pedal,
66 None,
67 Power
68};
69
72struct Degree
73{
76 enum class Type
77 {
78 Add,
79 Remove,
80 Alter
81 };
82
83 int value{};
84 int alteration{};
89};
90
97{
103 enum class Position
104 {
105 Inline,
106 Above,
107 Below
108 };
109
110 std::string text;
112};
113
114} // namespace chord
115
119{
121 std::vector<chord::SuffixString> strings;
123 std::optional<chord::Quality> quality;
125 std::vector<chord::Degree> degrees;
135
138 std::string calcText() const;
139};
140
144 const musx::dom::MusxInstanceList<musx::dom::others::ChordSuffixElement>& suffix);
145
148
149} // namespace classify
150} // namespace denigma
ChordSuffixClassification classifyChordSuffix()
Classifies a Finale chord with no displayed suffix as a major triad.
Core public API for the Denigma conversion libraries.
Definition articulations.h:32
Classified logical strings reconstructed from Finale chord-suffix elements.
Definition chords.h:119
bool hasUnrecognizedGlyphs
True when the suffix contains a private-use character that no known font mapping resolved.
Definition chords.h:134
bool stackDegrees
True when the suffix shows degrees stacked vertically instead of running left to right.
Definition chords.h:129
std::vector< chord::SuffixString > strings
The suffix's logical strings in Finale's source order. (See chord::SuffixString.)
Definition chords.h:121
std::string calcText() const
Concatenates the classified strings in Finale's source order.
bool hasOuterParentheses
True when a single pair of parentheses encloses the entire suffix text.
Definition chords.h:131
std::vector< chord::Degree > degrees
Degrees the suffix applies on top of quality, in source order.
Definition chords.h:125
std::optional< chord::Quality > quality
The recognized harmonic quality, or std::nullopt when the suffix text could not be parsed.
Definition chords.h:123
bool parenthesizeDegrees
True when the suffix shows degrees inside parentheses.
Definition chords.h:127
One degree alteration that a chord suffix applies on top of its chord::Quality.
Definition chords.h:73
Type type
How the degree modifies the chord.
Definition chords.h:85
int alteration
Chromatic alteration in semitones: -1 for flat, 1 for sharp, 0 for none.
Definition chords.h:84
int value
Degree number relative to the root, such as 9, 11, or 13.
Definition chords.h:83
Type
How the degree modifies the chord.
Definition chords.h:77
@ Remove
The degree is omitted from the chord.
@ Alter
A degree already present in the chord is chromatically altered.
@ Add
The degree is added to the chord.
bool impliedByText
True when the suffix text already spells this degree out, such as the seventh in "7sus4".
Definition chords.h:86
One contiguous logical text string within a Finale chord suffix.
Definition chords.h:97
Position position
The string's position relative to the suffix baseline.
Definition chords.h:111
Position
Logical vertical position of a Finale chord-suffix string.
Definition chords.h:104
@ Above
Stacked above the suffix baseline.
@ Below
Stacked below the suffix baseline.
std::string text
The string's text as Unicode.
Definition chords.h:110