debug: add bank count log in noteOn, SpessaSynth play tries then falls back
This commit is contained in:
@@ -208,7 +208,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
playNote: function (note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine) {
|
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 (_initialized && _synthInstance && _currentSfId) {
|
||||||
if (synthEngine) {
|
if (synthEngine) {
|
||||||
const ch = channel !== undefined ? channel : (synthEngine.soundfont_bank === 128 ? 9 : 0);
|
const ch = channel !== undefined ? channel : (synthEngine.soundfont_bank === 128 ? 9 : 0);
|
||||||
@@ -218,10 +219,14 @@
|
|||||||
if (channel === undefined) channel = ch;
|
if (channel === undefined) channel = ch;
|
||||||
}
|
}
|
||||||
if (channel === undefined) channel = 0;
|
if (channel === undefined) channel = 0;
|
||||||
this._playNoteSpessa(note, velocity, durationMs, channel);
|
// Try SpessaSynth, fallback to oscillator on error
|
||||||
return;
|
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);
|
this._playNoteOsc(note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -234,10 +239,10 @@
|
|||||||
const durSec = durationMs / 1000;
|
const durSec = durationMs / 1000;
|
||||||
const doNoteOn = () => {
|
const doNoteOn = () => {
|
||||||
try {
|
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);
|
_synthInstance.noteOn(channel, midiPitch, midiVel);
|
||||||
setTimeout(() => {
|
setTimeout(() => { try { _synthInstance.noteOff(channel, midiPitch); } catch (e) {} }, durSec * 1000);
|
||||||
try { _synthInstance.noteOff(channel, midiPitch); } catch (e) {}
|
|
||||||
}, durSec * 1000);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("[SonicSF] noteOn failed:", e);
|
console.warn("[SonicSF] noteOn failed:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user