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:
@@ -63,17 +63,22 @@
|
|||||||
loadSoundFont: async function (sfId) {
|
loadSoundFont: async function (sfId) {
|
||||||
if (!_initialized || !_synthInstance) return false;
|
if (!_initialized || !_synthInstance) return false;
|
||||||
if (_currentSfId === sfId) return true;
|
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 {
|
try {
|
||||||
// Unload previous SoundFont
|
|
||||||
if (_currentSfId) {
|
|
||||||
try { _synthInstance.soundBankManager.deleteSoundBank(_currentSfId); } catch (e) {}
|
|
||||||
}
|
|
||||||
const cache = window.SonicSFStorage;
|
const cache = window.SonicSFStorage;
|
||||||
let buf = cache ? await cache.getBuffer(sfId) : null;
|
let buf = cache ? await cache.getBuffer(sfId) : null;
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
const url = "/api/v1/plugins/soundfonts/download/" + encodeURIComponent(sfId) + "?t=" + Date.now();
|
const url = "/api/v1/plugins/soundfonts/download/" + encodeURIComponent(sfId) + "?t=" + Date.now();
|
||||||
const resp = await fetch(url);
|
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();
|
buf = await resp.arrayBuffer();
|
||||||
if (cache) await cache.saveBuffer(sfId, buf);
|
if (cache) await cache.saveBuffer(sfId, buf);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user