phase5: mặc định RENDER_ENGINE=bridge, gỡ pedalboard khỏi requirements/source/LICENSE
- config.py: SF_RENDER_ENGINE default 'bridge' (pedalboard GPL-3.0 đã gỡ)
- requirements.txt: bỏ pedalboard==0.9.19
- vst_engine.py: bỏ HAS_PEDALBOARD/check_pedalboard_safe/load_vst/import pedalboard;
midi_events_to_messages giữ làm utility thuần (không gate pedalboard)
- render_engine.py: bỏ nhánh elif vst and HAS_PEDALBOARD + import thừa
- plugins.py: preview/midi-render chỉ qua native_bridge; guard SF_RENDER_ENGINE=bridge
- runtime.py: _vst_render_available() check bridge exe (SF_BRIDGE_PATH/install/) thay find_spec('pedalboard')
- LICENSE.md/THIRD_PARTY_LICENSES.md: bỏ cảnh báo GPL-3.0 pedalboard, đánh số lại
- tests: bỏ test golden so pedalboard + test requires_pedalboard; 114 passed 0 skip
This commit is contained in:
+7
-38
@@ -6,7 +6,7 @@ import functools
|
||||
import threading
|
||||
from ctypes import c_char_p
|
||||
|
||||
# pedalboard VST3 + pyfluidsynth KHÔNG thread-safe: tuần tự hóa mọi native render
|
||||
# Native render (bridge/pyfluidsynth) không thread-safe: tuần tự hóa
|
||||
RENDER_LOCK = threading.RLock()
|
||||
|
||||
|
||||
@@ -166,14 +166,9 @@ def _module_available(name: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def check_pedalboard_safe():
|
||||
return _module_available("pedalboard")
|
||||
|
||||
|
||||
def check_pyfluidsynth_safe():
|
||||
return _module_available("fluidsynth")
|
||||
|
||||
HAS_PEDALBOARD = check_pedalboard_safe()
|
||||
HAS_PYFLUIDSYNTH = check_pyfluidsynth_safe()
|
||||
|
||||
def ensure_pyfluidsynth():
|
||||
@@ -182,12 +177,6 @@ def ensure_pyfluidsynth():
|
||||
HAS_PYFLUIDSYNTH = check_pyfluidsynth_safe()
|
||||
return HAS_PYFLUIDSYNTH
|
||||
|
||||
if HAS_PEDALBOARD:
|
||||
try:
|
||||
from pedalboard import VST3Plugin, Pedalboard, Gain
|
||||
except Exception:
|
||||
HAS_PEDALBOARD = False
|
||||
|
||||
if HAS_PYFLUIDSYNTH:
|
||||
try:
|
||||
import fluidsynth
|
||||
@@ -221,7 +210,7 @@ def get_plugin_manager(vst_dir=None, sf_dir=None, upload_sf_dir=None) -> "Plugin
|
||||
"""Singleton: reuse PluginManager when args match, else create new.
|
||||
Default dirs từ settings (env/.env/docker-compose hoặc user override).
|
||||
VST scan gộp thêm plugin_dirs user (Plugin Manager) — nút Synth phải liệt
|
||||
kê được VSTi đã scan và load_vst phải tìm thấy chúng khi render."""
|
||||
kê được VSTi đã scan."""
|
||||
from app.config import settings as _st
|
||||
vst_dir = vst_dir or _st.VST_DIR
|
||||
sf_dir = sf_dir or _st.SOUNDFONT_DIR
|
||||
@@ -287,7 +276,7 @@ class PluginManager:
|
||||
self.sf_dir = sf_dir or _st.SOUNDFONT_DIR
|
||||
self.upload_sf_dir = upload_sf_dir
|
||||
# Thư mục VST thêm (plugin_dirs user scan trong Plugin Manager) —
|
||||
# list_available()/load_vst phải thấy VSTi user đã scan (bug: nút
|
||||
# list_available() phải thấy VSTi user đã scan (bug: nút
|
||||
# Synth chỉ quét vst_dir env mặc định /opt/daw_engine/vst3).
|
||||
self.extra_vst_dirs = [d for d in (extra_vst_dirs or []) if d]
|
||||
self._sf_scan_cache = None # cache for _scan_soundfonts()
|
||||
@@ -351,23 +340,6 @@ class PluginManager:
|
||||
}
|
||||
return list(sf_map.values())
|
||||
|
||||
@_render_locked
|
||||
def load_vst(self, plugin_name: str, preset_data: dict = None):
|
||||
if not HAS_PEDALBOARD:
|
||||
return None
|
||||
plugins = self._scan_plugins()
|
||||
if plugin_name not in plugins:
|
||||
return None
|
||||
path = plugins[plugin_name]
|
||||
vst = VST3Plugin(path)
|
||||
if preset_data:
|
||||
for k, v in preset_data.items():
|
||||
try:
|
||||
setattr(vst, k, v)
|
||||
except Exception:
|
||||
pass
|
||||
return vst
|
||||
|
||||
def _scan_soundfonts_cached(self):
|
||||
if self._sf_scan_cache is not None:
|
||||
return self._sf_scan_cache
|
||||
@@ -475,7 +447,7 @@ class PluginManager:
|
||||
"vst_instruments": [
|
||||
{"id": k, "name": k,
|
||||
"type": "VST3" if p.lower().endswith(".vst3") else "VST2",
|
||||
"has_native_support": HAS_PEDALBOARD}
|
||||
"has_native_support": True}
|
||||
for k, p in plugins.items()
|
||||
],
|
||||
"soundfonts": self._scan_soundfonts()
|
||||
@@ -483,12 +455,9 @@ class PluginManager:
|
||||
|
||||
@staticmethod
|
||||
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)
|
||||
# pedalboard >= 0.9: MIDI messages là tuple (bytes, timestamp_seconds)
|
||||
# (MidiMessage class đã bị bỏ). bytes là raw MIDI event:
|
||||
# 0x9n note_on, 0x8n note_off, 0xB0 control_change, 0xC0 program_change
|
||||
# MIDI message = (bytes raw MIDI, timestamp_seconds). bytes là raw MIDI
|
||||
# event: 0x9n note_on, 0x8n note_off, 0xB0 control_change, 0xC0 program_change
|
||||
messages = []
|
||||
if bank is not None:
|
||||
messages.append((bytes([0xB0, 0, int(bank) & 0x7F]), 0.0))
|
||||
@@ -607,7 +576,7 @@ def resolve_plugin_path(name_or_path: str, ext: str = "") -> str:
|
||||
return ""
|
||||
|
||||
def apply_preset_to_plugin(plugin, preset_id=None, preset_path=None, preset_data_b64=None) -> bool:
|
||||
"""Gán preset lên plugin pedalboard: bytes nhúng (base64 .vstpreset) ưu
|
||||
"""Gán preset lên plugin VSTi: bytes nhúng (base64 .vstpreset) ưu
|
||||
tiên, sau đó preset_id (thư viện), sau preset_path (file). Trả True nếu
|
||||
áp dụng được; KHÔNG raise (render engine chỉ log warning)."""
|
||||
if plugin is None:
|
||||
|
||||
Reference in New Issue
Block a user