fix: piano roll và main session play
This commit is contained in:
@@ -164,6 +164,35 @@ class PluginManager:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def list_soundfont_instruments(self, sf_id: str):
|
||||
if not HAS_PYFLUIDSYNTH:
|
||||
return []
|
||||
dirs = [self.sf_dir]
|
||||
if self.upload_sf_dir:
|
||||
dirs.append(self.upload_sf_dir)
|
||||
for d in dirs:
|
||||
for f in os.listdir(d):
|
||||
base = os.path.splitext(f)[0]
|
||||
if base == sf_id or base == sf_id.replace("sf_", ""):
|
||||
path = os.path.join(d, f)
|
||||
try:
|
||||
fl = fluidsynth.FluidSynth(sample_rate=44100, gain=0.2)
|
||||
fid = fl.sfload(path)
|
||||
count = fl.sfont_get_preset_count(fid)
|
||||
presets = []
|
||||
for pi in range(count):
|
||||
try:
|
||||
name = fl.sfont_get_preset_name(fid, pi)
|
||||
bank, prog = fl.sfont_get_preset_bank_num(fid, pi), fl.sfont_get_preset_prog_num(fid, pi)
|
||||
presets.append({"bank": bank, "program": prog, "name": name})
|
||||
except Exception:
|
||||
pass
|
||||
fl.delete()
|
||||
return presets
|
||||
except Exception:
|
||||
pass
|
||||
return []
|
||||
|
||||
def list_available(self) -> dict:
|
||||
return {
|
||||
"vst_instruments": [
|
||||
|
||||
Reference in New Issue
Block a user