fix: locateFile cho FluidSynth WASM module (dùng self-host/CDN)

Module script (type=module) có document.currentScript === null,
nên libfluidsynth không thể tự locate .wasm file. Fix: pass
locateFile() trả về URL .wasm tương ứng với URL .js đã load.

fluidsynthLoader.js: expose __FluidSynthLocateWasm() trả về
FLUIDSYNTH_JS_URL.replace('.js', '.wasm'). Dùng polling
setInterval thay vì resolve callback cho đáng tin cậy hơn.
soundfontPlayer.js: pass locateFile factory khi gọi factory.
This commit is contained in:
2026-07-27 14:48:58 +07:00
parent ef1238b87d
commit e801023beb
2 changed files with 38 additions and 17 deletions
+8 -1
View File
@@ -73,7 +73,14 @@
}
console.log("[SonicSF] Initializing FluidSynth WASM Engine...");
_fluidModule = await window.__FluidSynthModuleFactory();
_fluidModule = await window.__FluidSynthModuleFactory({
locateFile: function (path) {
if (path.endsWith('.wasm')) {
return window.__FluidSynthLocateWasm ? window.__FluidSynthLocateWasm() : path;
}
return path;
}
});
if (!_fluidModule || !_fluidModule._new_fluid_settings) {
throw new Error("FluidSynth WASM module loaded but API missing");