FIX: sửa lỗi không load instrument của soundfont trên window
This commit is contained in:
@@ -35,6 +35,21 @@ def _find_sf2_path(sf_id: str) -> str:
|
||||
fbase, fext = os.path.splitext(fname)
|
||||
if fext.lower() in (".sf2", ".sf3") and (fbase.lower() == clean_lower or fbase.lower() == sf_lower):
|
||||
return os.path.join(base_dir, fname)
|
||||
# Thư mục user thêm qua Plugin Manager (plugin_dirs — Add Directory):
|
||||
# soundfont trong thư mục user phải render được (Windows thường dùng cách này)
|
||||
try:
|
||||
from app.core.vst_engine import _load_user_plugin_dirs
|
||||
for base_dir in _load_user_plugin_dirs():
|
||||
if not os.path.isdir(base_dir):
|
||||
continue
|
||||
for root, dirs, files in os.walk(base_dir):
|
||||
for fname in files:
|
||||
fbase, fext = os.path.splitext(fname)
|
||||
if fext.lower() in (".sf2", ".sf3") and (fbase.lower() == clean_lower or fbase.lower() == sf_lower):
|
||||
return os.path.join(root, fname)
|
||||
dirs[:] = [] # không walk sâu
|
||||
except Exception:
|
||||
pass
|
||||
static_dir = os.path.join(settings.APP_DIR, "static", "soundfonts")
|
||||
if os.path.isdir(static_dir):
|
||||
for fname in os.listdir(static_dir):
|
||||
|
||||
@@ -287,6 +287,12 @@ class PluginManager:
|
||||
search_dirs.append(self.sf_dir)
|
||||
if self.upload_sf_dir and os.path.isdir(self.upload_sf_dir) and self.upload_sf_dir != self.sf_dir:
|
||||
search_dirs.append(self.upload_sf_dir)
|
||||
# Thư mục user thêm qua Plugin Manager (plugin_dirs — chứa cả VST lẫn
|
||||
# SoundFont): nếu không có, instrument của soundfont trong thư mục user
|
||||
# không liệt kê được (bug "nhấn tên SF không thấy instrument").
|
||||
for d in (self.extra_vst_dirs or []):
|
||||
if d and os.path.isdir(d) and d not in search_dirs:
|
||||
search_dirs.append(d)
|
||||
for d in search_dirs:
|
||||
for f in os.listdir(d):
|
||||
if not (f.endswith(".sf2") or f.endswith(".sf3")):
|
||||
|
||||
Reference in New Issue
Block a user