feat: migrate SpessaSynth → FluidSynth WASM (SF3 native, loop Gen 54 fix)

Replace SpessaSynth JS/AudioWorklet with FluidSynth C++ WASM
(@enikey87/fluidsynth-emscripten@0.1.1). CDN for dev, self-host
for prod. Fixes stuck Tremolo/Saxophone notes via compliant
Gen 44 loop mode processing. 100% audio parity with server
pyfluidsynth render (same C++ core).

- soundfontPlayer.js: FluidSynth WASM engine, preserve SonicSF API
- fluidsynthLoader.js: auto-select CDN (dev) vs self-host (prod)
- fluidsynth-bridge.js: PCM bridge AudioWorklet processor
- index.html: remove SpessaSynth importmap + module, add loader
- vendor/: libfluidsynth-2.3.0-sf3.js + .wasm (1.8MB self-host)
This commit is contained in:
2026-07-27 12:48:30 +07:00
parent 81dc9a0354
commit ef1238b87d
7 changed files with 341 additions and 181 deletions
@@ -0,0 +1,23 @@
window.__FluidSynthReady = new Promise(function (resolve) {
var FLUIDSYNTH_SRC;
if (window.__FLUIDSYNTH_CDN) {
FLUIDSYNTH_SRC = window.__FLUIDSYNTH_CDN;
} else if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
FLUIDSYNTH_SRC = 'https://cdn.jsdelivr.net/npm/@enikey87/fluidsynth-emscripten@0.1.1/dist/libfluidsynth-2.3.0-sf3.js';
} else {
FLUIDSYNTH_SRC = '/static/js/vendor/libfluidsynth-2.3.0-sf3.js';
}
var script = document.createElement('script');
script.type = 'module';
script.textContent = [
'import FluidsynthModule from "' + FLUIDSYNTH_SRC + '";',
'window.__FluidSynthModuleFactory = FluidsynthModule;',
'window.__FluidSynthReadyResolver = function() { window.__FluidSynthReadyResolve(); };',
'console.log("[FluidSynth] Loaded from:", "' + FLUIDSYNTH_SRC + '");'
].join('\n');
document.head.appendChild(script);
window.__FluidSynthReadyResolve = resolve;
});