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 {
44 Fourth,
45 MajorThird,
46 Fifth
47 };
48
50 musx::dom::NoteInfoPtr stoppedNote;
52 musx::dom::NoteInfoPtr touchedNote;
58 TouchInterval interval{ TouchInterval::Fourth };
61 musx::dom::NoteInfoPtr soundingNote;
62};
63
67{
69 std::vector<ArtificialHarmonic> harmonics;
70};
71
73using NoteheadValue = std::variant<std::monostate, ArtificialHarmonics>;
74
75} // namespace entry
76
80{
82 entry::NoteheadValue value{};
83
85 explicit operator bool() const noexcept
86 { return !std::holds_alternative<std::monostate>(value); }
87
89 template <typename T>
90 const T* as() const noexcept
91 { return std::get_if<T>(&value); }
92
94 template <typename T>
95 bool is() const noexcept
96 { return std::holds_alternative<T>(value); }
97};
98
103EntryNoteheadClassification classifyEntryNoteheads(const musx::dom::EntryInfoPtr& entry);
104
105} // namespace classify
106} // 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:32
Result returned by chord-level notehead-pattern classification.
Definition entries.h:80
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:82
const T * as() const noexcept
Returns the classified payload as T, or nullptr when it has another type.
Definition entries.h:90
Result returned by notehead classification.
Definition noteheads.h:66
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:43
musx::dom::NoteInfoPtr stoppedNote
The stopped (fingered) note. Normally has a notehead::Shape::Regular notehead.
Definition entries.h:50
NoteheadClassification touchedNotehead
Notehead classification already computed for touchedNote.
Definition entries.h:56
musx::dom::NoteInfoPtr soundingNote
A third note in the chord at the theoretical sounding pitch, if the source explicitly includes one.
Definition entries.h:61
NoteheadClassification stoppedNotehead
Notehead classification already computed for stoppedNote.
Definition entries.h:54
TouchInterval interval
Notated interval from stoppedNote to touchedNote.
Definition entries.h:58
musx::dom::NoteInfoPtr touchedNote
The touched note (harmonic node). Normally has a notehead::Shape::Diamond notehead.
Definition entries.h:52
One or more artificial-harmonic note pairs found within a chord (e.g.
Definition entries.h:67
std::vector< ArtificialHarmonic > harmonics
The artificial-harmonic note pairs found in the chord.
Definition entries.h:69