fix: instrument SF3/Sonatina không phát âm thanh - chuyển SF3->SF2, bỏ convert SF2->SF3, sửa converter
This commit is contained in:
@@ -206,16 +206,29 @@
|
||||
try {
|
||||
var cache = window.SonicSFStorage;
|
||||
var buf = cache ? await cache.getBuffer(sfId) : null;
|
||||
if (!buf) {
|
||||
var url = "/api/v1/plugins/soundfonts/download/" + encodeURIComponent(sfId) + "?t=" + Date.now();
|
||||
var resp = await fetch(url);
|
||||
if (!resp.ok) {
|
||||
console.warn("[SonicSF] SoundFont not found:", sfId);
|
||||
return false;
|
||||
if (buf) {
|
||||
var cachedOk = this._tryLoadSFL(buf, '.sf3');
|
||||
if (cachedOk === -1) cachedOk = this._tryLoadSFL(buf, '.sf2');
|
||||
if (cachedOk !== -1) {
|
||||
_sfHandleMap.set(sfId, cachedOk);
|
||||
_currentSfId = sfId;
|
||||
_loadedFonts[sfId] = true;
|
||||
console.log("[SonicSF] SoundFont loaded from cache:", sfId, "handle:", cachedOk);
|
||||
return true;
|
||||
}
|
||||
buf = await resp.arrayBuffer();
|
||||
if (cache) await cache.saveBuffer(sfId, buf);
|
||||
// Stale/corrupt cache (e.g. old SF3 buffers the WASM can't
|
||||
// decode) — drop it and re-download from the server.
|
||||
console.warn("[SonicSF] Cached SoundFont unplayable, re-downloading:", sfId);
|
||||
try { await cache.saveBuffer(sfId, null); } catch (e2) {}
|
||||
}
|
||||
var url = "/api/v1/plugins/soundfonts/download/" + encodeURIComponent(sfId) + "?t=" + Date.now();
|
||||
var resp = await fetch(url);
|
||||
if (!resp.ok) {
|
||||
console.warn("[SonicSF] SoundFont not found:", sfId);
|
||||
return false;
|
||||
}
|
||||
buf = await resp.arrayBuffer();
|
||||
if (cache) await cache.saveBuffer(sfId, buf);
|
||||
var sfHandle = this._tryLoadSFL(buf, '.sf3');
|
||||
if (sfHandle === -1) {
|
||||
console.warn("[SonicSF] sfload .sf3 failed, trying .sf2 for", sfId);
|
||||
|
||||
Reference in New Issue
Block a user