Merge pS-w1-t4-kbd: keyboard_strip isNaturalKey predicate (S-VIEW-7 core)
This commit is contained in:
@@ -102,6 +102,29 @@ ZoneBarHit zoneBarAtPoint(const StripLayout& layout, const int* lows, const int*
|
||||
return ZoneBarHit{}; // on the band but on no bar
|
||||
}
|
||||
|
||||
bool isNaturalKey(int note) {
|
||||
// Clamp to the valid MIDI range before indexing.
|
||||
const int n = note < 0 ? 0 : (note > kStripKeyCount - 1 ? kStripKeyCount - 1 : note);
|
||||
// The 12-semitone pattern of natural (white) keys within an octave, starting at C:
|
||||
// positions 0(C) 2(D) 4(E) 5(F) 7(G) 9(A) 11(B) are natural;
|
||||
// positions 1(C#) 3(D#) 6(F#) 8(G#) 10(A#) are accidental.
|
||||
static constexpr bool kNatural[12] = {
|
||||
true, // 0 C
|
||||
false, // 1 C#
|
||||
true, // 2 D
|
||||
false, // 3 D#
|
||||
true, // 4 E
|
||||
true, // 5 F
|
||||
false, // 6 F#
|
||||
true, // 7 G
|
||||
false, // 8 G#
|
||||
true, // 9 A
|
||||
false, // 10 A#
|
||||
true, // 11 B
|
||||
};
|
||||
return kNatural[n % 12];
|
||||
}
|
||||
|
||||
int resolveDragNote(const StripLayout& layout, int startNote, int dxPixels) {
|
||||
if (dxPixels == 0) return clampNote(startNote);
|
||||
const int bandWidth = std::max(0, layout.keys.width());
|
||||
|
||||
@@ -118,4 +118,14 @@ ZoneBarHit zoneBarAtPoint(const StripLayout& layout, const int* lows, const int*
|
||||
// key centre. Returns startNote unchanged for dxPixels==0.
|
||||
int resolveDragNote(const StripLayout& layout, int startNote, int dxPixels);
|
||||
|
||||
// Returns true when `note` (0..127) is a NATURAL (white) key in standard 12-tone equal
|
||||
// temperament; false when it is an ACCIDENTAL (black) key. Notes out of the [0,127]
|
||||
// range are clamped to [0,127] before classification (i.e. this never throws/UBs on a
|
||||
// bad input). The 12 semitone positions within an octave:
|
||||
// Natural (white): 0(C) 2(D) 4(E) 5(F) 7(G) 9(A) 11(B)
|
||||
// Accidental (black): 1(C#) 3(D#) 6(F#) 8(G#) 10(A#)
|
||||
// Used by the shell to overlay the two-tone bright/dark piano-key pattern over the
|
||||
// pastel spectral fill (S-VIEW-7). Pure — no layout required, no host types.
|
||||
bool isNaturalKey(int note);
|
||||
|
||||
} // namespace reasampler::vst
|
||||
|
||||
Reference in New Issue
Block a user