fix: add init guard, log selectablePresetList count
- Add missing if (_initialized && _synthInstance) return to init() - soundBank is main-thread proxy, worklet has actual presets - Check selectablePresetList.length from soundBankManager (worklet state) - Log when presets are empty (SpessaSynth parser issue)
This commit is contained in:
@@ -64,6 +64,7 @@
|
|||||||
// PHASE 1: Init SpessaSynth
|
// PHASE 1: Init SpessaSynth
|
||||||
// ════════════════════════════════════════════════
|
// ════════════════════════════════════════════════
|
||||||
init: async function (audioContext) {
|
init: async function (audioContext) {
|
||||||
|
if (_initialized && _synthInstance) return;
|
||||||
console.log("[SonicSF][DEBUG] PHASE1: init start");
|
console.log("[SonicSF][DEBUG] PHASE1: init start");
|
||||||
if (!window.SpessaSynthClass || !window.__SpessaSynthCDN) {
|
if (!window.SpessaSynthClass || !window.__SpessaSynthCDN) {
|
||||||
console.warn("[SonicSF][DEBUG] PHASE1: SpessaSynth CDN not available");
|
console.warn("[SonicSF][DEBUG] PHASE1: SpessaSynth CDN not available");
|
||||||
@@ -152,32 +153,15 @@
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
_currentSfId = sfId;
|
_currentSfId = sfId;
|
||||||
const bankCount = _synthInstance.soundBankManager?.soundBankList?.length ?? 0;
|
const bankCount = _synthInstance.soundBankManager?.soundBankList?.length ?? 0;
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: addSoundBank SUCCESS. _currentSfId=" + _currentSfId + " total banks=" + bankCount);
|
const sb = _synthInstance.soundBankManager?.soundBankList?.[0];
|
||||||
// Try to enumerate presets from loaded bank
|
console.log("[SonicSF][DEBUG] PHASE2d: addSoundBank SUCCESS. _currentSfId=" + _currentSfId + " total banks=" + bankCount + " sb_exists=" + !!sb);
|
||||||
try {
|
// soundBank is only stored on the worklet side (not main thread).
|
||||||
const sb = _synthInstance.soundBankManager?.soundBankList?.[0]?.soundBank;
|
// Check selectablePresetList count (proxy for worklet state)
|
||||||
if (sb) {
|
const spl = _synthInstance.soundBankManager?.selectablePresetList?.length ?? 0;
|
||||||
const allKeys = Object.keys(sb);
|
console.log("[SonicSF][DEBUG] PHASE2d: selectablePresetList.length=" + spl);
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: soundBank keys=" + JSON.stringify(allKeys.slice(0, 20)));
|
if (spl === 0) {
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: soundBank.presets length=" + (sb.presets?.length ?? "undefined"));
|
// The bank was registered but presets are empty - parser issue.
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: soundBank.instruments length=" + (sb.instruments?.length ?? "undefined"));
|
console.warn("[SonicSF][DEBUG] PHASE2d: presets EMPTY. SpessaSynth parser couldn't extract presets from SF2.");
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: soundBank.samples length=" + (sb.samples?.length ?? "undefined"));
|
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: soundBank._presetList length=" + (sb._presetList?.length ?? "undefined"));
|
|
||||||
if (sb.presets && sb.presets.length > 0) {
|
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: presets in loaded bank=" + sb.presets.length);
|
|
||||||
for (let i = 0; i < Math.min(sb.presets.length, 10); i++) {
|
|
||||||
const p = sb.presets[i];
|
|
||||||
const pk = Object.keys(p).slice(0, 8);
|
|
||||||
console.log("[SonicSF][DEBUG] PHASE2d: preset[" + i + "] name=" + p.name + " keys=" + JSON.stringify(pk) + " bank=" + p.bankMSB + "/" + p.bankLSB + " prog=" + p.program + " drum=" + p.isGMGSDrum);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.warn("[SonicSF][DEBUG] PHASE2d: soundBank.presets is EMPTY — parser didn't extract presets");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.warn("[SonicSF][DEBUG] PHASE2d: soundBankList[0] is EMPTY");
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("[SonicSF][DEBUG] PHASE2d: preset enumeration failed:", e);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user