denigma 4.0.0
Loading...
Searching...
No Matches
entries.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 <variant>
25#include <vector>
26
27#include "denigma/classify/noteheads.h"
28#include "musx/musx.h"
29
30namespace denigma {
31namespace classify {
32
33namespace entry {
34
39{
42 enum class TouchInterval {
43 Fourth,
44 MajorThird,
45 Fifth
46 };
47
49 musx::dom::NoteInfoPtr stoppedNote;
51 musx::dom::NoteInfoPtr touchedNote;
57 TouchInterval interval{TouchInterval::Fourth};
60 musx::dom::NoteInfoPtr soundingNote;
61};
62
66{
68 std::vector<ArtificialHarmonic> harmonics;
69};
70
72using NoteheadValue = std::variant<std::monostate, ArtificialHarmonics>;
73
74} // namespace entry
75
79{
81 entry::NoteheadValue value{};
82
84 explicit operator bool() const noexcept { return !std::holds_alternative<std::monostate>(value); }
85
87 template <typename T>
88 const T* as() const noexcept
89 {
90 return std::get_if<T>(&value);
91 }
92
94 template <typename T>
95 bool is() const noexcept
96 {
97 return std::holds_alternative<T>(value);
98 }
99};
100
105EntryNoteheadClassification classifyEntryNoteheads(const musx::dom::EntryInfoPtr& entry);
106
107} // namespace classify
108} // namespace denigma
EntryNoteheadClassification classifyEntryNoteheads(const musx::dom::EntryInfoPtr &entry)
Classifies chord-level notehead patterns (e.g.
Core public API for the Denigma conversion libraries.
Definition articulations.h:33
Result returned by chord-level notehead-pattern classification.
Definition entries.h:79
bool is() const noexcept
Returns true when the classified payload has type T.
Definition entries.h:95
entry::NoteheadValue value
Classified payload, or std::monostate when no chord-level notehead pattern was recognized.
Definition entries.h:81
const T * as() const noexcept
Returns the classified payload as T, or nullptr when it has another type.
Definition entries.h:88
Result returned by notehead classification.
Definition noteheads.h:65
Classification for one artificial-harmonic note pair (a stopped note plus a touched node) found withi...
Definition entries.h:39
TouchInterval
The notated interval from the stopped note up to the touched node.
Definition entries.h:42
musx::dom::NoteInfoPtr stoppedNote
The stopped (fingered) note. Normally has a notehead::Shape::Regular notehead.
Definition entries.h:49
NoteheadClassification touchedNotehead
Notehead classification already computed for touchedNote.
Definition entries.h:55
musx::dom::NoteInfoPtr soundingNote
A third note in the chord at the theoretical sounding pitch, if the source explicitly includes one.
Definition entries.h:60
NoteheadClassification stoppedNotehead
Notehead classification already computed for stoppedNote.
Definition entries.h:53
TouchInterval interval
Notated interval from stoppedNote to touchedNote.
Definition entries.h:57
musx::dom::NoteInfoPtr touchedNote
The touched note (harmonic node). Normally has a notehead::Shape::Diamond notehead.
Definition entries.h:51
One or more artificial-harmonic note pairs found within a chord (e.g.
Definition entries.h:66
std::vector< ArtificialHarmonic > harmonics
The artificial-harmonic note pairs found in the chord.
Definition entries.h:68