fix: synth để gắn soundfont cho midi

This commit is contained in:
2026-07-23 19:26:26 +07:00
parent 055f351a17
commit a21266736c
7 changed files with 366 additions and 35 deletions
+11 -6
View File
@@ -86,9 +86,10 @@ if HAS_PYFLUIDSYNTH:
class PluginManager:
def __init__(self, vst_dir="/opt/daw_engine/vst3", sf_dir="/opt/daw_engine/soundfonts"):
def __init__(self, vst_dir="/opt/daw_engine/vst3", sf_dir="/opt/daw_engine/soundfonts", upload_sf_dir=None):
self.vst_dir = vst_dir
self.sf_dir = sf_dir
self.upload_sf_dir = upload_sf_dir
def _scan_plugins(self) -> dict:
plugins = {}
@@ -104,11 +105,15 @@ class PluginManager:
def _scan_soundfonts(self) -> list:
sfonts = []
if not os.path.isdir(self.sf_dir):
return sfonts
for f in os.listdir(self.sf_dir):
if f.endswith(".sf2") or f.endswith(".sf3"):
sfonts.append({"id": os.path.splitext(f)[0], "name": f, "file": f})
dirs = [self.sf_dir]
if self.upload_sf_dir and self.upload_sf_dir != self.sf_dir:
dirs.append(self.upload_sf_dir)
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})
return sfonts
def load_vst(self, plugin_name: str, preset_data: dict = None):