mirror of
https://github.com/9x/sheetmusictrainer.git
synced 2026-11-03 13:53:55 +01:00
UI reorg: settings grouped by usage frequency
- Filter (key/strings/fret window) collapsed behind Filter button with active-count badge; opens the unified TargetNoteControls panel - Display key signature moved into the filter panel (all modes) - Instrument + Tuning selects moved into Settings modal (Instrument section); removed from footer - Settings modal restructured into collapsible sections: Instrument, Appearance, Audio, Microphone - Phrase setup panel: removed cross-reference hint texts - PracticeFilter is now the single source of truth: removed mirrored keyTonic/keyMode/fretWindow fields from PhraseSettings - Dark mode: neutral gray with slight blue tint (was warm brown)
This commit is contained in:
@@ -1,14 +1,11 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Guitar, Music, Gauge } from 'lucide-react';
|
import { Gauge, SlidersHorizontal } from 'lucide-react';
|
||||||
import { TUNINGS, INSTRUMENT_TUNINGS } from '../music/Tunings';
|
|
||||||
import { INSTRUMENT_DEFINITIONS } from '../music/InstrumentConfigs';
|
|
||||||
|
|
||||||
import { TuningMeter } from './TuningMeter';
|
import { TuningMeter } from './TuningMeter';
|
||||||
import { TargetNoteControls } from './TargetNoteControls';
|
import { TargetNoteControls } from './TargetNoteControls';
|
||||||
import { MetronomeWidget } from './MetronomeWidget';
|
import { MetronomeWidget } from './MetronomeWidget';
|
||||||
import { phraseRunBus } from '../hooks/phraseRunBus';
|
import { phraseRunBus } from '../hooks/phraseRunBus';
|
||||||
import { useSettings } from '../context/useSettings';
|
import { useSettings } from '../context/useSettings';
|
||||||
import { type Difficulty, type RhythmSettings } from '../types/SettingsTypes';
|
import { getPracticeFilter, type RhythmSettings } from '../types/SettingsTypes';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -18,35 +15,13 @@ interface ControlsProps {
|
|||||||
|
|
||||||
export const Controls: React.FC<ControlsProps> = ({ currentPitch }) => {
|
export const Controls: React.FC<ControlsProps> = ({ currentPitch }) => {
|
||||||
const { settings, updateSettings } = useSettings();
|
const { settings, updateSettings } = useSettings();
|
||||||
// Alias to minimize refactor, or just use updateSettings.
|
|
||||||
const onUpdateSettings = updateSettings;
|
const onUpdateSettings = updateSettings;
|
||||||
// Phrase run gate: the metronome only ticks while the phrase trainer is
|
// Phrase run gate: the metronome only ticks while the phrase trainer is
|
||||||
// counting in / playing (armed by the user toggle, fired by the run).
|
// counting in / playing (armed by the user toggle, fired by the run).
|
||||||
const [phraseRunActive, setPhraseRunActive] = useState(false);
|
const [phraseRunActive, setPhraseRunActive] = useState(false);
|
||||||
useEffect(() => phraseRunBus.subscribe(setPhraseRunActive), []);
|
useEffect(() => phraseRunBus.subscribe(setPhraseRunActive), []);
|
||||||
const handleTuningChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
// Note-filter panel: hidden by default (minimal UI), toggled here.
|
||||||
onUpdateSettings({ ...settings, tuningId: e.target.value });
|
const [filtersOpen, setFiltersOpen] = useState(false);
|
||||||
};
|
|
||||||
|
|
||||||
const handleInstrumentChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
||||||
const newInstrumentId = e.target.value;
|
|
||||||
const instDef = INSTRUMENT_DEFINITIONS[newInstrumentId];
|
|
||||||
|
|
||||||
const defaultRange = instDef.ranges[0].id;
|
|
||||||
|
|
||||||
// Reset tuning if applicable, or just keep as is (it won't be shown/used)
|
|
||||||
let newTuningId = settings.tuningId;
|
|
||||||
if (instDef.showTuning && INSTRUMENT_TUNINGS[newInstrumentId as 'guitar' | 'bass']) {
|
|
||||||
newTuningId = INSTRUMENT_TUNINGS[newInstrumentId as 'guitar' | 'bass'][0];
|
|
||||||
}
|
|
||||||
|
|
||||||
onUpdateSettings({
|
|
||||||
...settings,
|
|
||||||
instrument: newInstrumentId,
|
|
||||||
difficulty: defaultRange as Difficulty,
|
|
||||||
tuningId: newTuningId
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateRhythm = (updates: Partial<RhythmSettings>) => {
|
const updateRhythm = (updates: Partial<RhythmSettings>) => {
|
||||||
onUpdateSettings({
|
onUpdateSettings({
|
||||||
@@ -55,98 +30,36 @@ export const Controls: React.FC<ControlsProps> = ({ currentPitch }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cast instrument to specific key if needed, or use generic record access
|
const pf = getPracticeFilter(settings);
|
||||||
const availableTunings = INSTRUMENT_TUNINGS[settings.instrument as 'guitar' | 'bass'] || [];
|
const activeFilterCount =
|
||||||
const currentInstrumentDef = INSTRUMENT_DEFINITIONS[settings.instrument];
|
(pf.keyEnabled ? 1 : 0) +
|
||||||
|
(pf.strings.length > 0 ? 1 : 0) +
|
||||||
|
(pf.fretWindowEnabled ? 1 : 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Phrase Mode brings its own key/tempo machinery; the single-note
|
|
||||||
// key-signature select and metronome tool would be competing controls.
|
|
||||||
const inPhraseMode = settings.gameMode === 'phrase';
|
const inPhraseMode = settings.gameMode === 'phrase';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="controls-container">
|
<div className="controls-container">
|
||||||
{/* Top Section: Settings Grid (2 Columns) */}
|
{/* Note filter: collapsed behind a button — visible only when needed */}
|
||||||
<div className="settings-grid">
|
<div style={{ display: 'flex', justifyContent: 'center', marginBottom: '8px' }}>
|
||||||
{/* Row 1, Col 1 */}
|
<button
|
||||||
<div className="control-group">
|
className={`hint-button ${filtersOpen ? 'active' : ''}`}
|
||||||
<label className="control-label">
|
onClick={() => setFiltersOpen(o => !o)}
|
||||||
<Music size={18} />
|
title="Limit the notes used for exercises (key, strings, fret window)"
|
||||||
<span>Instrument</span>
|
>
|
||||||
</label>
|
<SlidersHorizontal size={16} />
|
||||||
<select
|
Filter
|
||||||
value={settings.instrument}
|
{activeFilterCount > 0 && (
|
||||||
onChange={handleInstrumentChange}
|
<span style={{
|
||||||
className="control-select"
|
display: 'inline-block', minWidth: '18px', padding: '1px 5px',
|
||||||
>
|
marginLeft: '4px', borderRadius: '9px', fontSize: '11px',
|
||||||
{Object.values(INSTRUMENT_DEFINITIONS).map(def => (
|
background: 'var(--color-primary)', color: 'var(--color-surface)',
|
||||||
<option key={def.id} value={def.id}>{def.displayName}</option>
|
fontWeight: 600, textAlign: 'center'
|
||||||
))}
|
}}>{activeFilterCount}</span>
|
||||||
</select>
|
)}
|
||||||
</div>
|
</button>
|
||||||
|
|
||||||
{/* Row 1, Col 2 (Conditional) */}
|
|
||||||
{currentInstrumentDef.showTuning ? (
|
|
||||||
<div className="control-group">
|
|
||||||
<label className="control-label">
|
|
||||||
<Guitar size={18} />
|
|
||||||
<span>Tuning</span>
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
value={settings.tuningId}
|
|
||||||
onChange={handleTuningChange}
|
|
||||||
className="control-select"
|
|
||||||
>
|
|
||||||
{availableTunings.map(id => (
|
|
||||||
<option key={id} value={id}>{TUNINGS[id].name}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
) : <div />} {/* Spacer to maintain grid flow if needed, or omit to let items flow. User asked for specific rows.
|
|
||||||
If I omit, Note Set goes here. Let's omit for "Dense" feel, or keep empty div for strict rows?
|
|
||||||
The request "Top row: instrument and tuning" implies if tuning is missing, maybe just 1 item?
|
|
||||||
I'll output an empty div if I want to FORCE strict placement, but generally flow is better.
|
|
||||||
However, "Second row: note set..." suggests structure.
|
|
||||||
I will use an empty div if tuning is hidden to push Note Set to next row?
|
|
||||||
Actually, grid-template-columns: 1fr 1fr.
|
|
||||||
If Tuning is hidden, Note Set becomes Item 2.
|
|
||||||
I'll forgo complexity and just render what's available. */}
|
|
||||||
|
|
||||||
{/* Row 2, Col 2 */}
|
|
||||||
{!inPhraseMode && (
|
|
||||||
<div className="control-group">
|
|
||||||
<label className="control-label">
|
|
||||||
<span>Key signature</span>
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
value={settings.keySignature}
|
|
||||||
onChange={(e) => onUpdateSettings({ ...settings, keySignature: e.target.value })}
|
|
||||||
className="control-select"
|
|
||||||
>
|
|
||||||
<optgroup label="Major Keys">
|
|
||||||
<option value="C">C Major</option>
|
|
||||||
<option value="G">G Major</option>
|
|
||||||
<option value="D">D Major</option>
|
|
||||||
<option value="A">A Major</option>
|
|
||||||
<option value="E">E Major</option>
|
|
||||||
<option value="F">F Major</option>
|
|
||||||
<option value="Bb">Bb Major</option>
|
|
||||||
<option value="Eb">Eb Major</option>
|
|
||||||
</optgroup>
|
|
||||||
<optgroup label="Minor Keys">
|
|
||||||
<option value="Am">A Minor</option>
|
|
||||||
<option value="Em">E Minor</option>
|
|
||||||
<option value="Dm">D Minor</option>
|
|
||||||
</optgroup>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{filtersOpen && <TargetNoteControls />}
|
||||||
{/* Target-note filter: unified controls, all modes */}
|
|
||||||
<TargetNoteControls />
|
|
||||||
|
|
||||||
{/* Bottom Section: Tools Grid (2 Columns now) */}
|
{/* Bottom Section: Tools Grid (2 Columns now) */}
|
||||||
<div className="tools-grid" style={inPhraseMode ? { gridTemplateColumns: '1fr' } : undefined}>
|
<div className="tools-grid" style={inPhraseMode ? { gridTemplateColumns: '1fr' } : undefined}>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRe
|
|||||||
import { useSettings } from '../context/useSettings';
|
import { useSettings } from '../context/useSettings';
|
||||||
import { useAudioPlayer } from '../hooks/useAudioPlayer';
|
import { useAudioPlayer } from '../hooks/useAudioPlayer';
|
||||||
import { usePhraseTrainer, type PhraseTrainerApi, type PhrasePhase } from '../hooks/usePhraseTrainer';
|
import { usePhraseTrainer, type PhraseTrainerApi, type PhrasePhase } from '../hooks/usePhraseTrainer';
|
||||||
import { getPhraseSettings, getPracticeFilter, type PhraseSettings, type PracticeFilter } from '../types/SettingsTypes';
|
import { getPhraseSettings, getPracticeFilter, type PhraseSettings } from '../types/SettingsTypes';
|
||||||
import { rawFrameCount } from '../hooks/rawFrameBus';
|
import { rawFrameCount } from '../hooks/rawFrameBus';
|
||||||
import { audioEngine } from '../audio/AudioEngine';
|
import { audioEngine } from '../audio/AudioEngine';
|
||||||
import { computePlayableNotes, isFrettedInstrument, positionsWithinWindow } from '../music/playableRange';
|
import { computePlayableNotes, isFrettedInstrument, positionsWithinWindow } from '../music/playableRange';
|
||||||
@@ -71,14 +71,9 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
const setSettings = updateSettings;
|
const setSettings = updateSettings;
|
||||||
const { playNote } = useAudioPlayer();
|
const { playNote } = useAudioPlayer();
|
||||||
const phrase = getPhraseSettings(settings);
|
const phrase = getPhraseSettings(settings);
|
||||||
// Unified target-note controls: Phrase Mode reads/writes the shared
|
// Unified target-note controls: Phrase Mode reads the shared practice
|
||||||
// practice filter so all modes expose identical key/fret-window state.
|
// filter (single source of truth across all modes).
|
||||||
const pf = getPracticeFilter(settings);
|
const pf = getPracticeFilter(settings);
|
||||||
phrase.keyTonic = pf.keyTonic;
|
|
||||||
phrase.keyMode = pf.keyMode;
|
|
||||||
phrase.fretWindowEnabled = pf.fretWindowEnabled;
|
|
||||||
phrase.fretMin = pf.fretMin;
|
|
||||||
phrase.fretMax = pf.fretMax;
|
|
||||||
// Unified metronome: phrase tempo reads from the shared rhythm BPM
|
// Unified metronome: phrase tempo reads from the shared rhythm BPM
|
||||||
// (single source of truth across modes; the phrase-local BPM control
|
// (single source of truth across modes; the phrase-local BPM control
|
||||||
// was replaced by the common metronome widget in Controls).
|
// was replaced by the common metronome widget in Controls).
|
||||||
@@ -96,18 +91,7 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
? settings.rhythm.active && settings.rhythm.sound
|
? settings.rhythm.active && settings.rhythm.sound
|
||||||
: settings.rhythm.active && settings.rhythm.sound && !settings.rhythm.syncToExercise;
|
: settings.rhythm.active && settings.rhythm.sound && !settings.rhythm.syncToExercise;
|
||||||
const setPhrase = useCallback((updates: Partial<PhraseSettings>) => {
|
const setPhrase = useCallback((updates: Partial<PhraseSettings>) => {
|
||||||
updateSettings(s => {
|
updateSettings(s => ({ ...s, phrase: { ...getPhraseSettings(s), ...updates } }));
|
||||||
const next = { ...s, phrase: { ...getPhraseSettings(s), ...updates } };
|
|
||||||
// Mirror shared filter fields into the unified practice filter.
|
|
||||||
const shared: Partial<PracticeFilter> = {};
|
|
||||||
if ('keyTonic' in updates) shared.keyTonic = updates.keyTonic;
|
|
||||||
if ('keyMode' in updates) shared.keyMode = updates.keyMode;
|
|
||||||
if ('fretWindowEnabled' in updates) shared.fretWindowEnabled = updates.fretWindowEnabled;
|
|
||||||
if ('fretMin' in updates) shared.fretMin = updates.fretMin;
|
|
||||||
if ('fretMax' in updates) shared.fretMax = updates.fretMax;
|
|
||||||
if (Object.keys(shared).length > 0) next.practice = { ...getPracticeFilter(s), ...shared };
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
}, [updateSettings]);
|
}, [updateSettings]);
|
||||||
const currentInstrumentDef = INSTRUMENT_DEFINITIONS[settings.instrument];
|
const currentInstrumentDef = INSTRUMENT_DEFINITIONS[settings.instrument];
|
||||||
const currentTuning = TUNINGS[settings.tuningId];
|
const currentTuning = TUNINGS[settings.tuningId];
|
||||||
@@ -140,7 +124,6 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
customMaxFret: settings.customMaxFret,
|
customMaxFret: settings.customMaxFret,
|
||||||
});
|
});
|
||||||
}, [pf.strings, pf.fretWindowEnabled, pf.fretMin, pf.fretMax, fretted, currentTuning,
|
}, [pf.strings, pf.fretWindowEnabled, pf.fretMin, pf.fretMax, fretted, currentTuning,
|
||||||
phrase.fretWindowEnabled, phrase.fretMin, phrase.fretMax,
|
|
||||||
settings.instrument, settings.difficulty, settings.tuningId, settings.customMinFret, settings.customMaxFret]);
|
settings.instrument, settings.difficulty, settings.tuningId, settings.customMinFret, settings.customMaxFret]);
|
||||||
|
|
||||||
// ---- Imported score (session-only) --------------------------------------
|
// ---- Imported score (session-only) --------------------------------------
|
||||||
@@ -173,8 +156,8 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
const baseScore: Result<Score> | null = useMemo(() => {
|
const baseScore: Result<Score> | null = useMemo(() => {
|
||||||
if (phrase.material === 'melody') {
|
if (phrase.material === 'melody') {
|
||||||
const result = generateMelody({
|
const result = generateMelody({
|
||||||
keyTonic: phrase.keyTonic,
|
keyTonic: pf.keyTonic,
|
||||||
keyMode: (isMode(phrase.keyMode) ? phrase.keyMode : 'major') as ModeId,
|
keyMode: (isMode(pf.keyMode) ? pf.keyMode : 'major') as ModeId,
|
||||||
bars: phrase.bars,
|
bars: phrase.bars,
|
||||||
meter: { numerator: phrase.meterNumerator, denominator: 4 },
|
meter: { numerator: phrase.meterNumerator, denominator: 4 },
|
||||||
rhythmLevel: phrase.rhythmLevel,
|
rhythmLevel: phrase.rhythmLevel,
|
||||||
@@ -184,8 +167,8 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
}
|
}
|
||||||
if (phrase.material === 'scale') {
|
if (phrase.material === 'scale') {
|
||||||
return generateScaleDrill({
|
return generateScaleDrill({
|
||||||
keyTonic: phrase.keyTonic,
|
keyTonic: pf.keyTonic,
|
||||||
keyMode: (isMode(phrase.keyMode) ? phrase.keyMode : 'major') as ModeId,
|
keyMode: (isMode(pf.keyMode) ? pf.keyMode : 'major') as ModeId,
|
||||||
direction: phrase.scaleDirection,
|
direction: phrase.scaleDirection,
|
||||||
coverage: phrase.scaleCoverage,
|
coverage: phrase.scaleCoverage,
|
||||||
meter: { numerator: phrase.meterNumerator, denominator: 4 },
|
meter: { numerator: phrase.meterNumerator, denominator: 4 },
|
||||||
@@ -196,8 +179,8 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
// Meter is auto-derived inside the generator from the figure
|
// Meter is auto-derived inside the generator from the figure
|
||||||
// length (always eighths) — the user no longer picks a meter.
|
// length (always eighths) — the user no longer picks a meter.
|
||||||
return generateGiulianiStudy({
|
return generateGiulianiStudy({
|
||||||
keyTonic: phrase.keyTonic,
|
keyTonic: pf.keyTonic,
|
||||||
keyMode: (isMode(phrase.keyMode) ? phrase.keyMode : 'major') as ModeId,
|
keyMode: (isMode(pf.keyMode) ? pf.keyMode : 'major') as ModeId,
|
||||||
pattern: phrase.giulianiPattern,
|
pattern: phrase.giulianiPattern,
|
||||||
tuningId: settings.tuningId,
|
tuningId: settings.tuningId,
|
||||||
bars: phrase.giulianiBars,
|
bars: phrase.giulianiBars,
|
||||||
@@ -209,8 +192,8 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
}
|
}
|
||||||
if (phrase.material === 'arpeggio') {
|
if (phrase.material === 'arpeggio') {
|
||||||
return generateArpeggio({
|
return generateArpeggio({
|
||||||
keyTonic: phrase.keyTonic,
|
keyTonic: pf.keyTonic,
|
||||||
keyMode: (isMode(phrase.keyMode) ? phrase.keyMode : 'major') as ModeId,
|
keyMode: (isMode(pf.keyMode) ? pf.keyMode : 'major') as ModeId,
|
||||||
degree: (phrase.arpeggioDegree as ArpeggioDegree) || 'I',
|
degree: (phrase.arpeggioDegree as ArpeggioDegree) || 'I',
|
||||||
pattern: phrase.arpeggioPattern,
|
pattern: phrase.arpeggioPattern,
|
||||||
coverage: phrase.arpeggioCoverage,
|
coverage: phrase.arpeggioCoverage,
|
||||||
@@ -231,7 +214,7 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
return { ok: true, value: importedScore };
|
return { ok: true, value: importedScore };
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}, [phrase.material, phrase.keyTonic, phrase.keyMode, phrase.bars, phrase.meterNumerator,
|
}, [phrase.material, pf.keyTonic, pf.keyMode, phrase.bars, phrase.meterNumerator,
|
||||||
phrase.rhythmLevel, phrase.scaleDirection, phrase.scaleCoverage, phrase.scaleRhythm, phrase.libraryId,
|
phrase.rhythmLevel, phrase.scaleDirection, phrase.scaleCoverage, phrase.scaleRhythm, phrase.libraryId,
|
||||||
phrase.arpeggioDegree, phrase.arpeggioPattern, phrase.arpeggioCoverage,
|
phrase.arpeggioDegree, phrase.arpeggioPattern, phrase.arpeggioCoverage,
|
||||||
phrase.arpeggioBars, phrase.arpeggioProgression,
|
phrase.arpeggioBars, phrase.arpeggioProgression,
|
||||||
@@ -355,11 +338,11 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
|
|
||||||
const hintPositions = useMemo(() => {
|
const hintPositions = useMemo(() => {
|
||||||
if (!settings.showHint || !currentInstrumentDef.showTuning || !currentTuning || currentMidi === null) return [];
|
if (!settings.showHint || !currentInstrumentDef.showTuning || !currentTuning || currentMidi === null) return [];
|
||||||
if (phrase.fretWindowEnabled) {
|
if (pf.fretWindowEnabled) {
|
||||||
return positionsWithinWindow(currentMidi, currentTuning, phrase.fretMin, phrase.fretMax);
|
return positionsWithinWindow(currentMidi, currentTuning, pf.fretMin, pf.fretMax);
|
||||||
}
|
}
|
||||||
return getFretboardPositions(currentMidi, currentTuning);
|
return getFretboardPositions(currentMidi, currentTuning);
|
||||||
}, [settings.showHint, currentInstrumentDef, currentTuning, currentMidi, phrase.fretWindowEnabled, phrase.fretMin, phrase.fretMax]);
|
}, [settings.showHint, currentInstrumentDef, currentTuning, currentMidi, pf.fretWindowEnabled, pf.fretMin, pf.fretMax]);
|
||||||
|
|
||||||
const handleVirtualPlay = useCallback((midi: number) => {
|
const handleVirtualPlay = useCallback((midi: number) => {
|
||||||
if (!settings.virtualGuitarMute) {
|
if (!settings.virtualGuitarMute) {
|
||||||
@@ -579,11 +562,7 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
{(phrase.material === 'melody' || phrase.material === 'scale' || phrase.material === 'arpeggio') && (
|
{(phrase.material === 'melody' || phrase.material === 'scale' || phrase.material === 'arpeggio') && null}
|
||||||
<span style={{ fontSize: '11px', opacity: 0.7, alignSelf: 'center' }}>
|
|
||||||
Key/mode: use the "Target key" controls below the sheet — shared across modes.
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{phrase.material === 'melody' && (
|
{phrase.material === 'melody' && (
|
||||||
<>
|
<>
|
||||||
@@ -799,11 +778,7 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{fretted && (
|
{fretted && null}
|
||||||
<span style={{ fontSize: '11px', opacity: 0.7, alignSelf: 'center' }}>
|
|
||||||
Fret window: use the "Fret window" controls below the sheet — shared across modes.
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Pace lives in the metronome widget now:
|
{/* Pace lives in the metronome widget now:
|
||||||
'Sync to exercise' checked = tempo pace,
|
'Sync to exercise' checked = tempo pace,
|
||||||
@@ -816,11 +791,6 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
/>
|
/>
|
||||||
Virtual input only
|
Virtual input only
|
||||||
</label>
|
</label>
|
||||||
{phrase.pace === 'tempo' && (
|
|
||||||
<span style={{ fontSize: '11px', opacity: 0.7, alignSelf: 'center' }}>
|
|
||||||
BPM + click: on the metronome widget below.
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<label className="phrase-check">
|
<label className="phrase-check">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@@ -839,7 +809,7 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{phrase.pace === 'tempo' && (
|
{phrase.pace === 'tempo' && (
|
||||||
<p className="phrase-note">The run clicks a full count-in bar, then one click per beat. The metronome pendulum mirrors these beats — set the tempo on the metronome tool.</p>
|
<p className="phrase-note">Tempo and click sound live on the metronome tool (Sync checked = the run sets the pace; unchecked = play at your own pace with a free metronome).</p>
|
||||||
)}
|
)}
|
||||||
<p className="phrase-note">
|
<p className="phrase-note">
|
||||||
Matching checks pitch, not fingering — several fretboard positions produce the same pitch.
|
Matching checks pitch, not fingering — several fretboard positions produce the same pitch.
|
||||||
@@ -878,7 +848,7 @@ export const PhraseTrainer = forwardRef<PhraseHandle, PhraseTrainerProps>(
|
|||||||
onPlayNote={handleVirtualPlay}
|
onPlayNote={handleVirtualPlay}
|
||||||
onHover={setHoveredMidi}
|
onHover={setHoveredMidi}
|
||||||
showHints={settings.showHint}
|
showHints={settings.showHint}
|
||||||
maxFrets={Math.max(15, phrase.fretWindowEnabled ? phrase.fretMax + 1 : 0)}
|
maxFrets={Math.max(15, pf.fretWindowEnabled ? pf.fretMax + 1 : 0)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,8 +1,32 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { X, Volume2, VolumeX, ChevronDown, ChevronUp, Mic, MicOff, Sun, Moon, Monitor, Clock } from 'lucide-react';
|
import { X, Volume2, VolumeX, ChevronDown, ChevronUp, Mic, MicOff, Sun, Moon, Monitor, Clock, Guitar } from 'lucide-react';
|
||||||
import type { AppSettings } from '../types/SettingsTypes';
|
import type { AppSettings } from '../types/SettingsTypes';
|
||||||
import { MIC_SENSITIVITY_DB_RANGE, MIC_DEFAULT_SENSITIVITY } from '../AppConfig';
|
import { MIC_SENSITIVITY_DB_RANGE, MIC_DEFAULT_SENSITIVITY } from '../AppConfig';
|
||||||
import type { MicrophoneDebugInfo } from '../hooks/usePitchDetector';
|
import type { MicrophoneDebugInfo } from '../hooks/usePitchDetector';
|
||||||
|
import { TUNINGS, INSTRUMENT_TUNINGS } from '../music/Tunings';
|
||||||
|
import { INSTRUMENT_DEFINITIONS } from '../music/InstrumentConfigs';
|
||||||
|
|
||||||
|
/** Collapsible settings section. First section open by default. */
|
||||||
|
const Section: React.FC<{ title: string; defaultOpen?: boolean; children: React.ReactNode }> = ({ title, defaultOpen = false, children }) => {
|
||||||
|
const [open, setOpen] = useState(defaultOpen);
|
||||||
|
return (
|
||||||
|
<div style={{ borderBottom: '1px solid color-mix(in srgb, var(--color-text-main) 10%, transparent)' }}>
|
||||||
|
<button
|
||||||
|
onClick={() => setOpen(o => !o)}
|
||||||
|
style={{
|
||||||
|
width: '100%', background: 'transparent', border: 'none', color: 'inherit',
|
||||||
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
||||||
|
padding: '14px 0', cursor: 'pointer', font: 'inherit'
|
||||||
|
}}
|
||||||
|
aria-expanded={open}
|
||||||
|
>
|
||||||
|
<span style={{ fontSize: '15px', fontWeight: 600 }}>{title}</span>
|
||||||
|
{open ? <ChevronUp size={16} style={{ opacity: 0.6 }} /> : <ChevronDown size={16} style={{ opacity: 0.6 }} />}
|
||||||
|
</button>
|
||||||
|
{open && <div style={{ paddingBottom: '20px' }}>{children}</div>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
interface SettingsModalProps {
|
interface SettingsModalProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@@ -78,7 +102,52 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
|
|||||||
<div className="help-popup-overlay" onClick={onClose}>
|
<div className="help-popup-overlay" onClick={onClose}>
|
||||||
<div className="help-popup" onClick={e => e.stopPropagation()}>
|
<div className="help-popup" onClick={e => e.stopPropagation()}>
|
||||||
<button className="help-close" onClick={onClose}><X size={20} /></button>
|
<button className="help-close" onClick={onClose}><X size={20} /></button>
|
||||||
<h2 style={{ marginTop: 0, marginBottom: '24px' }}>Settings</h2>
|
<h2 style={{ marginTop: 0, marginBottom: '12px' }}>Settings</h2>
|
||||||
|
|
||||||
|
{/* Instrument & Tuning (rarely changed — lives here now) */}
|
||||||
|
<Section title="Instrument" defaultOpen>
|
||||||
|
<div className="control-group" style={{ marginBottom: '16px' }}>
|
||||||
|
<label className="control-label" style={{ marginBottom: '8px', fontSize: '16px' }}>
|
||||||
|
<Guitar size={18} />
|
||||||
|
<span>Instrument</span>
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
value={settings.instrument}
|
||||||
|
onChange={(e) => {
|
||||||
|
const id = e.target.value;
|
||||||
|
const def = INSTRUMENT_DEFINITIONS[id];
|
||||||
|
let tuningId = settings.tuningId;
|
||||||
|
if (def.showTuning && INSTRUMENT_TUNINGS[id as 'guitar' | 'bass']) {
|
||||||
|
tuningId = INSTRUMENT_TUNINGS[id as 'guitar' | 'bass'][0];
|
||||||
|
}
|
||||||
|
onUpdateSettings({ ...settings, instrument: id, difficulty: def.ranges[0].id, tuningId });
|
||||||
|
}}
|
||||||
|
className="control-select"
|
||||||
|
>
|
||||||
|
{Object.values(INSTRUMENT_DEFINITIONS).map(def => (
|
||||||
|
<option key={def.id} value={def.id}>{def.displayName}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{INSTRUMENT_DEFINITIONS[settings.instrument]?.showTuning && INSTRUMENT_TUNINGS[settings.instrument as 'guitar' | 'bass'] && (
|
||||||
|
<div className="control-group">
|
||||||
|
<label className="control-label" style={{ marginBottom: '8px', fontSize: '16px' }}>
|
||||||
|
<span>Tuning</span>
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
value={settings.tuningId}
|
||||||
|
onChange={(e) => onUpdateSettings({ ...settings, tuningId: e.target.value })}
|
||||||
|
className="control-select"
|
||||||
|
>
|
||||||
|
{INSTRUMENT_TUNINGS[settings.instrument as 'guitar' | 'bass'].map(id => (
|
||||||
|
<option key={id} value={id}>{TUNINGS[id]?.name ?? id}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section title="Appearance">
|
||||||
|
|
||||||
{/* Theme Settings */}
|
{/* Theme Settings */}
|
||||||
<div className="control-group" style={{ marginBottom: '24px' }}>
|
<div className="control-group" style={{ marginBottom: '24px' }}>
|
||||||
@@ -119,8 +188,6 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr style={{ borderColor: 'rgba(255,255,255,0.1)', margin: '24px 0' }} />
|
|
||||||
|
|
||||||
{/* Animation Settings */}
|
{/* Animation Settings */}
|
||||||
<div className="control-group" style={{ marginBottom: '24px' }}>
|
<div className="control-group" style={{ marginBottom: '24px' }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '8px' }}>
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '8px' }}>
|
||||||
@@ -140,7 +207,9 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr style={{ borderColor: 'rgba(255,255,255,0.1)', margin: '24px 0' }} />
|
</Section>
|
||||||
|
|
||||||
|
<Section title="Audio" defaultOpen>
|
||||||
|
|
||||||
<div className="control-group" style={{ marginBottom: '24px' }}>
|
<div className="control-group" style={{ marginBottom: '24px' }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '8px' }}>
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '8px' }}>
|
||||||
@@ -261,7 +330,9 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr style={{ borderColor: 'rgba(255,255,255,0.1)', margin: '24px 0' }} />
|
</Section>
|
||||||
|
|
||||||
|
<Section title="Microphone" defaultOpen>
|
||||||
|
|
||||||
{/* Microphone Toggle */}
|
{/* Microphone Toggle */}
|
||||||
<div className="control-group" style={{ marginBottom: '16px' }}>
|
<div className="control-group" style={{ marginBottom: '16px' }}>
|
||||||
@@ -434,6 +505,8 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
</Section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -101,6 +101,35 @@ export const TargetNoteControls: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Display key signature (sheet notation) */}
|
||||||
|
<div className="control-group">
|
||||||
|
<label className="control-label">
|
||||||
|
<span>Key signature (display)</span>
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
value={settings.keySignature}
|
||||||
|
onChange={e => updateSettings(s => ({ ...s, keySignature: e.target.value }))}
|
||||||
|
className="control-select"
|
||||||
|
aria-label="Display key signature"
|
||||||
|
>
|
||||||
|
<optgroup label="Major Keys">
|
||||||
|
<option value="C">C Major</option>
|
||||||
|
<option value="G">G Major</option>
|
||||||
|
<option value="D">D Major</option>
|
||||||
|
<option value="A">A Major</option>
|
||||||
|
<option value="E">E Major</option>
|
||||||
|
<option value="F">F Major</option>
|
||||||
|
<option value="Bb">Bb Major</option>
|
||||||
|
<option value="Eb">Eb Major</option>
|
||||||
|
</optgroup>
|
||||||
|
<optgroup label="Minor Keys">
|
||||||
|
<option value="Am">A Minor</option>
|
||||||
|
<option value="Em">E Minor</option>
|
||||||
|
<option value="Dm">D Minor</option>
|
||||||
|
</optgroup>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Key filter */}
|
{/* Key filter */}
|
||||||
<div className="control-group">
|
<div className="control-group">
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
|
|||||||
@@ -59,24 +59,24 @@
|
|||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root {
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
--color-bg: hsl(30, 20%, 10%);
|
--color-bg: hsl(220, 6%, 10%);
|
||||||
--color-surface: hsl(30, 20%, 15%);
|
--color-surface: hsl(220, 6%, 15%);
|
||||||
--color-text-main: hsl(30, 10%, 90%);
|
--color-text-main: hsl(220, 4%, 90%);
|
||||||
--color-text-muted: hsl(30, 10%, 60%);
|
--color-text-muted: hsl(220, 4%, 60%);
|
||||||
--color-primary: hsl(0, 0%, 90%);
|
--color-primary: hsl(220, 4%, 90%);
|
||||||
--color-primary-dark: hsl(0, 0%, 100%);
|
--color-primary-dark: hsl(220, 4%, 100%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manual Dark Mode Override */
|
/* Manual Dark Mode Override */
|
||||||
html[data-theme="dark"] {
|
html[data-theme="dark"] {
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
--color-bg: hsl(30, 20%, 10%);
|
--color-bg: hsl(220, 6%, 10%);
|
||||||
--color-surface: hsl(30, 20%, 15%);
|
--color-surface: hsl(220, 6%, 15%);
|
||||||
--color-text-main: hsl(30, 10%, 90%);
|
--color-text-main: hsl(220, 4%, 90%);
|
||||||
--color-text-muted: hsl(30, 10%, 60%);
|
--color-text-muted: hsl(220, 4%, 60%);
|
||||||
--color-primary: hsl(0, 0%, 90%);
|
--color-primary: hsl(220, 4%, 90%);
|
||||||
--color-primary-dark: hsl(0, 0%, 100%);
|
--color-primary-dark: hsl(220, 4%, 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manual Light Mode Override */
|
/* Manual Light Mode Override */
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ export interface PhraseSettings {
|
|||||||
material: PhraseMaterial;
|
material: PhraseMaterial;
|
||||||
libraryId: string;
|
libraryId: string;
|
||||||
/** Imported score id (the parsed score lives in component state, session-only). */
|
/** Imported score id (the parsed score lives in component state, session-only). */
|
||||||
keyTonic: string;
|
|
||||||
keyMode: string; // ModeId
|
|
||||||
bars: number; // 1–8 (melodies)
|
bars: number; // 1–8 (melodies)
|
||||||
meterNumerator: 3 | 4 | 6;
|
meterNumerator: 3 | 4 | 6;
|
||||||
rhythmLevel: 1 | 2 | 3;
|
rhythmLevel: 1 | 2 | 3;
|
||||||
@@ -69,10 +67,6 @@ export interface PhraseSettings {
|
|||||||
/** Giuliani study material (own category — voicing-enforced). */
|
/** Giuliani study material (own category — voicing-enforced). */
|
||||||
giulianiPattern: 'pim' | 'pima' | 'pami' | 'aim' | 'pimamim' | 'pmamim' | 'piai' | 'pmami' | 'pimami' | 'pimaia' | 'pimai' | 'pmia' | 'pmim';
|
giulianiPattern: 'pim' | 'pima' | 'pami' | 'aim' | 'pimamim' | 'pmamim' | 'piai' | 'pmami' | 'pimami' | 'pimaia' | 'pimai' | 'pmia' | 'pmim';
|
||||||
giulianiBars: number;
|
giulianiBars: number;
|
||||||
/** Phrase-local fret window (guitar/bass) — overrides the note set. */
|
|
||||||
fretWindowEnabled: boolean;
|
|
||||||
fretMin: number;
|
|
||||||
fretMax: number;
|
|
||||||
/** Practice range for library/import material (1-based, inclusive). */
|
/** Practice range for library/import material (1-based, inclusive). */
|
||||||
startBar: number;
|
startBar: number;
|
||||||
barCount: number;
|
barCount: number;
|
||||||
@@ -95,8 +89,6 @@ export interface PhraseSettings {
|
|||||||
export const DEFAULT_PHRASE_SETTINGS: PhraseSettings = {
|
export const DEFAULT_PHRASE_SETTINGS: PhraseSettings = {
|
||||||
material: 'melody',
|
material: 'melody',
|
||||||
libraryId: '',
|
libraryId: '',
|
||||||
keyTonic: 'C',
|
|
||||||
keyMode: 'major',
|
|
||||||
bars: 2,
|
bars: 2,
|
||||||
meterNumerator: 4,
|
meterNumerator: 4,
|
||||||
rhythmLevel: 1,
|
rhythmLevel: 1,
|
||||||
@@ -111,9 +103,6 @@ export const DEFAULT_PHRASE_SETTINGS: PhraseSettings = {
|
|||||||
arpeggioProgression: 'functional',
|
arpeggioProgression: 'functional',
|
||||||
giulianiPattern: 'pima',
|
giulianiPattern: 'pima',
|
||||||
giulianiBars: 4,
|
giulianiBars: 4,
|
||||||
fretWindowEnabled: false,
|
|
||||||
fretMin: 0,
|
|
||||||
fretMax: 4,
|
|
||||||
startBar: 1,
|
startBar: 1,
|
||||||
barCount: 2,
|
barCount: 2,
|
||||||
pace: 'step',
|
pace: 'step',
|
||||||
|
|||||||
Reference in New Issue
Block a user