fix: NAM amp level param now controls input drive, JACK period 256, toggle API matching
This commit is contained in:
+37
-13
@@ -79,7 +79,7 @@ FOCUSRITE_PROFILES: dict[str, tuple[str, int, int]] = {
|
||||
# 48 kHz / 64 frames = 1.33 ms buffer → aggressive, may xrun on RPi 4B
|
||||
LATENCY_PROFILES: dict[str, dict] = {
|
||||
"standard": {
|
||||
"period": 128,
|
||||
"period": 256,
|
||||
"nperiods": 2,
|
||||
"rate": 48000,
|
||||
"rt_priority": 70,
|
||||
@@ -415,9 +415,12 @@ class AudioSystem:
|
||||
This is a no-op if jack_connect is unavailable (not in PATH)
|
||||
or if any of the target ports don't exist yet.
|
||||
"""
|
||||
# Mono: duplicate processed signal to both L/R channels
|
||||
# so Scarlett 2i2 headphone jack (which mirrors stereo pair) works.
|
||||
mono_connections = [
|
||||
("system:capture_1", "fx_in:input_0"),
|
||||
("fx_out:output_0", "system:playback_1"),
|
||||
("fx_out:output_0", "system:playback_2"),
|
||||
]
|
||||
stereo_4cm_connections = [
|
||||
("system:capture_1", "fx_in:input_0"),
|
||||
@@ -934,18 +937,33 @@ class JackAudioClient:
|
||||
logger.warning("Failed to connect %s -> %s: %s",
|
||||
sys_port_name, port.name, exc)
|
||||
|
||||
# Connect each playback port to the corresponding system playback
|
||||
# Connect each playback port to the corresponding system playback.
|
||||
# In mono mode (single outport), duplicate to both L/R channels
|
||||
# so Scarlett 2i2 headphone jack (which mirrors stereo pair) works.
|
||||
for i, port in enumerate(self._outports):
|
||||
suffix = f"playback_{i + 1}" if self._output_channels > 1 else "playback_1"
|
||||
sys_port_name = f"system:{suffix}"
|
||||
try:
|
||||
sys_ports = self._client.get_ports(sys_port_name)
|
||||
if sys_ports:
|
||||
self._client.connect(port, sys_ports[0])
|
||||
logger.debug("Connected %s -> %s", port.name, sys_port_name)
|
||||
except Exception as exc:
|
||||
logger.warning("Failed to connect %s -> %s: %s",
|
||||
port.name, sys_port_name, exc)
|
||||
if self._output_channels == 1:
|
||||
# Mono: connect to both playback_1 and playback_2
|
||||
for ch in [1, 2]:
|
||||
sys_port_name = f"system:playback_{ch}"
|
||||
try:
|
||||
sys_ports = self._client.get_ports(sys_port_name)
|
||||
if sys_ports:
|
||||
self._client.connect(port, sys_ports[0])
|
||||
logger.debug("Mono: connected %s -> %s", port.name, sys_port_name)
|
||||
except Exception as exc:
|
||||
logger.warning("Failed to connect %s -> %s: %s",
|
||||
port.name, sys_port_name, exc)
|
||||
else:
|
||||
suffix = f"playback_{i + 1}"
|
||||
sys_port_name = f"system:{suffix}"
|
||||
try:
|
||||
sys_ports = self._client.get_ports(sys_port_name)
|
||||
if sys_ports:
|
||||
self._client.connect(port, sys_ports[0])
|
||||
logger.debug("Connected %s -> %s", port.name, sys_port_name)
|
||||
except Exception as exc:
|
||||
logger.warning("Failed to connect %s -> %s: %s",
|
||||
port.name, sys_port_name, exc)
|
||||
|
||||
# ── Runtime reconfiguration ────────────────────────────────────
|
||||
|
||||
@@ -983,6 +1001,9 @@ class JackAudioClient:
|
||||
for ch in range(self._input_channels):
|
||||
port_buf = self._inports[ch].get_array()
|
||||
self._in_buf[ch, :frames] = port_buf[:frames]
|
||||
# DEBUG: always log
|
||||
import os
|
||||
os.system('echo "CB frames=' + str(frames) + '" >> /tmp/debug_audio.log')
|
||||
|
||||
# ── Run through pipeline ─────────────────────────────────
|
||||
if self._input_channels == 1:
|
||||
@@ -992,8 +1013,11 @@ class JackAudioClient:
|
||||
|
||||
try:
|
||||
audio_out = self._pipeline.process(audio_in)
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
# Never let an exception escape the RT callback
|
||||
logger.error("Pipeline error: %s", str(exc))
|
||||
import traceback
|
||||
logger.error("Traceback:\n%s", traceback.format_exc())
|
||||
audio_out = np.zeros(frames, dtype=np.float32) if self._output_channels == 1 else \
|
||||
np.zeros((self._output_channels, frames), dtype=np.float32)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user