mirror of
https://github.com/9x/sheetmusictrainer.git
synced 2026-09-02 09:34:33 +02:00
Note sets
This commit is contained in:
10
src/App.tsx
10
src/App.tsx
@@ -59,14 +59,20 @@ function App() {
|
|||||||
// Find range config
|
// Find range config
|
||||||
const rangeConfig = currentInstrumentDef.ranges.find(r => r.id === settings.difficulty);
|
const rangeConfig = currentInstrumentDef.ranges.find(r => r.id === settings.difficulty);
|
||||||
|
|
||||||
|
const getNotesFromConfig = (config: typeof rangeConfig) => {
|
||||||
|
if (!config) return [];
|
||||||
|
if (config.notes) return config.notes;
|
||||||
|
return Array.from({ length: config.max - config.min + 1 }, (_, i) => config.min + i);
|
||||||
|
};
|
||||||
|
|
||||||
if (rangeConfig) {
|
if (rangeConfig) {
|
||||||
return Array.from({ length: rangeConfig.max - rangeConfig.min + 1 }, (_, i) => rangeConfig.min + i);
|
return getNotesFromConfig(rangeConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback if difficulty ID doesn't match current instrument (e.g. after switch)
|
// Fallback if difficulty ID doesn't match current instrument (e.g. after switch)
|
||||||
// Return first range of current instrument
|
// Return first range of current instrument
|
||||||
const fallbackRange = currentInstrumentDef.ranges[0];
|
const fallbackRange = currentInstrumentDef.ranges[0];
|
||||||
return Array.from({ length: fallbackRange.max - fallbackRange.min + 1 }, (_, i) => fallbackRange.min + i);
|
return getNotesFromConfig(fallbackRange);
|
||||||
|
|
||||||
}, [settings.difficulty, currentInstrumentDef]);
|
}, [settings.difficulty, currentInstrumentDef]);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Settings, Guitar, Music, Gauge } from 'lucide-react';
|
|||||||
import { TUNINGS, INSTRUMENT_TUNINGS } from '../music/Tunings';
|
import { TUNINGS, INSTRUMENT_TUNINGS } from '../music/Tunings';
|
||||||
import { INSTRUMENT_DEFINITIONS } from '../music/InstrumentConfigs';
|
import { INSTRUMENT_DEFINITIONS } from '../music/InstrumentConfigs';
|
||||||
|
|
||||||
export type Difficulty = 'all' | 'first_pos' | 'open' | 'e_string';
|
export type Difficulty = string;
|
||||||
|
|
||||||
export interface RhythmSettings {
|
export interface RhythmSettings {
|
||||||
mode: 'bpm' | 'seconds';
|
mode: 'bpm' | 'seconds';
|
||||||
@@ -112,7 +112,7 @@ export const Controls: React.FC<ControlsProps> = ({ settings, onUpdateSettings }
|
|||||||
<div className="control-group">
|
<div className="control-group">
|
||||||
<label className="control-label">
|
<label className="control-label">
|
||||||
<Settings size={18} />
|
<Settings size={18} />
|
||||||
<span>Range</span>
|
<span>Note Set</span>
|
||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
value={settings.difficulty}
|
value={settings.difficulty}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ import type { Instrument } from './Tunings';
|
|||||||
|
|
||||||
export type ClefMode = 'treble' | 'bass' | 'grand';
|
export type ClefMode = 'treble' | 'bass' | 'grand';
|
||||||
|
|
||||||
export interface RangeConfig {
|
export interface NoteSetConfig {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string;
|
||||||
min: number; // MIDI number
|
min: number; // MIDI number
|
||||||
max: number; // MIDI number
|
max: number; // MIDI number
|
||||||
|
notes?: number[]; // Explicit list of notes (overrides min/max for generation if present)
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InstrumentDefinition {
|
export interface InstrumentDefinition {
|
||||||
@@ -14,7 +15,7 @@ export interface InstrumentDefinition {
|
|||||||
displayName: string;
|
displayName: string;
|
||||||
clefMode: ClefMode;
|
clefMode: ClefMode;
|
||||||
transpose: number; // Semitones to add to MIDI to get written note (e.g. +12 for guitar)
|
transpose: number; // Semitones to add to MIDI to get written note (e.g. +12 for guitar)
|
||||||
ranges: RangeConfig[];
|
ranges: NoteSetConfig[];
|
||||||
showTuning: boolean;
|
showTuning: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,8 +27,19 @@ export const INSTRUMENT_DEFINITIONS: Record<string, InstrumentDefinition> = {
|
|||||||
transpose: 12, // Guitar sounds octave lower than written, so we add 12 to played midi to show it
|
transpose: 12, // Guitar sounds octave lower than written, so we add 12 to played midi to show it
|
||||||
showTuning: true,
|
showTuning: true,
|
||||||
ranges: [
|
ranges: [
|
||||||
{ id: 'open', label: 'Open Strings', min: 40, max: 64 }, // Dynamic logic handled in App for specific strings, but this is fallback
|
{
|
||||||
{ id: 'first_pos', label: 'First Position', min: 40, max: 44 + 12 }, // Approx
|
id: 'open',
|
||||||
|
label: 'Open Strings',
|
||||||
|
min: 40,
|
||||||
|
max: 64,
|
||||||
|
notes: [40, 45, 50, 55, 59, 64] // E2, A2, D3, G3, B3, E4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'first_pos',
|
||||||
|
label: 'First Position',
|
||||||
|
min: 40,
|
||||||
|
max: 68 // E2 to G#4 (First 4 frets on high E string e(64) -> g#(68))
|
||||||
|
},
|
||||||
{ id: 'all', label: 'All Notes', min: 40, max: 76 }
|
{ id: 'all', label: 'All Notes', min: 40, max: 76 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user