feat: add SoundFont inspection engine + AI instrument schema

- SoundFontInspector (sf2utils) scans .sf2, generates full/condensed catalog
- GET /api/v1/plugins/soundfonts/catalog with lazy init + cache invalidation
- AI tool generate_multitrack_midi now requires soundfont_id/bank/program
- Condensed catalog auto-injected into AI system prompt with bank rules
- Server render: FluidSynth program_select uses bank/program + channel routing (drums→ch9)
- VST3 pedalboard path inserts CC0 bank select + program change before notes
- DecentSamplerManager loads .dspreset with CWD fix for relative sample paths
- Pianobook render branch in render_engine.py
- Client SonicSF: controllerChange, programChange, applyAITrackInstrument
- Post-AI track creation applies instrument via applyAITrackInstrument
- Background cache rescan on .sf2 upload, frontend re-fetches catalog
- libcurl4 + VST3 dirs in Dockerfile
This commit is contained in:
2026-07-26 12:36:48 +07:00
parent f16467eba1
commit 89c7237379
12 changed files with 361 additions and 13 deletions
+31 -1
View File
@@ -286,11 +286,15 @@ class PluginManager:
}
@staticmethod
def midi_events_to_messages(midi_events: list, bpm: float, sr: int) -> list:
def midi_events_to_messages(midi_events: list, bpm: float, sr: int, bank: int = None, program: int = None) -> list:
if not HAS_PEDALBOARD:
return []
beat_duration_sec = 60.0 / max(30.0, bpm)
messages = []
if bank is not None:
messages.append(MidiMessage(control_change=0, value=bank, sample_offset=0))
if program is not None:
messages.append(MidiMessage(program_change=program, sample_offset=0))
for ev in midi_events:
note = ev.get("note", 60)
velocity = ev.get("velocity", 100)
@@ -313,3 +317,29 @@ class PluginManager:
if data[8:12] != b'sfbk':
return False
return True
class DecentSamplerManager:
def __init__(self, vst_path="/opt/daw_engine/vst3/DecentSampler.vst3"):
self.vst_path = vst_path
def create_decent_sampler_instance(self, dspreset_path: str):
if not HAS_PEDALBOARD:
raise RuntimeError("pedalboard not available")
if not os.path.exists(self.vst_path):
raise FileNotFoundError(f"DecentSampler VST3 not found at {self.vst_path}")
if not os.path.exists(dspreset_path):
raise FileNotFoundError(f"Preset file not found at {dspreset_path}")
plugin = VST3Plugin(self.vst_path)
abs_preset = os.path.abspath(dspreset_path)
preset_dir = os.path.dirname(abs_preset)
cwd_before = os.getcwd()
try:
os.chdir(preset_dir)
plugin.load_preset(abs_preset)
finally:
os.chdir(cwd_before)
return plugin