Sync NAM engine block_size with JACK period on profile switch
- Add FastNAMHost.set_block_size() — reloads current model with new block_size, keeping the engine in sync with JACK's period - Wire into POST /api/audio/profile so NAM engine restarts with correct frame count when switching between standard/low/stable - Prevents sample-alignment drift when JACK period changes but NAM engine stays at old block_size (was causing passthrough)
This commit is contained in:
@@ -93,6 +93,19 @@ class FastNAMHost:
|
|||||||
return 0.0
|
return 0.0
|
||||||
return self._engine.avg_inference_ms
|
return self._engine.avg_inference_ms
|
||||||
|
|
||||||
|
@property
|
||||||
|
def block_size(self) -> int:
|
||||||
|
return self._block_size
|
||||||
|
|
||||||
|
def set_block_size(self, block_size: int) -> None:
|
||||||
|
"""Update block size. Reloads current model if loaded."""
|
||||||
|
if block_size == self._block_size:
|
||||||
|
return
|
||||||
|
self._block_size = block_size
|
||||||
|
if self._loaded_path:
|
||||||
|
logger.info("Block size changed to %d — reloading model %s", block_size, self._loaded_path)
|
||||||
|
self.load_model(self._loaded_path)
|
||||||
|
|
||||||
# ── Model loading ──────────────────────────────────────────────
|
# ── Model loading ──────────────────────────────────────────────
|
||||||
|
|
||||||
def load_model(self, model_path: str) -> bool:
|
def load_model(self, model_path: str) -> bool:
|
||||||
|
|||||||
@@ -1361,6 +1361,10 @@ class WebServer:
|
|||||||
# Restart JACK audio client
|
# Restart JACK audio client
|
||||||
if jack_client:
|
if jack_client:
|
||||||
jack_client.start()
|
jack_client.start()
|
||||||
|
# Sync NAM engine block size with new period
|
||||||
|
nam_host = self.deps.nam_host
|
||||||
|
if nam_host and hasattr(nam_host, 'set_block_size'):
|
||||||
|
nam_host.set_block_size(profile["period"])
|
||||||
await self._manager.broadcast({
|
await self._manager.broadcast({
|
||||||
"type": "audio_profile_changed",
|
"type": "audio_profile_changed",
|
||||||
"profile": profile_key,
|
"profile": profile_key,
|
||||||
|
|||||||
Reference in New Issue
Block a user