From 6242eba3c8517dd63cb332a2dccaa50b6cbdec77 Mon Sep 17 00:00:00 2001 From: 3dtours Date: Sun, 26 Jul 2026 20:00:17 +0700 Subject: [PATCH] debug: add bank count log in noteOn, SpessaSynth play tries then falls back --- app/static/js/services/soundfontPlayer.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/static/js/services/soundfontPlayer.js b/app/static/js/services/soundfontPlayer.js index cbaf6a2..cb5385a 100644 --- a/app/static/js/services/soundfontPlayer.js +++ b/app/static/js/services/soundfontPlayer.js @@ -208,7 +208,8 @@ }, playNote: function (note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine) { - // SpessaSynth path: only if bank is loaded + // TEMP: always use oscillator for reliable preview + // SpessaSynth path: only when bank is confirmed loaded if (_initialized && _synthInstance && _currentSfId) { if (synthEngine) { const ch = channel !== undefined ? channel : (synthEngine.soundfont_bank === 128 ? 9 : 0); @@ -218,10 +219,14 @@ if (channel === undefined) channel = ch; } if (channel === undefined) channel = 0; - this._playNoteSpessa(note, velocity, durationMs, channel); - return; + // Try SpessaSynth, fallback to oscillator on error + try { + this._playNoteSpessa(note, velocity, durationMs, channel); + return; + } catch (e) { + console.warn("[SonicSF] SpessaSynth play failed, fallback:", e); + } } - // Oscillator fallback this._playNoteOsc(note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine); }, @@ -234,10 +239,10 @@ const durSec = durationMs / 1000; const doNoteOn = () => { try { + const bl = _synthInstance.soundBankManager?.soundBankList?.length ?? 0; + console.log("[SonicSF] noteOn ch", channel, "pitch", midiPitch, "vel", midiVel, "banks:", bl); _synthInstance.noteOn(channel, midiPitch, midiVel); - setTimeout(() => { - try { _synthInstance.noteOff(channel, midiPitch); } catch (e) {} - }, durSec * 1000); + setTimeout(() => { try { _synthInstance.noteOff(channel, midiPitch); } catch (e) {} }, durSec * 1000); } catch (e) { console.warn("[SonicSF] noteOn failed:", e); }