mirror of
https://github.com/9x/sheetmusictrainer.git
synced 2026-09-02 09:34:33 +02:00
Fix pitch detection frequency ranges
This commit is contained in:
16
src/App.tsx
16
src/App.tsx
@@ -69,6 +69,14 @@ function App() {
|
|||||||
const currentTuning = TUNINGS[settings.tuningId];
|
const currentTuning = TUNINGS[settings.tuningId];
|
||||||
const currentInstrumentDef = INSTRUMENT_DEFINITIONS[settings.instrument];
|
const currentInstrumentDef = INSTRUMENT_DEFINITIONS[settings.instrument];
|
||||||
|
|
||||||
|
// Resolve overrides
|
||||||
|
const currentRangeDef = useMemo(() => {
|
||||||
|
return currentInstrumentDef.ranges.find(r => r.id === settings.difficulty);
|
||||||
|
}, [currentInstrumentDef, settings.difficulty]);
|
||||||
|
|
||||||
|
const activeClef = currentRangeDef?.clef ?? currentInstrumentDef.clefMode;
|
||||||
|
const activeTranspose = currentRangeDef?.transpose ?? currentInstrumentDef.transpose;
|
||||||
|
|
||||||
// Generate valid notes based on difficulty
|
// Generate valid notes based on difficulty
|
||||||
const validNotes = useMemo(() => {
|
const validNotes = useMemo(() => {
|
||||||
// Find range config
|
// Find range config
|
||||||
@@ -423,10 +431,10 @@ function App() {
|
|||||||
targetMidi={targetMidi}
|
targetMidi={targetMidi}
|
||||||
playedMidi={virtualNote ?? pitchData?.midi}
|
playedMidi={virtualNote ?? pitchData?.midi}
|
||||||
keySignature={settings.keySignature}
|
keySignature={settings.keySignature}
|
||||||
clef={currentInstrumentDef.clefMode}
|
clef={activeClef}
|
||||||
transpose={currentInstrumentDef.transpose}
|
transpose={activeTranspose}
|
||||||
width={Math.min(window.innerWidth - 40, 500)}
|
width={Math.min(window.innerWidth - 40, 500)}
|
||||||
height={currentInstrumentDef.clefMode === 'grand' ? 260 : 180}
|
height={activeClef === 'grand' ? 260 : 180}
|
||||||
hideTargetNote={settings.gameMode === 'ear_training' && !revealed}
|
hideTargetNote={settings.gameMode === 'ear_training' && !revealed}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -458,7 +466,7 @@ function App() {
|
|||||||
<div className="hint-card">
|
<div className="hint-card">
|
||||||
{settings.showHint && (
|
{settings.showHint && (
|
||||||
<div className="hint-note landscape-hint-note">
|
<div className="hint-note landscape-hint-note">
|
||||||
{getNoteDetails(targetMidi + currentInstrumentDef.transpose).scientific}
|
{getNoteDetails(targetMidi + activeTranspose).scientific}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{currentInstrumentDef.showTuning && currentTuning && (
|
{currentInstrumentDef.showTuning && currentTuning && (
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ export interface NoteSetConfig {
|
|||||||
defaultMinFret?: number;
|
defaultMinFret?: number;
|
||||||
defaultMaxFret?: number;
|
defaultMaxFret?: number;
|
||||||
stringIndex?: number; // 0-based index from lowest string (0) to highest
|
stringIndex?: number; // 0-based index from lowest string (0) to highest
|
||||||
|
transpose?: number; // Override instrument default
|
||||||
|
clef?: ClefMode; // Override instrument default
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InstrumentDefinition {
|
export interface InstrumentDefinition {
|
||||||
@@ -98,17 +100,27 @@ export const INSTRUMENT_DEFINITIONS: Record<string, InstrumentDefinition> = {
|
|||||||
voice: {
|
voice: {
|
||||||
id: 'voice',
|
id: 'voice',
|
||||||
displayName: 'Voice',
|
displayName: 'Voice',
|
||||||
clefMode: 'treble', // Dynamic? Usually vocal music is specific clef OR treble w/ 8va. Let's stick to Treble/Bass per range?
|
clefMode: 'treble', // Default
|
||||||
// Actually, let's keep simple static clef or make App logic handle it.
|
|
||||||
// For now, Voice is usually Treble unless Bass/Baritone.
|
|
||||||
// Let's use Treble by default and maybe switch if range is low.
|
|
||||||
transpose: 0,
|
transpose: 0,
|
||||||
showTuning: false,
|
showTuning: false,
|
||||||
ranges: [
|
ranges: [
|
||||||
{ id: 'soprano', label: 'Soprano (C4-A5)', type: 'static', min: 60, max: 81 },
|
{ id: 'soprano', label: 'Soprano (C4-A5)', type: 'static', min: 60, max: 81 },
|
||||||
{ id: 'alto', label: 'Alto (G3-E5)', type: 'static', min: 55, max: 76 },
|
{ id: 'alto', label: 'Alto (G3-E5)', type: 'static', min: 55, max: 76 },
|
||||||
{ id: 'tenor', label: 'Tenor (C3-A4)', type: 'static', min: 48, max: 69 },
|
{
|
||||||
{ id: 'bass_voice', label: 'Bass (E2-E4)', type: 'static', min: 40, max: 64 }
|
id: 'tenor',
|
||||||
|
label: 'Tenor (C3-A4) [8vb]',
|
||||||
|
type: 'static',
|
||||||
|
min: 48, max: 69,
|
||||||
|
transpose: 12 // Reads Treble, Sounds octave lower.
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'bass_voice',
|
||||||
|
label: 'Bass (E2-E4)',
|
||||||
|
type: 'static',
|
||||||
|
min: 40, max: 64,
|
||||||
|
clef: 'bass', // Override to Bass Clef
|
||||||
|
transpose: 0 // Reads actual pitch on Bass Clef
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
whistle: {
|
whistle: {
|
||||||
|
|||||||
Reference in New Issue
Block a user