fix: NAM engine stability and hum — post-NAM DC blocker + HPF, warm-before-kill subprocess swap, non-blocking pipe I/O, sample rate sync, arch detection

- Add first-order DC blocker (R=0.999) after NAM processing to kill subsonic offset
- Add 80Hz Butterworth HPF after NAM to catch residual 60/120Hz hum
- Recompute HPF coefficients on sample rate change in set_audio_profile()
- Warm-before-kill: spawn new C++ subprocess before stopping old one (no gap)
- Add background reader thread for non-blocking stdout consumption
- Reuse last known output frame if engine is slow (keeps stream aligned)
- Pass sample_rate to NAMEngineProcess and FastNAMHost constructors
- Forward sample_rate in server.py profile change and main.py init
- Read actual architecture from .nam files instead of hardcoding 'LSTM'
- Add threading.Lock to FastNAMHost for safe engine ref swaps
This commit is contained in:
2026-06-19 14:13:44 -04:00
parent acdff5eb9b
commit 04931fd738
6 changed files with 349 additions and 75 deletions
+3
View File
@@ -1765,6 +1765,9 @@ class WebServer:
nam_host = self.deps.nam_host
if nam_host and hasattr(nam_host, 'set_block_size'):
nam_host.set_block_size(target_profile["period"])
# Sync NAM engine sample rate too
if nam_host and hasattr(nam_host, 'set_sample_rate'):
nam_host.set_sample_rate(target_profile["rate"])
# Sync AudioPipeline block size and sample rate for correct DSP timing
pipeline = self.deps.pipeline