fix: clone buffer before addSoundBank, re-await isReady, force program 0

- Clone ArrayBuffer before sendToWorklet (transfer neuters original)
- Re-await synthInstance.isReady after addSoundBank
- Force controllerChange(0,0,0) + programChange(0,0) after load
This commit is contained in:
2026-07-26 18:44:43 +07:00
parent 5096c618b4
commit c884f3c533
+7 -1
View File
@@ -103,7 +103,13 @@
} }
} }
try { try {
await _synthInstance.soundBankManager.addSoundBank(buffer, sfId); // Clone buffer before sending to worklet (avoids transfer neutering)
const bufCopy = buffer.slice(0);
await _synthInstance.soundBankManager.addSoundBank(bufCopy, sfId);
await _synthInstance.isReady;
// Force program 0 on channel 0 to activate loaded bank
this.controllerChange(0, 0, 0);
this.programChange(0, 0);
_currentSfId = sfId; _currentSfId = sfId;
console.log("[SonicSF] SoundFont loaded:", sfId); console.log("[SonicSF] SoundFont loaded:", sfId);
} catch (e) { } catch (e) {