Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
accidentals.h
1#pragma once
2
3#include "model/scale/anchor_marker.h"
4#include "model/scale/musical_key.h"
5#include "model/scale/scale_change.h"
6
7#include <cstdint>
8
13namespace deluge::accidentals {
14
18struct SpelledKey {
19 explicit SpelledKey(const MusicalKey& key_) : key(key_), flats(key_.prefersFlats()) {}
20
23 [[nodiscard]] int32_t displayAnchor(int32_t noteCode) const { return key.accidentalAnchor(noteCode, flats); }
24
25 MusicalKey key;
26 bool flats;
27};
28
32int32_t lineageAnchor(int32_t pitch, AnchorMarker marker, const SpelledKey& key);
33
38AnchorMarker markerFor(int32_t pitch, int32_t anchor, const SpelledKey& newKey);
39
47
50 int32_t pitch;
52 int32_t anchor;
55 AnchorMarker forcedMarker = AnchorMarker::derived();
56
60 [[nodiscard]] AnchorMarker markerUnder(const SpelledKey& finalKey, int32_t pendingTranspose = 0) const {
61 return forcedMarker.isDerived() ? markerFor(pitch + pendingTranspose, anchor + pendingTranspose, finalKey)
63 }
64};
65
76NoteDestination destination(int32_t pitch, AnchorMarker marker, const SpelledKey& oldKey, const ScaleChange& change,
77 AccidentalHandling handling);
78
79} // namespace deluge::accidentals
Definition anchor_marker.h:23
Definition musical_key.h:10
bool prefersFlats() const
Definition musical_key.cpp:19
Definition scale_change.h:24
Definition instrument_clip.h:46
NoteDestination destination(int32_t pitch, AnchorMarker marker, const SpelledKey &oldKey, const ScaleChange &change, AccidentalHandling handling)
Definition accidentals.cpp:133
AccidentalHandling
What a scale change which shifts scale degrees does with accidentals.
Definition accidentals.h:41
@ FOLLOW_ANCHOR
They move along with the in-key note they hang off.
Definition accidentals.h:43
@ KEEP_PITCH
They stay at their pitch (sharpening or flattening one degree).
Definition accidentals.h:45
int32_t lineageAnchor(int32_t pitch, AnchorMarker marker, const SpelledKey &key)
Definition accidentals.cpp:8
AnchorMarker markerFor(int32_t pitch, int32_t anchor, const SpelledKey &newKey)
Definition accidentals.cpp:15
Where a scale change puts a note.
Definition accidentals.h:49
int32_t anchor
The note's lineage anchor after the change.
Definition accidentals.h:52
AnchorMarker forcedMarker
Definition accidentals.h:55
AnchorMarker markerUnder(const SpelledKey &finalKey, int32_t pendingTranspose=0) const
Definition accidentals.h:60
Definition accidentals.h:18
int32_t displayAnchor(int32_t noteCode) const
Definition accidentals.h:23