FEAT: Plugin Manager folder picker + scan dirs (Windows/macOS), docker .env paths, status bar adaptive tips, DSP Tool vao sub-tab audioclip
- Plugins Manager (Tools menu): Browse folder (Tauri dialog + fallback paste path), Save & Scan VST/SoundFont dirs -> plugin_dirs.json (user override, env la base) - Docker: VST_DIR/SOUNDFONT_DIR/PIANOBK_DIR tu .env/docker-compose mount vao container + env cho engine/celery - Status bar: bo label 'Scroll: Zoom' -> Adaptive tips (prHint + fallback text) - DSP Tool: move vao SUB-TAB editor audioclip (Phase Inv / Swap L/R / Reverse + apply vung chon/ca clip) - Tauri: them tauri-plugin-dialog + dialog:default permission cho folder picker
This commit is contained in:
+89
-4
@@ -16,7 +16,89 @@ router = APIRouter()
|
||||
UPLOAD_SF_DIR = os.path.join(settings.STORAGE_DIR, "soundfonts")
|
||||
os.makedirs(UPLOAD_SF_DIR, exist_ok=True)
|
||||
|
||||
SYSTEM_SF_DIR = "/opt/daw_engine/soundfonts"
|
||||
SYSTEM_SF_DIR = settings.SOUNDFONT_DIR
|
||||
SYSTEM_VST_DIR = settings.VST_DIR
|
||||
|
||||
# User dirs (Windows/macOS — người dùng chọn qua folder picker trong
|
||||
# Plugins Manager). File global (không per-user): desktop app 1 user.
|
||||
PLUGIN_DIRS_FILE = os.path.join(settings.STORAGE_DIR, "plugin_dirs.json")
|
||||
|
||||
def _load_plugin_dirs() -> dict:
|
||||
if os.path.exists(PLUGIN_DIRS_FILE):
|
||||
try:
|
||||
with open(PLUGIN_DIRS_FILE, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except Exception:
|
||||
pass
|
||||
return {}
|
||||
|
||||
def _save_plugin_dirs(dirs: dict):
|
||||
os.makedirs(settings.STORAGE_DIR, exist_ok=True)
|
||||
with open(PLUGIN_DIRS_FILE, "w", encoding="utf-8") as f:
|
||||
json.dump(dirs, f, indent=2)
|
||||
|
||||
def _effective_dirs() -> dict:
|
||||
"""Env/.env (Docker) là base; user dirs (file) override nếu khai báo."""
|
||||
user = _load_plugin_dirs()
|
||||
return {
|
||||
"vst_dir": user.get("vst_dir") or settings.VST_DIR,
|
||||
"soundfont_dir": user.get("soundfont_dir") or settings.SOUNDFONT_DIR,
|
||||
"vst_dir_user_set": bool(user.get("vst_dir")),
|
||||
"soundfont_dir_user_set": bool(user.get("soundfont_dir")),
|
||||
}
|
||||
|
||||
class DirsRequest(BaseModel):
|
||||
vst_dir: Optional[str] = None
|
||||
soundfont_dir: Optional[str] = None
|
||||
|
||||
@router.get("/dirs")
|
||||
async def get_plugin_dirs():
|
||||
return {"success": True, **(_effective_dirs())}
|
||||
|
||||
@router.post("/dirs")
|
||||
async def save_plugin_dirs(req: DirsRequest, current_user: dict = Depends(get_current_user)):
|
||||
enforce_password_changed(current_user)
|
||||
user = _load_plugin_dirs()
|
||||
if req.vst_dir is not None:
|
||||
user["vst_dir"] = req.vst_dir.strip()
|
||||
if req.soundfont_dir is not None:
|
||||
user["soundfont_dir"] = req.soundfont_dir.strip()
|
||||
_save_plugin_dirs(user)
|
||||
return {"success": True, **(_effective_dirs())}
|
||||
|
||||
@router.post("/scan")
|
||||
async def scan_plugin_dirs(background_tasks: BackgroundTasks = None,
|
||||
current_user: dict = Depends(get_current_user)):
|
||||
"""Scan các dir hiệu lực (env + user override): cập nhật catalog
|
||||
soundfont (inspector/scanner) + liệt kê VST. Trả về số lượng tìm thấy."""
|
||||
enforce_password_changed(current_user)
|
||||
dirs = _effective_dirs()
|
||||
vst_dir = dirs["vst_dir"]
|
||||
sf_dir = dirs["soundfont_dir"]
|
||||
# SoundFont: quét + inspect vào catalog (scan_once dùng dir hiệu lực)
|
||||
scanner = SoundFontAutoScanner(system_sf_dir=sf_dir, upload_sf_dir=UPLOAD_SF_DIR)
|
||||
if background_tasks:
|
||||
background_tasks.add_task(scanner.scan_once)
|
||||
else:
|
||||
scanner.scan_once()
|
||||
catalog = scanner.get_catalog()
|
||||
# VST: liệt kê thư mục (walk .vst3/.so)
|
||||
vst_found = []
|
||||
if os.path.isdir(vst_dir):
|
||||
for root, _dirs, files in os.walk(vst_dir):
|
||||
for f in files:
|
||||
if f.endswith(".vst3") or f.endswith(".so") or f.endswith(".dll"):
|
||||
vst_found.append({"name": os.path.splitext(f)[0],
|
||||
"path": os.path.join(root, f),
|
||||
"type": "VST3" if f.endswith(".vst3") else "VST2"})
|
||||
return {
|
||||
"success": True,
|
||||
"vst_dir": vst_dir,
|
||||
"soundfont_dir": sf_dir,
|
||||
"vst_found": vst_found,
|
||||
"vst_count": len(vst_found),
|
||||
"soundfont_count": len(catalog),
|
||||
}
|
||||
|
||||
_inspector = None
|
||||
_scanner = None
|
||||
@@ -24,20 +106,23 @@ _scanner = None
|
||||
def get_inspector():
|
||||
global _inspector
|
||||
if _inspector is None:
|
||||
_inspector = SoundFontInspector(system_sf_dir=SYSTEM_SF_DIR, upload_sf_dir=UPLOAD_SF_DIR)
|
||||
d = _effective_dirs()
|
||||
_inspector = SoundFontInspector(system_sf_dir=d["soundfont_dir"], upload_sf_dir=UPLOAD_SF_DIR)
|
||||
return _inspector
|
||||
|
||||
def get_scanner():
|
||||
global _scanner
|
||||
if _scanner is None:
|
||||
_scanner = SoundFontAutoScanner(system_sf_dir=SYSTEM_SF_DIR, upload_sf_dir=UPLOAD_SF_DIR)
|
||||
d = _effective_dirs()
|
||||
_scanner = SoundFontAutoScanner(system_sf_dir=d["soundfont_dir"], upload_sf_dir=UPLOAD_SF_DIR)
|
||||
_scanner.scan_once()
|
||||
return _scanner
|
||||
|
||||
|
||||
@router.get("/available")
|
||||
async def list_plugins(current_user: dict = Depends(get_current_user)):
|
||||
pm = PluginManager(upload_sf_dir=UPLOAD_SF_DIR)
|
||||
d = _effective_dirs()
|
||||
pm = PluginManager(vst_dir=d["vst_dir"], sf_dir=d["soundfont_dir"], upload_sf_dir=UPLOAD_SF_DIR)
|
||||
return pm.list_available()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user