From de4caefb50281ee90920c71000cb4501738f6221 Mon Sep 17 00:00:00 2001 From: locphamtran Date: Tue, 25 Aug 2026 17:54:39 +0700 Subject: [PATCH] =?UTF-8?q?fix(preview):=20download=20soundfont=20resolve?= =?UTF-8?q?=20plugin=5Fdirs=20+=20fallback=20default=20GM=20(h=E1=BA=BFt?= =?UTF-8?q?=20oscillator)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/v1/plugins.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/api/v1/plugins.py b/app/api/v1/plugins.py index af3a4ab..310acab 100644 --- a/app/api/v1/plugins.py +++ b/app/api/v1/plugins.py @@ -601,6 +601,16 @@ async def download_soundfont_asset(sf_id: str): except Exception as e: print(f"[soundfont-download] SF3->SF2 conversion failed for {full}: {e}") return FileResponse(full, media_type="application/octet-stream", filename="soundfont.sf3") + # Not found in the 3 standard dirs -> resolve like offline render + # (render_engine._find_sf2_path): scan user plugin_dirs (Downloads...), + # then fall back to default GM font. UI preview must hear the SAME + # instrument as offline; before, 404 -> soundfontPlayer.js played a + # fallback oscillator (synth sound). + resolved = _find_sf2_path(clean_id) + if not resolved or not os.path.exists(resolved): + resolved = _find_default_sf2() + if resolved and os.path.exists(resolved): + return FileResponse(resolved, media_type="application/octet-stream", filename=os.path.basename(resolved)) raise HTTPException(status_code=404, detail="SoundFont asset not found")