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:
@@ -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 ""
|
||||
|
||||
|
||||
@@ -6130,8 +6130,11 @@ const serializeTracksList = (tracksList, secondsPerBar) => {
|
||||
instrument_id: t.instrumentId || null,
|
||||
instrument_program: t.instrumentProgram !== undefined ? t.instrumentProgram : null,
|
||||
instrument_name: t.instrumentName || null,
|
||||
soundfont_bank: t.soundfont_bank !== undefined ? t.soundfont_bank : null,
|
||||
soundfont_program: t.soundfont_program !== undefined ? t.soundfont_program : null,
|
||||
instrument_source: t.instrument_source || (t.synth_engine ? t.synth_engine.type : null),
|
||||
soundfont_id: t.soundfont_id || (t.synth_engine ? t.synth_engine.soundfont_id : null),
|
||||
soundfont_bank: t.soundfont_bank !== undefined ? t.soundfont_bank : (t.synth_engine ? t.synth_engine.soundfont_bank : null),
|
||||
soundfont_program: t.soundfont_program !== undefined ? t.soundfont_program : (t.synth_engine ? t.synth_engine.soundfont_program : null),
|
||||
synth_engine: t.synth_engine || null,
|
||||
items: items
|
||||
};
|
||||
});
|
||||
@@ -6199,8 +6202,11 @@ const deserializeTracksList = (schemaTracks, secondsPerBar, sectionStore) => {
|
||||
instrumentId: t.instrument_id || null,
|
||||
instrumentProgram: t.instrument_program !== null ? t.instrument_program : undefined,
|
||||
instrumentName: t.instrument_name || null,
|
||||
instrument_source: t.instrument_source || null,
|
||||
soundfont_id: t.soundfont_id || null,
|
||||
soundfont_bank: t.soundfont_bank !== null ? t.soundfont_bank : undefined,
|
||||
soundfont_program: t.soundfont_program !== null ? t.soundfont_program : undefined
|
||||
soundfont_program: t.soundfont_program !== null ? t.soundfont_program : undefined,
|
||||
synth_engine: t.synth_engine || null
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user