fix(engine): case-insensitive SF2 lookup, add synth_engine to serialization

- _find_sf2_path now case-insensitive to match catalog IDs
- serializeTracksList includes synth_engine, soundfont_id, instrument_source
- deserializeTracksList restores synth_engine and soundfont_id
This commit is contained in:
2026-07-26 17:00:28 +07:00
parent d48262d468
commit 280c8f598f
2 changed files with 13 additions and 6 deletions
+4 -3
View File
@@ -24,19 +24,20 @@ SYS_SOUNDFONTS = [
def _find_sf2_path(sf_id: str) -> str:
clean_id = sf_id.replace("sf_", "") if sf_id.startswith("sf_") else sf_id
clean_lower = clean_id.lower()
sf_lower = sf_id.lower()
for base_dir in [UPLOAD_SF_DIR, SYSTEM_SF_DIR]:
if not os.path.isdir(base_dir):
continue
for fname in os.listdir(base_dir):
fbase, fext = os.path.splitext(fname)
if fext.lower() in (".sf2", ".sf3") and (fbase == clean_id or fbase == sf_id):
if fext.lower() in (".sf2", ".sf3") and (fbase.lower() == clean_lower or fbase.lower() == sf_lower):
return os.path.join(base_dir, fname)
# Backward compat: static/soundfonts
static_dir = os.path.join(settings.APP_DIR, "static", "soundfonts")
if os.path.isdir(static_dir):
for fname in os.listdir(static_dir):
fbase, fext = os.path.splitext(fname)
if fext.lower() in (".sf2", ".sf3") and (fbase == clean_id or fbase == sf_id):
if fext.lower() in (".sf2", ".sf3") and (fbase.lower() == clean_lower or fbase.lower() == sf_lower):
return os.path.join(static_dir, fname)
return ""