mirror of
https://github.com/9x/sheetmusictrainer.git
synced 2026-11-03 22:03:54 +01:00
Feedback round 2: strings filter, key sync, fixed clef, unified metronome
- Strings filter: per-string toggle buttons (replaces fret-window-only semantics as a third 'limits notes' control); combines with fret window and key filter in targetPool (fretted instruments). - Key sync checkbox: display key signature can follow the target key (major/minor mapping), default off — both remain independently settable. - LiveNoteStaff: optional fixed clef — guitar/bass now keep their usual clef instead of flipping at middle C; octave markers handle range. - Unified metronome widget (MetronomeWidget) with animated linear pendulum synced to the audible click; shown in ALL modes next to the tuner. Phrase BPM now reads from settings.rhythm.bpm (single source); the phrase-local BPM control was removed from the setup panel. - Tests: 160/160; tsc + eslint clean; build ok.
This commit is contained in:
@@ -10,6 +10,7 @@ const base = {
|
||||
keyEnabled: false,
|
||||
keyTonic: 'C',
|
||||
keyMode: 'major',
|
||||
strings: [],
|
||||
fretWindowEnabled: false,
|
||||
fretMin: 0,
|
||||
fretMax: 4,
|
||||
@@ -76,3 +77,34 @@ describe('computeTargetPool', () => {
|
||||
expect(pool.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('computeTargetPool — string selection', () => {
|
||||
it('restricts to a single string when selected', () => {
|
||||
// String index 5 = high E (open midi 64)
|
||||
const pool = computeTargetPool({ ...base, strings: [5] });
|
||||
expect(pool).toContain(64); // open high E
|
||||
expect(pool).toContain(65); // fret 1
|
||||
expect(pool).not.toContain(45); // open A (string 1) — different string
|
||||
// all notes come from one string
|
||||
expect(pool.every(m => m >= 64)).toBe(true);
|
||||
});
|
||||
|
||||
it('combines strings + fret window', () => {
|
||||
// String index 1 (open A = 45), frets 0..2
|
||||
const pool = computeTargetPool({ ...base, strings: [1], fretWindowEnabled: true, fretMin: 0, fretMax: 2 });
|
||||
expect(pool).toEqual([45, 46, 47]);
|
||||
});
|
||||
|
||||
it('combines strings + fret window + key filter', () => {
|
||||
// Low E string (index 0), frets 0..4, C major → only natural notes in that range
|
||||
const pool = computeTargetPool({ ...base, strings: [0], fretWindowEnabled: true, fretMin: 0, fretMax: 4, keyEnabled: true, keyTonic: 'C', keyMode: 'major' });
|
||||
// Low E string frets 0-4: E(40) F(41) F#(42) G(43) G#(44); C major pcs: C D E F G A B
|
||||
expect(pool).toEqual([40, 41, 43]); // E, F, G (F#, G# excluded)
|
||||
});
|
||||
|
||||
it('treats empty strings array as all strings', () => {
|
||||
const a = computeTargetPool({ ...base, strings: [] });
|
||||
const b = computeTargetPool({ ...base, strings: [0, 1, 2, 3, 4, 5] });
|
||||
expect(a).toEqual(b);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user