/api/models/load now also updates the current preset's NAM Amp block(s) nam_model_path, so the UI block reflects the loaded model.
This commit is contained in:
+24
-1
@@ -1239,7 +1239,12 @@ class WebServer:
|
|||||||
|
|
||||||
@app.post("/api/models/load")
|
@app.post("/api/models/load")
|
||||||
async def load_model(data: dict, channel: str = "guitar"):
|
async def load_model(data: dict, channel: str = "guitar"):
|
||||||
"""Load a NAM model by path for the given channel."""
|
"""Load a NAM model by path for the given channel.
|
||||||
|
|
||||||
|
Also updates the current preset's NAM Amp block(s) nam_model_path
|
||||||
|
so the block UI reflects the newly loaded model.
|
||||||
|
"""
|
||||||
|
from ..presets.types import Channel
|
||||||
_pm, _pl, nam, _ir = self._channel_deps(channel)
|
_pm, _pl, nam, _ir = self._channel_deps(channel)
|
||||||
if not nam:
|
if not nam:
|
||||||
raise HTTPException(status_code=503)
|
raise HTTPException(status_code=503)
|
||||||
@@ -1250,6 +1255,24 @@ class WebServer:
|
|||||||
if not ok:
|
if not ok:
|
||||||
detail = nam.last_error or "Failed to load model"
|
detail = nam.last_error or "Failed to load model"
|
||||||
raise HTTPException(status_code=422, detail=detail)
|
raise HTTPException(status_code=422, detail=detail)
|
||||||
|
|
||||||
|
# Also update the current preset's NAM Amp blocks to match
|
||||||
|
if _pm is not None:
|
||||||
|
try:
|
||||||
|
bank = _pm.current_bank
|
||||||
|
program = _pm.current_program
|
||||||
|
preset = _pm.load(bank, program, channel=Channel(channel))
|
||||||
|
changed = False
|
||||||
|
for b in preset.chain:
|
||||||
|
if b.fx_type.value == "nam_amp" or b.nam_model_path:
|
||||||
|
if b.nam_model_path != path:
|
||||||
|
b.nam_model_path = path
|
||||||
|
changed = True
|
||||||
|
if changed:
|
||||||
|
_pm.save(preset, channel=Channel(channel))
|
||||||
|
except Exception:
|
||||||
|
logger.warning("Failed to update preset NAM block path", exc_info=True)
|
||||||
|
|
||||||
await self._manager.broadcast({
|
await self._manager.broadcast({
|
||||||
"type": "model_loaded",
|
"type": "model_loaded",
|
||||||
"model": path,
|
"model": path,
|
||||||
|
|||||||
Reference in New Issue
Block a user