fix: keep all banks loaded, don't delete on switch

- Remove deleteSoundBank — SpessaSynth merges presets from all banks
- Check soundBankList for existing bank before re-downloading
- Handle 404 gracefully — warn but don't break subsequent loads
- Failed load doesn't delete previously loaded banks
This commit is contained in:
2026-07-26 22:03:49 +07:00
parent 0f5f494173
commit 45a86f09bd
+10 -5
View File
@@ -63,17 +63,22 @@
loadSoundFont: async function (sfId) {
if (!_initialized || !_synthInstance) return false;
if (_currentSfId === sfId) return true;
// Check if already loaded (SpessaSynth can hold multiple banks)
const already = _synthInstance.soundBankManager?.soundBankList?.some(b => b.id === sfId);
if (already) {
_currentSfId = sfId;
return true;
}
try {
// Unload previous SoundFont
if (_currentSfId) {
try { _synthInstance.soundBankManager.deleteSoundBank(_currentSfId); } catch (e) {}
}
const cache = window.SonicSFStorage;
let buf = cache ? await cache.getBuffer(sfId) : null;
if (!buf) {
const url = "/api/v1/plugins/soundfonts/download/" + encodeURIComponent(sfId) + "?t=" + Date.now();
const resp = await fetch(url);
if (!resp.ok) return false;
if (!resp.ok) {
console.warn("[SonicSF] SoundFont not found on server:", sfId);
return false;
}
buf = await resp.arrayBuffer();
if (cache) await cache.saveBuffer(sfId, buf);
}