fix: piano roll tab có thể play với soundfont
This commit is contained in:
+22
-1
@@ -108,12 +108,33 @@ class PluginManager:
|
||||
dirs = [self.sf_dir]
|
||||
if self.upload_sf_dir and self.upload_sf_dir != self.sf_dir:
|
||||
dirs.append(self.upload_sf_dir)
|
||||
|
||||
# Load metadata cache for upload soundfonts
|
||||
meta_cache = {}
|
||||
if self.upload_sf_dir and os.path.isdir(self.upload_sf_dir):
|
||||
for f in os.listdir(self.upload_sf_dir):
|
||||
if f.endswith(".meta"):
|
||||
try:
|
||||
import json
|
||||
with open(os.path.join(self.upload_sf_dir, f), "r") as mf:
|
||||
meta_cache[os.path.splitext(f)[0]] = json.load(mf)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for d in dirs:
|
||||
if not os.path.isdir(d):
|
||||
continue
|
||||
for f in os.listdir(d):
|
||||
if f.endswith(".sf2") or f.endswith(".sf3"):
|
||||
sfonts.append({"id": os.path.splitext(f)[0], "name": f, "file": f})
|
||||
base_id = os.path.splitext(f)[0]
|
||||
meta = meta_cache.get(base_id, None)
|
||||
if meta:
|
||||
display_name = meta.get("original_name", f)
|
||||
else:
|
||||
# Generate a friendly name from UUID: truncate to first 8 chars
|
||||
short_id = base_id[:8] if len(base_id) > 8 else base_id
|
||||
display_name = f"SoundFont_{short_id}"
|
||||
sfonts.append({"id": base_id, "name": display_name, "file": f, "display": os.path.splitext(display_name)[0][:40]})
|
||||
return sfonts
|
||||
|
||||
def load_vst(self, plugin_name: str, preset_data: dict = None):
|
||||
|
||||
Reference in New Issue
Block a user