fix: SpessaSynth noteOn catches 'No preset found' error, falls back to oscillator

- playNote logs warning when _currentSfId is null (no bank)
- _playNoteSpessa catches noteOn errors, falls back to _playNoteOsc
- Prevents 'No preset found' from breaking playback
This commit is contained in:
2026-07-26 19:46:50 +07:00
parent 91e228ad6a
commit 9cad9f6c95
+9 -2
View File
@@ -172,8 +172,12 @@
playNote: function (note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine) {
if (_initialized && _synthInstance && _currentSfId) {
return this._playNoteSpessa(note, velocity, durationMs, startTime, program, channel, synthEngine);
} else {
if (_initialized && _synthInstance && !_currentSfId) {
console.warn("[SonicSF] No sound bank loaded, using oscillator fallback");
}
return this._playNoteOsc(note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine);
}
return this._playNoteOsc(note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine);
},
_playNoteSpessa: function (note, velocity, durationMs, startTime, program, channel, synthEngine) {
@@ -198,7 +202,10 @@
try {
_synthInstance.noteOn(channel, midiPitch, midiVel);
setTimeout(() => { try { _synthInstance.noteOff(channel, midiPitch); } catch (e) {} }, durSec * 1000);
} catch (e) {}
} catch (e) {
console.warn("[SonicSF] SpessaSynth noteOn failed, falling back to oscillator:", e);
this._playNoteOsc(note, velocity, durationMs, startTime, program, null, channel, synthEngine);
}
};
if (scheduledTime > 0) setTimeout(doNoteOn, scheduledTime * 1000); else doNoteOn();
},