fix: sfBank/sfProg ReferenceError — move declarations outside closure

This commit is contained in:
2026-07-26 19:41:49 +07:00
parent 09231d9b21
commit 91e228ad6a
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -6501,12 +6501,12 @@ const App = () => {
"Guitar Fret Noise","Breath Noise","Seashore","Bird Tweet","Telephone Ring","Helicopter","Applause","Gunshot"
];
const setTrackInstrumentWithProgram = (trackId, instrumentId, programNumber, displayName, bankNumber) => {
const isSfInstrument = instrumentId && typeof instrumentId === 'string' && instrumentId.startsWith('sf_');
const sfBank = bankNumber !== undefined ? bankNumber : (isSfInstrument ? 0 : undefined);
const sfProg = programNumber !== undefined ? programNumber : undefined;
updateActiveTracks(prev => prev.map(t => {
if (t.id !== trackId) return t;
const hasInstrument = !!instrumentId;
const isSfInstrument = instrumentId && typeof instrumentId === 'string' && instrumentId.startsWith('sf_');
const sfBank = bankNumber !== undefined ? bankNumber : (isSfInstrument ? 0 : undefined);
const sfProg = programNumber !== undefined ? programNumber : undefined;
const instrType = isSfInstrument ? 'soundfont' : (hasInstrument ? 'vst3' : 'default');
const synthEngine = hasInstrument ? {
type: instrType,
@@ -6523,7 +6523,7 @@ const App = () => {
setSynthCategory(null);
setSelectedSoundFontId(null);
// Trigger SpessaSynth load + program change when soundfont instrument selected
if (window.SonicSF && window.SonicSF.selectInstrument && instrumentId && typeof instrumentId === 'string' && instrumentId.startsWith('sf_')) {
if (window.SonicSF && window.SonicSF.selectInstrument && instrumentId && isSfInstrument) {
const sfId = instrumentId.replace('sf_', '');
const ch = sfBank === 128 ? 9 : 0;
window.SonicSF.selectInstrument(ch, sfBank || 0, sfProg || 0, sfId);