From 9cad9f6c9537305eaf70f41a1bc3f75074299970 Mon Sep 17 00:00:00 2001 From: 3dtours Date: Sun, 26 Jul 2026 19:46:50 +0700 Subject: [PATCH] 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 --- app/static/js/services/soundfontPlayer.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/static/js/services/soundfontPlayer.js b/app/static/js/services/soundfontPlayer.js index 60dd5e2..a6c451e 100644 --- a/app/static/js/services/soundfontPlayer.js +++ b/app/static/js/services/soundfontPlayer.js @@ -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(); },