Преглед на файлове

mod-host: plug all inputs

Johan Le Baut преди 1 седмица
родител
ревизия
56c5ee93f4

+ 5 - 5
AGENTS.md

@@ -8,12 +8,12 @@ The current target is Debian GNU/Linux 13 on AArch64 with a Behringer UMC404HD 1
 
 ## Layout and architecture
 
-- `config/desired-state.yaml` is the central YAML description of the intended components, four mono sources, looper channel assignments, mix, the guitar NAM/cabinet chain, mod-host PipeWire boundary ports, planned/forbidden connections, and exact external PipeWire links tracked for observation.
-- `config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf` is a PipeWire filter-chain fragment with four mono mixer inputs, one mono output, and initial gain `0.2` per input. It defines the processing graph and ports, but does not create links to hardware or implement the looper graph.
+- `config/desired-state.yaml` is the central YAML description of the intended components, four mono sources, looper channel assignments, mix, the guitar NAM/cabinet chain, four-channel mod-host PipeWire boundaries, planned/forbidden connections, and exact external PipeWire links tracked for observation.
+- `config/pipewire/filter-chain.conf.d/rigforge-direct-mix.conf` is a PipeWire filter-chain fragment with eight mono mixer inputs (four direct sources and four looper returns), one mono output, and initial gain `0.2` per input. It defines the processing graph and ports, but does not create links to hardware or implement the looper graph.
 - `scripts/validate_desired_state.py` checks the YAML's four-source/physical-input model, single four-channel looper, source-to-channel assignments, mix declaration, and prohibition on routing looper returns back to looper inputs.
 - `scripts/observe_pipewire.py` validates the state and managed endpoint declarations, reads `pw-link -l`, and compares observed links against explicitly managed ports and links. Without `--reconcile-once`, it is read-only; one-shot reconciliation and the separately deployed timer create only declared missing links and remove only declared stale links.
-- `scripts/generate_mod_ui_pedalboard.py` builds the YAML-declared NAM→IR reference bundle; mod-ui owns plugin instances and internal cables after loading it.
-- `scripts/run_mod_host_ports.py` runs the two mono PipeWire loopbacks which form stable mod-ui-visible input/output boundaries.
+- `scripts/generate_mod_ui_pedalboard.py` builds the YAML-declared guitar NAM→IR chain and three direct-through source pairs; mod-ui owns plugin instances and internal cables after loading it.
+- `scripts/run_mod_host_ports.py` runs the paired four-channel PipeWire loopbacks which form stable mod-ui-visible input/output boundaries.
 - `scripts/run_mod_ui_service.py` launches mod-ui under `pw-jack` and holds a WebSocket session so the backend loads without a browser.
 - `build/arm64/patch_mod_ui_rigforge.py` reapplies the local PipeWire-boundary mapping and acknowledged MIDI WebSocket command when rebuilding the pinned mod-ui artifact; keep it consistent with the tracked artifact changes.
 - `scripts/wait_mod_host_ports.py` waits for boundary and mixer endpoints before mod-host starts, avoiding startup races after PipeWire restarts.
@@ -25,7 +25,7 @@ The current target is Debian GNU/Linux 13 on AArch64 with a Behringer UMC404HD 1
 - `tests/` contains Python `unittest` tests for state validation, observation/reconciliation, the generated pedalboard, MIDI WebSocket control, and simulated deployment operations. These validate repository-level invariants, not live audio behavior.
 - `config/sooperlooper/fcb1010.slb` is supplied controller configuration, pending target verification. No SooperLooper build definition or artifact is present.
 
-The YAML is the source of truth for desired topology and the generated pedalboard. mod-ui owns the NAM→IR cable; Rigforge owns the UMC→input-boundary and output-boundary→mixer/looper links. The observer compares only external links whose endpoints are listed in `routing.managed_ports`. Keep mod-ui-owned plugin cables and unrelated WirePlumber links out of scope. Managed endpoint names are constrained by an explicit allowlist pattern in the observer, so a new port naming scheme must be deliberately reviewed and tested there as well as declared in YAML.
+The YAML is the source of truth for desired topology and the generated pedalboard. mod-ui owns the guitar NAM→IR cable and the bass/voice/synth input-to-output passthrough cables; its Rigforge bridge applies those boundary Connect/Disconnect operations through `pw-link`. Rigforge's observer owns only external UMC→input-boundary and output-boundary→mixer/looper links. The observer compares only external links whose endpoints are listed in `routing.managed_ports`. Keep mod-ui-owned cables and unrelated WirePlumber links out of scope. Managed endpoint names are constrained by an explicit allowlist pattern in the observer, so a new port naming scheme must be deliberately reviewed and tested there as well as declared in YAML.
 
 ## Commands
 

Файловите разлики са ограничени, защото са твърде много
+ 8 - 7
README.md


+ 14 - 2
artifacts/mod-ui/arm64/current/app/html/js/pedalboard.js

@@ -767,13 +767,25 @@ JqueryClass('pedalboard', {
                 var symbol
                 for (var i=1, count=data.hardware.audio_ins; i<=count; i++) {
                     symbol = (i < 3) ? ('/graph/capture_' + i) : ('/graph/audio_from_slave_' + (i-2))
-                    var captureTitle = (i === 1) ? 'Rigforge Mod-Host Input' : ('Hardware Capture ' + i)
+                    var captureTitles = {
+                        1: 'Guitare - Entrée mod-ui',
+                        2: 'Basse - Entrée mod-ui',
+                        3: 'Micro - Entrée mod-ui',
+                        4: 'Synthé - Entrée mod-ui'
+                    }
+                    var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
                     var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
                     self.pedalboard('addHardwareOutput', hw, symbol, 'audio')
                 }
                 for (var i=1, count=data.hardware.audio_outs; i<=count; i++) {
                     symbol = (i < 3) ? ('/graph/playback_' + i) : ('/graph/audio_to_slave_' + (i-2))
-                    var playbackTitle = (i === 1) ? 'Rigforge Mod-Host Output' : ('Hardware Playback ' + i)
+                    var playbackTitles = {
+                        1: 'Guitare - Sortie mod-ui',
+                        2: 'Basse - Sortie mod-ui',
+                        3: 'Micro - Sortie mod-ui',
+                        4: 'Synthé - Sortie mod-ui'
+                    }
+                    var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
                     var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
                     self.pedalboard('addHardwareInput', hw, '/graph/playback_' + i, 'audio')
                 }

+ 32 - 9
artifacts/mod-ui/arm64/current/app/mod/host.py

@@ -424,8 +424,20 @@ class Host(object):
 
         # clients at the end of the chain, all managed by mod-host
         self.jack_hw_capture_prefix = "mod-host:out" if self.descriptor.get('has_noisegate', False) else "system:capture_"
-        self.rigforge_capture_port = os.environ.get("MOD_RIGFORGE_CAPTURE_PORT")
-        self.rigforge_playback_port = os.environ.get("MOD_RIGFORGE_PLAYBACK_PORT")
+        self.rigforge_capture_ports = {
+            "capture_%d" % (index + 1): port
+            for index, port in enumerate(
+                os.environ.get("MOD_RIGFORGE_CAPTURE_PORTS", "").split(",")
+            )
+            if port
+        }
+        self.rigforge_playback_ports = {
+            "playback_%d" % (index + 1): port
+            for index, port in enumerate(
+                os.environ.get("MOD_RIGFORGE_PLAYBACK_PORTS", "").split(",")
+            )
+            if port
+        }
 
         # used for external connections
         self.jack_external_prefix = "mod-external"
@@ -1187,10 +1199,16 @@ class Host(object):
             self.hasSerialMidiOut = False
             return False
 
-        if self.rigforge_capture_port and self.rigforge_playback_port:
+        if self.rigforge_capture_ports and self.rigforge_playback_ports:
             # These graph symbols map to Rigforge's stable virtual PipeWire boundary ports.
-            self.audioportsIn = ["capture_1"]
-            self.audioportsOut = ["playback_1"]
+            self.audioportsIn = [
+                "capture_%d" % index
+                for index in range(1, len(self.rigforge_capture_ports) + 1)
+            ]
+            self.audioportsOut = [
+                "playback_%d" % index
+                for index in range(1, len(self.rigforge_playback_ports) + 1)
+            ]
         else:
             for port in get_jack_hardware_ports(True, False):
                 client_name, port_name = port.split(":",1)
@@ -3623,10 +3641,10 @@ class Host(object):
 
         if len(data) == 3:
             # Handle special cases
-            if data[2] == "capture_1" and self.rigforge_capture_port:
-                return self.rigforge_capture_port
-            if data[2] == "playback_1" and self.rigforge_playback_port:
-                return self.rigforge_playback_port
+            if data[2] in self.rigforge_capture_ports:
+                return self.rigforge_capture_ports[data[2]]
+            if data[2] in self.rigforge_playback_ports:
+                return self.rigforge_playback_ports[data[2]]
             if data[2] == "serial_midi_in":
                 return "ttymidi:MIDI_in"
             if data[2] == "serial_midi_out":
@@ -3692,8 +3710,13 @@ class Host(object):
         return boundary_connection(
             port_from,
             port_to,
+<<<<<<< Updated upstream
             self.rigforge_capture_port,
             self.rigforge_playback_port,
+=======
+            self.rigforge_capture_ports,
+            self.rigforge_playback_ports,
+>>>>>>> Stashed changes
             self._fix_host_connection_port,
         )
 

+ 7 - 0
artifacts/mod-ui/arm64/current/provenance.json

@@ -9,8 +9,15 @@
   "additional_python_requirement": "backports.ssl_match_hostname==3.7.0.1",
   "python_compatibility_patch": "Tornado 4.3 collections.MutableMapping to collections.abc.MutableMapping",
   "rigforge_integration_patch": "build/arm64/patch_mod_ui_rigforge.py",
+<<<<<<< Updated upstream
   "rigforge_integration_patch_sha256": "8742e8b3c5c503b2e4dec62ec953054d271b77a235c5875c64323c375041fe2e",
   "license": "AGPL-3.0-or-later",
   "rigforge_pipewire_helper": "build/arm64/mod_ui_pipewire.py",
   "rigforge_pipewire_helper_sha256": "0820e7d21c140a273834ef1395998de250c46996e3a8a7ef4c1eb5a68d8db078"
+=======
+  "rigforge_integration_patch_sha256": "bf9c08e74220d25bc3aaf6a2c2c1cba008ec3d11acf84e1ed90f1acdfe460347",
+  "license": "AGPL-3.0-or-later",
+  "rigforge_pipewire_helper": "build/arm64/mod_ui_pipewire.py",
+  "rigforge_pipewire_helper_sha256": "f67107c2fc30bf170aed804403e104a12b18894c392a8887d8a2ebdeee6ecd6a"
+>>>>>>> Stashed changes
 }

+ 291 - 11
build/arm64/patch_mod_ui_rigforge.py

@@ -14,26 +14,79 @@ def replace_once(path, original, replacement):
     path.write_text(text.replace(original, replacement), encoding="utf-8")
 
 
+def replace_if_present(path, original, replacement):
+    text = path.read_text(encoding="utf-8")
+    if (replacement and replacement in text) or original not in text:
+        return
+    if text.count(original) != 1:
+        raise RuntimeError(f"expected at most one upstream match in {path}")
+    path.write_text(text.replace(original, replacement), encoding="utf-8")
+
+
 def apply(source_root):
     app = Path(source_root)
+<<<<<<< Updated upstream
     helper_source = Path(__file__).with_name("mod_ui_pipewire.py")
     helper_target = app / "mod" / "rigforge_pipewire.py"
     helper_target.write_bytes(helper_source.read_bytes())
 
     replace_once(
+=======
+    helper = Path(__file__).with_name("mod_ui_pipewire.py")
+    (app / "mod" / "rigforge_pipewire.py").write_bytes(helper.read_bytes())
+    replace_if_present(
+>>>>>>> Stashed changes
         app / "mod" / "host.py",
         "from mod import (\n",
         "from mod.rigforge_pipewire import boundary_connection, connect_link, disconnect_link\n"
         "from mod import (\n",
     )
 
-    replace_once(
+    replace_if_present(
         app / "mod" / "host.py",
         '''        self.jack_hw_capture_prefix = "mod-host:out" if self.descriptor.get('has_noisegate', False) else "system:capture_"
 ''',
         '''        self.jack_hw_capture_prefix = "mod-host:out" if self.descriptor.get('has_noisegate', False) else "system:capture_"
-        self.rigforge_capture_port = os.environ.get("MOD_RIGFORGE_CAPTURE_PORT")
+        self.rigforge_capture_ports = {
+            "capture_%d" % (index + 1): port
+            for index, port in enumerate(
+                os.environ.get("MOD_RIGFORGE_CAPTURE_PORTS", "").split(",")
+            )
+            if port
+        }
+        self.rigforge_playback_ports = {
+            "playback_%d" % (index + 1): port
+            for index, port in enumerate(
+                os.environ.get("MOD_RIGFORGE_PLAYBACK_PORTS", "").split(",")
+            )
+            if port
+        }
+''',
+    )
+    replace_if_present(
+        app / "mod" / "host.py",
+        '''        self.rigforge_capture_port = os.environ.get("MOD_RIGFORGE_CAPTURE_PORT")
         self.rigforge_playback_port = os.environ.get("MOD_RIGFORGE_PLAYBACK_PORT")
+''',
+        "",
+    )
+    replace_if_present(
+        app / "mod" / "host.py",
+        '''        if self.rigforge_capture_port and self.rigforge_playback_port:
+            # These graph symbols map to Rigforge's stable virtual PipeWire boundary ports.
+            self.audioportsIn = ["capture_1"]
+            self.audioportsOut = ["playback_1"]
+''',
+        '''        if self.rigforge_capture_ports and self.rigforge_playback_ports:
+            # These graph symbols map to Rigforge's stable virtual PipeWire boundary ports.
+            self.audioportsIn = [
+                "capture_%d" % index
+                for index in range(1, len(self.rigforge_capture_ports) + 1)
+            ]
+            self.audioportsOut = [
+                "playback_%d" % index
+                for index in range(1, len(self.rigforge_playback_ports) + 1)
+            ]
 ''',
     )
     replace_once(
@@ -54,10 +107,16 @@ def apply(source_root):
             else:
                 self.audioportsOut.append(port_name)
 ''',
-        '''        if self.rigforge_capture_port and self.rigforge_playback_port:
+        '''        if self.rigforge_capture_ports and self.rigforge_playback_ports:
             # These graph symbols map to Rigforge's stable virtual PipeWire boundary ports.
-            self.audioportsIn = ["capture_1"]
-            self.audioportsOut = ["playback_1"]
+            self.audioportsIn = [
+                "capture_%d" % index
+                for index in range(1, len(self.rigforge_capture_ports) + 1)
+            ]
+            self.audioportsOut = [
+                "playback_%d" % index
+                for index in range(1, len(self.rigforge_playback_ports) + 1)
+            ]
         else:
             for port in get_jack_hardware_ports(True, False):
                 client_name, port_name = port.split(":",1)
@@ -74,6 +133,38 @@ def apply(source_root):
                     self.cvportsOut.append(CV_PREFIX + port_name)
                 else:
                     self.audioportsOut.append(port_name)
+''',
+    )
+    replace_if_present(
+        app / "mod" / "host.py",
+        '''            if data[2] == "capture_1" and self.rigforge_capture_port:
+                return self.rigforge_capture_port
+            if data[2] == "playback_1" and self.rigforge_playback_port:
+                return self.rigforge_playback_port
+''',
+        '''            if data[2] in self.rigforge_capture_ports:
+                return self.rigforge_capture_ports[data[2]]
+            if data[2] in self.rigforge_playback_ports:
+                return self.rigforge_playback_ports[data[2]]
+''',
+    )
+    replace_if_present(
+        app / "mod" / "host.py",
+        '''        if len(data) == 3:
+            # Handle special cases
+            if data[2] in self.rigforge_capture_ports:
+                return self.rigforge_capture_ports[data[2]]
+            if data[2] in self.rigforge_playback_ports:
+                return self.rigforge_playback_ports[data[2]]
+            if data[2] == "serial_midi_in":
+''' + "        \n",
+        '''        if len(data) == 3:
+            # Handle special cases
+            if data[2] in self.rigforge_capture_ports:
+                return self.rigforge_capture_ports[data[2]]
+            if data[2] in self.rigforge_playback_ports:
+                return self.rigforge_playback_ports[data[2]]
+            if data[2] == "serial_midi_in":
 ''',
     )
     replace_once(
@@ -188,14 +279,119 @@ def apply(source_root):
 ''',
         '''        if len(data) == 3:
             # Handle special cases
-            if data[2] == "capture_1" and self.rigforge_capture_port:
-                return self.rigforge_capture_port
-            if data[2] == "playback_1" and self.rigforge_playback_port:
-                return self.rigforge_playback_port
+            if data[2] in self.rigforge_capture_ports:
+                return self.rigforge_capture_ports[data[2]]
+            if data[2] in self.rigforge_playback_ports:
+                return self.rigforge_playback_ports[data[2]]
             if data[2] == "serial_midi_in":
 ''',
     )
 
+    replace_once(
+        app / "mod" / "host.py",
+        '''    def connect(self, port_from, port_to, callback):
+        if (port_from, port_to) in self.connections:
+''',
+        '''    def _rigforge_pipewire_boundary(self, port_from, port_to):
+        return boundary_connection(
+            port_from,
+            port_to,
+            self.rigforge_capture_ports,
+            self.rigforge_playback_ports,
+            self._fix_host_connection_port,
+        )
+
+    def connect(self, port_from, port_to, callback):
+        if (port_from, port_to) in self.connections:
+''',
+    )
+    replace_once(
+        app / "mod" / "host.py",
+        '''        def host_callback(ok):
+            callback(ok)
+            if ok:
+                self.connections.append((port_from, port_to))
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            else:
+                logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
+
+        self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
+''',
+        '''        pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+        if pipewire_link is not None:
+            ok = connect_link(*pipewire_link)
+            callback(ok)
+            if ok:
+                self.connections.append((port_from, port_to))
+                self.pedalboard_modified = True
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            else:
+                logging.error(
+                    "[host] PipeWire backend failed to connect ports: '%s' => '%s'",
+                    pipewire_link[0], pipewire_link[1]
+                )
+            return
+
+        def host_callback(ok):
+            callback(ok)
+            if ok:
+                self.connections.append((port_from, port_to))
+                self.msg_callback("connect %s %s" % (port_from, port_to))
+            else:
+                logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
+
+        self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
+''',
+    )
+    replace_once(
+        app / "mod" / "host.py",
+        '''    def disconnect(self, port_from, port_to, callback):
+        def host_callback(ok):
+''',
+        '''    def disconnect(self, port_from, port_to, callback):
+        pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+        if pipewire_link is not None:
+            ok = disconnect_link(*pipewire_link)
+            callback(ok)
+            if ok:
+                self.msg_callback("disconnect %s %s" % (port_from, port_to))
+                self.pedalboard_modified = True
+                try:
+                    self.connections.remove((port_from, port_to))
+                except ValueError:
+                    logging.info(
+                        "[host] Requested '%s' => '%s' connection was not in the UI state",
+                        port_from, port_to
+                    )
+            else:
+                logging.error(
+                    "[host] PipeWire backend failed to disconnect ports: '%s' => '%s'",
+                    pipewire_link[0], pipewire_link[1]
+                )
+            return
+
+        def host_callback(ok):
+''',
+    )
+    replace_once(
+        app / "mod" / "host.py",
+        '''                self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
+                self.connections.append((port_from, port_to))
+''',
+        '''                pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
+                if pipewire_link is not None:
+                    if not connect_link(*pipewire_link):
+                        logging.error(
+                            "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
+                            pipewire_link[0], pipewire_link[1]
+                        )
+                        continue
+                else:
+                    self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
+                self.connections.append((port_from, port_to))
+''',
+    )
+
     replace_once(
         app / "mod" / "session.py",
         '''    # Set a plugin block position within the canvas
@@ -252,11 +448,89 @@ def apply(source_root):
         "os.environ.setdefault('MOD_DEFAULT_PEDALBOARD', os.path.join(ROOT, 'default.pedalboard'))",
     )
 
+    replace_if_present(
+        app / "html" / "js" / "pedalboard.js",
+        '''                    var captureTitles = {
+                        1: 'Guitar - Mod-UI Input',
+                        2: 'Bass - Mod-UI Input',
+                        3: 'Micro - Mod-UI Input',
+                        4: 'Synth - Mod-UI Input'
+                    }
+                    var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
+''',
+        '''                    var captureTitles = {
+                        1: 'Guitare - Entrée mod-ui',
+                        2: 'Basse - Entrée mod-ui',
+                        3: 'Micro - Entrée mod-ui',
+                        4: 'Synthé - Entrée mod-ui'
+                    }
+                    var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
+''',
+    )
+    replace_if_present(
+        app / "html" / "js" / "pedalboard.js",
+        '''                    var playbackTitles = {
+                        1: 'Guitar - Mod-UI Output',
+                        2: 'Bass - Mod-UI Output',
+                        3: 'Micro - Mod-UI Output',
+                        4: 'Synth - Mod-UI Output'
+                    }
+                    var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
+''',
+        '''                    var playbackTitles = {
+                        1: 'Guitare - Sortie mod-ui',
+                        2: 'Basse - Sortie mod-ui',
+                        3: 'Micro - Sortie mod-ui',
+                        4: 'Synthé - Sortie mod-ui'
+                    }
+                    var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
+''',
+    )
+    replace_if_present(
+        app / "html" / "js" / "pedalboard.js",
+        '''                    var captureTitle = (i === 1) ? 'Rigforge Mod-Host Input' : ('Hardware Capture ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
+''',
+        '''                    var captureTitles = {
+                        1: 'Guitare - Entrée mod-ui',
+                        2: 'Basse - Entrée mod-ui',
+                        3: 'Micro - Entrée mod-ui',
+                        4: 'Synthé - Entrée mod-ui'
+                    }
+                    var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
+''',
+    )
+    replace_if_present(
+        app / "html" / "js" / "pedalboard.js",
+        '''                    var playbackTitle = (i === 1) ? 'Rigforge Mod-Host Output' : ('Hardware Playback ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
+''',
+        '''                    var playbackTitles = {
+                        1: 'Guitare - Sortie mod-ui',
+                        2: 'Basse - Sortie mod-ui',
+                        3: 'Micro - Sortie mod-ui',
+                        4: 'Synthé - Sortie mod-ui'
+                    }
+                    var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
+                    var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
+''',
+    )
     replace_once(
         app / "html" / "js" / "pedalboard.js",
         '''                    var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="Hardware Capture ' + i + '">')
 ''',
-        '''                    var captureTitle = (i === 1) ? 'Rigforge Mod-Host Input' : ('Hardware Capture ' + i)
+        '''                    var captureTitles = {
+                        1: 'Guitare - Entrée mod-ui',
+                        2: 'Basse - Entrée mod-ui',
+                        3: 'Micro - Entrée mod-ui',
+                        4: 'Synthé - Entrée mod-ui'
+                    }
+                    var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
                     var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
 ''',
     )
@@ -264,7 +538,13 @@ def apply(source_root):
         app / "html" / "js" / "pedalboard.js",
         '''                    var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="Hardware Playback ' + i + '">')
 ''',
-        '''                    var playbackTitle = (i === 1) ? 'Rigforge Mod-Host Output' : ('Hardware Playback ' + i)
+        '''                    var playbackTitles = {
+                        1: 'Guitare - Sortie mod-ui',
+                        2: 'Basse - Sortie mod-ui',
+                        3: 'Micro - Sortie mod-ui',
+                        4: 'Synthé - Sortie mod-ui'
+                    }
+                    var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
                     var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
 ''',
     )

+ 56 - 11
config/desired-state.yaml

@@ -92,7 +92,11 @@ deployment:
     service_destination: .config/systemd/user/rigforge-mod-host-ports.service
     user_service: rigforge-mod-host-ports.service
     python_path: /usr/bin/python3
-    channel_map: AUX0
+    channel_map:
+      - AUX0
+      - AUX1
+      - AUX2
+      - AUX3
     input_sink_name: rigforge.mod-host-input
     input_source_name: rigforge.mod-host-input.capture
     output_sink_name: rigforge.mod-host-output.playback
@@ -114,8 +118,16 @@ deployment:
     pedalboards_directory: .local/share/rigforge/mod-ui/pedalboards
     user_files_directory: .local/share/rigforge/mod-ui/user-files
     last_state_file: .local/share/rigforge/mod-ui/last-rigforge.json
-    hardware_input_port: rigforge.mod-host-input.capture:capture_AUX0
-    hardware_output_port: rigforge.mod-host-output.playback:playback_AUX0
+    hardware_input_ports:
+      - rigforge.mod-host-input.capture:capture_AUX0
+      - rigforge.mod-host-input.capture:capture_AUX1
+      - rigforge.mod-host-input.capture:capture_AUX2
+      - rigforge.mod-host-input.capture:capture_AUX3
+    hardware_output_ports:
+      - rigforge.mod-host-output.playback:playback_AUX0
+      - rigforge.mod-host-output.playback:playback_AUX1
+      - rigforge.mod-host-output.playback:playback_AUX2
+      - rigforge.mod-host-output.playback:playback_AUX3
   reconcile:
     observer_script: scripts/observe_pipewire.py
     service_source: config/systemd/user/rigforge-pipewire-reconcile.service.in
@@ -273,7 +285,13 @@ routing:
     - alsa_input.hw_U192k_0:capture_AUX2
     - alsa_input.hw_U192k_0:capture_AUX3
     - rigforge.mod-host-input:playback_AUX0
+    - rigforge.mod-host-input:playback_AUX1
+    - rigforge.mod-host-input:playback_AUX2
+    - rigforge.mod-host-input:playback_AUX3
     - rigforge.mod-host-output:capture_AUX0
+    - rigforge.mod-host-output:capture_AUX1
+    - rigforge.mod-host-output:capture_AUX2
+    - rigforge.mod-host-output:capture_AUX3
     - sooperlooper:loop0_in_1
     - sooperlooper:loop0_in_2
     - sooperlooper:loop0_in_3
@@ -298,24 +316,39 @@ routing:
     - from: alsa_input.hw_U192k_0:capture_AUX0
       to: rigforge.mod-host-input:playback_AUX0
       status: planned
+    - from: alsa_input.hw_U192k_0:capture_AUX1
+      to: rigforge.mod-host-input:playback_AUX1
+      status: planned
+    - from: alsa_input.hw_U192k_0:capture_AUX2
+      to: rigforge.mod-host-input:playback_AUX2
+      status: planned
+    - from: alsa_input.hw_U192k_0:capture_AUX3
+      to: rigforge.mod-host-input:playback_AUX3
+      status: planned
     - from: rigforge.mod-host-output:capture_AUX0
       to: rigforge.direct-mix.input:playback_AUX0
       status: planned
     - from: rigforge.mod-host-output:capture_AUX0
       to: sooperlooper:loop0_in_1
       status: planned
-    - from: alsa_input.hw_U192k_0:capture_AUX1
+    - from: rigforge.mod-host-output:capture_AUX1
+      to: rigforge.direct-mix.input:playback_AUX1
+      status: planned
+    - from: rigforge.mod-host-output:capture_AUX1
       to: sooperlooper:loop0_in_2
-      status: observed
-    - from: alsa_input.hw_U192k_0:capture_AUX2
+      status: planned
+    - from: rigforge.mod-host-output:capture_AUX2
       to: rigforge.direct-mix.input:playback_AUX2
-      status: observed
-    - from: alsa_input.hw_U192k_0:capture_AUX2
+      status: planned
+    - from: rigforge.mod-host-output:capture_AUX2
       to: sooperlooper:loop0_in_3
-      status: observed
-    - from: alsa_input.hw_U192k_0:capture_AUX3
+      status: planned
+    - from: rigforge.mod-host-output:capture_AUX3
+      to: rigforge.direct-mix.input:playback_AUX3
+      status: planned
+    - from: rigforge.mod-host-output:capture_AUX3
       to: sooperlooper:loop0_in_4
-      status: observed
+      status: planned
     - from: sooperlooper:loop0_out_1
       to: rigforge.direct-mix.input:playback_AUX4
       status: observed
@@ -338,6 +371,18 @@ routing:
     - from: alsa_input.hw_U192k_0:capture_AUX0
       to: rigforge.direct-mix.input:playback_AUX0
       status: observed
+    - from: alsa_input.hw_U192k_0:capture_AUX1
+      to: sooperlooper:loop0_in_2
+      status: observed
+    - from: alsa_input.hw_U192k_0:capture_AUX2
+      to: rigforge.direct-mix.input:playback_AUX2
+      status: observed
+    - from: alsa_input.hw_U192k_0:capture_AUX2
+      to: sooperlooper:loop0_in_3
+      status: observed
+    - from: alsa_input.hw_U192k_0:capture_AUX3
+      to: sooperlooper:loop0_in_4
+      status: observed
   monitoring:
     hardware_monitoring: verify-on-target
     software_monitoring: verify-on-target

+ 2 - 2
config/systemd/user/rigforge-mod-ui.service.in

@@ -13,8 +13,8 @@ Environment=MOD_USER_PEDALBOARDS_DIR=@PEDALBOARDS_DIR@
 Environment=MOD_USER_FILES_DIR=@USER_FILES_DIR@
 Environment=MOD_DEFAULT_PEDALBOARD=@REFERENCE_PEDALBOARD@
 Environment=MOD_DEVICE_WEBSERVER_PORT=@WEBSOCKET_PORT@
-Environment=MOD_RIGFORGE_CAPTURE_PORT=@HARDWARE_INPUT_PORT@
-Environment=MOD_RIGFORGE_PLAYBACK_PORT=@HARDWARE_OUTPUT_PORT@
+Environment=MOD_RIGFORGE_CAPTURE_PORTS=@HARDWARE_INPUT_PORTS@
+Environment=MOD_RIGFORGE_PLAYBACK_PORTS=@HARDWARE_OUTPUT_PORTS@
 ExecStart=@PYTHON@ -u @RUNNER_SCRIPT@ --launcher @MOD_UI_LAUNCHER@ --pw-jack @PW_JACK@ --host @WEBSOCKET_HOST@ --port @WEBSOCKET_PORT@
 Restart=on-failure
 RestartSec=5

+ 2 - 2
scripts/deploy.py

@@ -1056,8 +1056,8 @@ def render_mod_ui_service(config):
         "@PEDALBOARDS_DIR@": systemd_quote(home / config["pedalboards_directory"]),
         "@USER_FILES_DIR@": systemd_quote(home / config["user_files_directory"]),
         "@REFERENCE_PEDALBOARD@": systemd_quote(reference_pedalboard),
-        "@HARDWARE_INPUT_PORT@": config["hardware_input_port"],
-        "@HARDWARE_OUTPUT_PORT@": config["hardware_output_port"],
+        "@HARDWARE_INPUT_PORTS@": systemd_quote(",".join(config["hardware_input_ports"])),
+        "@HARDWARE_OUTPUT_PORTS@": systemd_quote(",".join(config["hardware_output_ports"])),
     }
     content = service_template.read_text(encoding="utf-8")
     for placeholder, replacement in replacements.items():

+ 51 - 5
scripts/generate_mod_ui_pedalboard.py

@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-"""Generate Rigforge's reference guitar pedalboard bundle for mod-ui."""
+"""Generate Rigforge's four-source reference pedalboard bundle for mod-ui."""
 
 import argparse
 import hashlib
@@ -51,6 +51,47 @@ def generate_bundle_files(state, repo_root=ROOT, asset_root=None, nam_model_path
     ir_instance = ir["mod_ui_instance"].removeprefix("/graph/")
     nam_model_uri = nam["file_property"]
     ir_file_uri = ir["file_property"]
+    source_labels = {
+        "guitar": "Guitare",
+        "bass": "Basse",
+        "voice": "Micro",
+        "synth": "Synthé",
+    }
+    source_ids = {source["id"] for source in state["sources"]}
+    passthrough_channels = [
+        (index, source_labels[source_id])
+        for index, source_id in enumerate(("guitar", "bass", "voice", "synth"), start=1)
+        if source_id != "guitar" and source_id in source_ids
+    ]
+    additional_ports_ttl = "\n\n".join(
+        f'''<capture_{index}>
+    lv2:index {9 + (index - 2) * 2} ;
+    lv2:name "{label} - Entrée mod-ui" ;
+    lv2:portProperty lv2:connectionOptional ;
+    lv2:symbol "capture_{index}" ;
+    a lv2:AudioPort, lv2:InputPort .
+
+<playback_{index}>
+    lv2:index {10 + (index - 2) * 2} ;
+    lv2:name "{label} - Sortie mod-ui" ;
+    lv2:portProperty lv2:connectionOptional ;
+    lv2:symbol "playback_{index}" ;
+    a lv2:AudioPort, lv2:OutputPort .'''
+        for index, label in passthrough_channels
+    )
+    additional_ports_list = ",\n             ".join(
+        f"<{symbol}_{index}>"
+        for index, _label in passthrough_channels
+        for symbol in ("capture", "playback")
+    )
+    additional_arcs_list = ", ".join(
+        f"_:b{index + 2}" for index, _label in passthrough_channels
+    )
+    additional_arcs_ttl = "\n\n".join(
+        f"_:b{index + 2} ingen:tail <capture_{index}> ;\n"
+        f"      ingen:head <playback_{index}> ."
+        for index, _label in passthrough_channels
+    )
 
     ttl = f"""\
 @prefix atom:  <http://lv2plug.in/ns/ext/atom#> .
@@ -67,18 +108,20 @@ def generate_bundle_files(state, repo_root=ROOT, asset_root=None, nam_model_path
 
 <capture_1>
     lv2:index 5 ;
-    lv2:name "Rigforge Mod-Host Input" ;
+    lv2:name "Guitare - Entrée mod-ui" ;
     lv2:portProperty lv2:connectionOptional ;
     lv2:symbol "capture_1" ;
     a lv2:AudioPort, lv2:InputPort .
 
 <playback_1>
     lv2:index 6 ;
-    lv2:name "Rigforge Mod-Host Output" ;
+    lv2:name "Guitare - Sortie mod-ui" ;
     lv2:portProperty lv2:connectionOptional ;
     lv2:symbol "playback_1" ;
     a lv2:AudioPort, lv2:OutputPort .
 
+{additional_ports_ttl}
+
 <:bpb>
     ingen:value 4.0 ;
     lv2:index 0 ;
@@ -232,7 +275,7 @@ def generate_bundle_files(state, repo_root=ROOT, asset_root=None, nam_model_path
     a lv2:ControlPort, lv2:InputPort .
 
 <>
-    doap:name "Rigforge Guitar NAM and IR" ;
+    doap:name "Rigforge - Guitare NAM/IR, Basse, Micro, Synthé" ;
     pedal:unitName "Rigforge" ;
     pedal:unitModel "Generic" ;
     pedal:width 1200 ;
@@ -243,11 +286,12 @@ def generate_bundle_files(state, repo_root=ROOT, asset_root=None, nam_model_path
     pedal:formatVersion 2 ;
     pedal:version 1 ;
     ingen:polyphony 1 ;
-    ingen:arc _:b1, _:b2, _:b3 ;
+    ingen:arc _:b1, _:b2, _:b3, {additional_arcs_list} ;
     ingen:block <{nam_instance}>, <{ir_instance}> ;
     lv2:port <:bpb>, <:bpm>, <:rolling>,
              <control_in>, <control_out>,
              <capture_1>, <playback_1>,
+             {additional_ports_list},
              <midi_separated_mode>, <midi_loopback> ;
     lv2:extensionData <http://lv2plug.in/ns/ext/state#interface> ;
     a lv2:Plugin, ingen:Graph, pedal:Pedalboard .
@@ -260,6 +304,8 @@ _:b2 ingen:tail <{nam_instance}/output> ;
 
 _:b3 ingen:tail <{ir_instance}/out> ;
      ingen:head <playback_1> .
+
+{additional_arcs_ttl}
 """
 
     files = {

+ 2 - 2
scripts/observe_pipewire.py

@@ -16,8 +16,8 @@ MANAGED_ENDPOINT_PATTERN = re.compile(
     r"alsa_output\.hw_U192k_0:playback_AUX[0-3]|"
     r"rigforge\.direct-mix\.input:playback_AUX[0-7]|"
     r"rigforge\.direct-mix\.output:capture_FL|"
-    r"rigforge\.mod-host-input:playback_AUX0|"
-    r"rigforge\.mod-host-output:capture_AUX0|"
+    r"rigforge\.mod-host-input:playback_AUX[0-3]|"
+    r"rigforge\.mod-host-output:capture_AUX[0-3]|"
     r"sooperlooper:loop0_(?:in|out)_[1-4]|"
     r"sooperlooper:midi_in|"
     r"Midi-Bridge:UMC404HD 192k MIDI 1 \(capture\)"

+ 17 - 7
scripts/run_mod_host_ports.py

@@ -14,7 +14,12 @@ from validate_desired_state import validate_state
 
 
 def loopback_command(binary, node_name, capture_name, playback_name, channel_map, latency_ms):
-    position = f"[{channel_map}]"
+    if isinstance(channel_map, str):
+        channel_map = [channel_map]
+    channel_map = tuple(channel_map)
+    if not channel_map or len(set(channel_map)) != len(channel_map):
+        raise ValueError("channel_map must contain unique channel positions")
+    position = f"[{','.join(channel_map)}]"
     label = node_name.rsplit(".", 1)[-1].replace("-", "_")
     capture_props = " ".join(
         (
@@ -45,7 +50,7 @@ def loopback_command(binary, node_name, capture_name, playback_name, channel_map
         "--name",
         node_name,
         "--channels",
-        "1",
+        str(len(channel_map)),
         "--channel-map",
         position,
         "--latency",
@@ -58,12 +63,17 @@ def loopback_command(binary, node_name, capture_name, playback_name, channel_map
 
 
 def required_endpoints(state):
-    chain = state["routing"]["mod_host_chains"]["guitar"]
+    ports = state["deployment"]["mod_host_ports"]
+    channels = ports["channel_map"]
     return {
-        chain["pipewire_input_port"],
-        chain["source_port"],
-        chain["mod_ui_output_port"],
-        chain["pipewire_output_port"],
+        endpoint
+        for channel in channels
+        for endpoint in (
+            f"{ports['input_sink_name']}:playback_{channel}",
+            f"{ports['input_source_name']}:capture_{channel}",
+            f"{ports['output_sink_name']}:playback_{channel}",
+            f"{ports['output_source_name']}:capture_{channel}",
+        )
     }
 
 

+ 0 - 1
scripts/run_mod_ui_service.py

@@ -73,7 +73,6 @@ def run_service(
 
 
 def main(argv=None):
-    root = Path(__file__).resolve().parents[1]
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument("--launcher", type=Path, required=True)
     parser.add_argument("--pw-jack", type=Path, default=Path("/usr/bin/pw-jack"))

+ 97 - 3
scripts/validate_desired_state.py

@@ -168,6 +168,82 @@ def validate_mod_host_chain(routing, source_by_id):
     return errors
 
 
+def validate_mod_host_channel_routes(state, source_by_id):
+    errors = []
+    deployment = state.get("deployment")
+    ports = deployment.get("mod_host_ports") if isinstance(deployment, dict) else None
+    if not isinstance(ports, dict):
+        return ["deployment.mod_host_ports must declare four-channel boundaries"]
+    channel_map = ports.get("channel_map")
+    if channel_map != ["AUX0", "AUX1", "AUX2", "AUX3"]:
+        return ["deployment.mod_host_ports.channel_map must contain AUX0 through AUX3"]
+    required_names = (
+        "input_sink_name",
+        "input_source_name",
+        "output_sink_name",
+        "output_source_name",
+    )
+    if any(not isinstance(ports.get(name), str) or not ports[name] for name in required_names):
+        return ["deployment.mod_host_ports must declare all four boundary node names"]
+
+    routing = state.get("routing")
+    if not isinstance(routing, dict):
+        return errors
+    links = routing.get("managed_links")
+    if not isinstance(links, list):
+        return ["routing.managed_links must be a list"]
+    edges = {
+        (link.get("from"), link.get("to"))
+        for link in links
+        if isinstance(link, dict)
+    }
+    for channel, source_id in enumerate(("guitar", "bass", "voice", "synth")):
+        source = source_by_id.get(source_id)
+        if not isinstance(source, dict):
+            continue
+        position = channel_map[channel]
+        expected_capture = f"alsa_input.hw_U192k_0:capture_AUX{channel}"
+        if source.get("physical_input") != channel + 1:
+            errors.append(
+                f"{source_id} must use physical input {channel + 1} for mod-ui channel {channel + 1}"
+            )
+        if source.get("capture_port") != expected_capture:
+            errors.append(
+                f"{source_id} capture_port must be {expected_capture} for mod-ui channel {channel + 1}"
+            )
+        expected = (
+            (
+                source.get("capture_port"),
+                f"{ports['input_sink_name']}:playback_{position}",
+            ),
+            (
+                f"{ports['output_source_name']}:capture_{position}",
+                f"rigforge.direct-mix.input:playback_AUX{channel}",
+            ),
+            (
+                f"{ports['output_source_name']}:capture_{position}",
+                f"sooperlooper:loop0_in_{channel + 1}",
+            ),
+        )
+        for edge in expected:
+            if edge not in edges:
+                errors.append(
+                    f"{source_id} mod-host boundary route must be declared: "
+                    f"{edge[0]} -> {edge[1]}"
+                )
+        bypass_edges = {
+            (source.get("capture_port"), f"rigforge.direct-mix.input:playback_AUX{channel}"),
+            (source.get("capture_port"), f"sooperlooper:loop0_in_{channel + 1}"),
+        }
+        stale = bypass_edges & edges
+        for source_port, destination_port in sorted(stale):
+            errors.append(
+                f"{source_id} capture must not bypass its mod-ui channel: "
+                f"{source_port} -> {destination_port}"
+            )
+    return errors
+
+
 def validate_state(state):
     errors = []
     if not isinstance(state, dict):
@@ -292,6 +368,7 @@ def validate_state(state):
         errors.append("routing.looper_returns.feed_looper_inputs must be false")
 
     errors.extend(validate_mod_host_chain(routing, source_by_id))
+    errors.extend(validate_mod_host_channel_routes(state, source_by_id))
 
     parameters = state.get("parameters")
     if not isinstance(parameters, dict):
@@ -596,11 +673,25 @@ def validate_state(state):
                 ("pedalboards_directory", ".local/share/rigforge/mod-ui/pedalboards"),
                 ("user_files_directory", ".local/share/rigforge/mod-ui/user-files"),
                 ("last_state_file", ".local/share/rigforge/mod-ui/last-rigforge.json"),
-                ("hardware_input_port", "rigforge.mod-host-input.capture:capture_AUX0"),
-                ("hardware_output_port", "rigforge.mod-host-output.playback:playback_AUX0"),
             ):
                 if mod_ui.get(key) != expected:
                     errors.append(f"deployment.mod_ui.{key} must be {expected}")
+            expected_input_ports = [
+                f"rigforge.mod-host-input.capture:capture_AUX{index}"
+                for index in range(4)
+            ]
+            expected_output_ports = [
+                f"rigforge.mod-host-output.playback:playback_AUX{index}"
+                for index in range(4)
+            ]
+            if mod_ui.get("hardware_input_ports") != expected_input_ports:
+                errors.append(
+                    "deployment.mod_ui.hardware_input_ports must declare capture_AUX0 through capture_AUX3"
+                )
+            if mod_ui.get("hardware_output_ports") != expected_output_ports:
+                errors.append(
+                    "deployment.mod_ui.hardware_output_ports must declare playback_AUX0 through playback_AUX3"
+                )
             ui_port = mod_ui.get("websocket_port")
             if (
                 not isinstance(ui_port, int)
@@ -625,7 +716,6 @@ def validate_state(state):
                 ("service_destination", ".config/systemd/user/rigforge-mod-host-ports.service"),
                 ("user_service", "rigforge-mod-host-ports.service"),
                 ("python_path", "/usr/bin/python3"),
-                ("channel_map", "AUX0"),
                 ("input_sink_name", "rigforge.mod-host-input"),
                 ("input_source_name", "rigforge.mod-host-input.capture"),
                 ("output_sink_name", "rigforge.mod-host-output.playback"),
@@ -633,6 +723,10 @@ def validate_state(state):
             ):
                 if mod_host_ports.get(key) != expected:
                     errors.append(f"deployment.mod_host_ports.{key} must be {expected}")
+            if mod_host_ports.get("channel_map") != ["AUX0", "AUX1", "AUX2", "AUX3"]:
+                errors.append(
+                    "deployment.mod_host_ports.channel_map must contain AUX0 through AUX3"
+                )
 
         reconcile = deployment.get("reconcile")
         if not isinstance(reconcile, dict):

+ 22 - 4
scripts/wait_mod_host_ports.py

@@ -13,14 +13,32 @@ def required_ports(state):
     routing = state["routing"]
     chain = routing["mod_host_chains"]["guitar"]
     mix = routing["mix"]
+    boundary = state["deployment"]["mod_host_ports"]
+    channels = boundary["channel_map"]
     return (
         {
-            chain["source_port"],
-            chain["pipewire_output_port"],
+            *(
+                f"{boundary['input_source_name']}:capture_{channel}"
+                for channel in channels
+            ),
+            *(
+                f"{boundary['output_source_name']}:capture_{channel}"
+                for channel in channels
+            ),
         },
         {
-            chain["pipewire_input_port"],
-            chain["mod_ui_output_port"],
+            *(
+                f"{boundary['input_sink_name']}:playback_{channel}"
+                for channel in channels
+            ),
+            *(
+                f"{boundary['output_sink_name']}:playback_{channel}"
+                for channel in channels
+            ),
+            *(
+                f"rigforge.direct-mix.input:playback_AUX{index}"
+                for index in range(4)
+            ),
             chain["mix_input"],
             mix["output_port"],
         },

+ 12 - 3
tests/test_deploy.py

@@ -642,13 +642,22 @@ class DeploymentTests(unittest.TestCase):
         content = destination.read_text(encoding="utf-8")
         self.assertIn("run_mod_ui_service.py", content)
         self.assertIn("MOD_DEFAULT_PEDALBOARD=", content)
-        self.assertIn("MOD_RIGFORGE_CAPTURE_PORT=", content)
+        self.assertIn("MOD_RIGFORGE_CAPTURE_PORTS=", content)
+        self.assertIn("MOD_RIGFORGE_PLAYBACK_PORTS=", content)
         self.assertIn(
             f'MOD_USER_FILES_DIR="{self.home / config["user_files_directory"]}"',
             content,
         )
-        self.assertIn("rigforge.mod-host-input.capture:capture_AUX0", content)
-        self.assertIn("rigforge.mod-host-output.playback:playback_AUX0", content)
+        self.assertIn(
+            "rigforge.mod-host-input.capture:capture_AUX0,rigforge.mod-host-input.capture:capture_AUX1,"
+            "rigforge.mod-host-input.capture:capture_AUX2,rigforge.mod-host-input.capture:capture_AUX3",
+            content,
+        )
+        self.assertIn(
+            "rigforge.mod-host-output.playback:playback_AUX0,rigforge.mod-host-output.playback:playback_AUX1,"
+            "rigforge.mod-host-output.playback:playback_AUX2,rigforge.mod-host-output.playback:playback_AUX3",
+            content,
+        )
         self.assertIn("Requires=rigforge-mod-host.service rigforge-mod-host-ports.service", content)
         self.assertIn("pw-jack", content)
 

+ 16 - 0
tests/test_desired_state.py

@@ -115,6 +115,22 @@ class DesiredStateValidationTests(unittest.TestCase):
         state["routing"]["mod_host_chains"]["guitar"]["processors"][0]["parameters"]["output_level"] = 30
         self.assertIn("NAM output_level must be between -20 and 20 dB", validate_state(state))
 
+    def test_mod_ui_boundary_channels_match_each_physical_input_and_source(self):
+        for index, source_id in enumerate(("guitar", "bass", "voice", "synth"), start=1):
+            source = next(item for item in self.state["sources"] if item["id"] == source_id)
+            self.assertEqual(source["physical_input"], index)
+            self.assertEqual(
+                source["capture_port"],
+                f"alsa_input.hw_U192k_0:capture_AUX{index - 1}",
+            )
+
+        state = copy.deepcopy(self.state)
+        bass = next(item for item in state["sources"] if item["id"] == "bass")
+        bass["physical_input"] = 3
+        self.assertTrue(
+            any("bass must use physical input 2" in error for error in validate_state(state))
+        )
+
     def test_declares_safe_midi_bridge_and_nam_models(self):
         processor = self.state["routing"]["mod_host_chains"]["guitar"]["processors"][0]
         self.assertEqual(set(processor["available_models"]), {

+ 10 - 5
tests/test_mod_host_ports.py

@@ -18,13 +18,13 @@ class ModHostPipeWirePortTests(unittest.TestCase):
             (ROOT / "config" / "desired-state.yaml").read_text(encoding="utf-8")
         )
 
-    def test_input_and_output_loopbacks_use_stable_mono_aux0_ports(self):
+    def test_input_and_output_loopbacks_expose_four_stable_mono_channels(self):
         input_command = loopback_command(
             "/usr/bin/pw-loopback",
             "rigforge.mod-host-input",
             "rigforge.mod-host-input",
             "rigforge.mod-host-input.capture",
-            "AUX0",
+            ["AUX0", "AUX1", "AUX2", "AUX3"],
             2.666666,
         )
         output_command = loopback_command(
@@ -32,7 +32,7 @@ class ModHostPipeWirePortTests(unittest.TestCase):
             "rigforge.mod-host-output",
             "rigforge.mod-host-output.playback",
             "rigforge.mod-host-output",
-            "AUX0",
+            ["AUX0", "AUX1", "AUX2", "AUX3"],
             2.666666,
         )
 
@@ -44,10 +44,15 @@ class ModHostPipeWirePortTests(unittest.TestCase):
             self.assertIn("--channels", command)
             self.assertIn("--channel-map", command)
             self.assertIn("--latency", command)
+            self.assertEqual(command[4], "4")
             self.assertEqual(command[8], "2.66667")
-            self.assertIn("[AUX0]", command)
+            self.assertIn("[AUX0,AUX1,AUX2,AUX3]", command)
             self.assertIn("media.class=Audio/Sink", command[10])
-            self.assertIn("media.class=Audio/Source", command[12])
+        self.assertIn("media.class=Audio/Source", command[12])
+        self.assertEqual(
+            self.state["deployment"]["mod_host_ports"]["channel_map"],
+            ["AUX0", "AUX1", "AUX2", "AUX3"],
+        )
 
     def test_runner_refuses_duplicate_boundary_names(self):
         def runner(command, **_kwargs):

+ 11 - 2
tests/test_mod_ui_pedalboard.py

@@ -23,8 +23,12 @@ class ModUiPedalboardTests(unittest.TestCase):
         files = generate_bundle_files(self.state, ROOT)
         ttl = files["rigforge-guitar.ttl"].decode("utf-8")
 
-        self.assertIn('lv2:name "Rigforge Mod-Host Input"', ttl)
-        self.assertIn('lv2:name "Rigforge Mod-Host Output"', ttl)
+        self.assertIn(
+            'doap:name "Rigforge - Guitare NAM/IR, Basse, Micro, Synthé"',
+            ttl,
+        )
+        self.assertIn('lv2:name "Guitare - Entrée mod-ui"', ttl)
+        self.assertIn('lv2:name "Guitare - Sortie mod-ui"', ttl)
         self.assertIn("<control_in>", ttl)
         self.assertIn("<control_out>", ttl)
         self.assertIn("<midi_separated_mode>", ttl)
@@ -43,6 +47,11 @@ class ModUiPedalboardTests(unittest.TestCase):
         self.assertIn("ingen:head <rigforge_nam/input>", ttl)
         self.assertIn("ingen:tail <rigforge_ir/out>", ttl)
         self.assertIn("ingen:head <playback_1>", ttl)
+        for channel, label in ((2, "Basse"), (3, "Micro"), (4, "Synthé")):
+            self.assertIn(f'lv2:name "{label} - Entrée mod-ui"', ttl)
+            self.assertIn(f'lv2:name "{label} - Sortie mod-ui"', ttl)
+            self.assertIn(f"ingen:tail <capture_{channel}>", ttl)
+            self.assertIn(f"ingen:head <playback_{channel}>", ttl)
         self.assertEqual(files["addressings.json"], b"{}\n")
 
     def test_generated_bundle_tracks_current_desired_state(self):

+ 30 - 4
tests/test_pipewire_observer.py

@@ -24,9 +24,15 @@ CAPTURE_1 = "alsa_input.hw_U192k_0:capture_AUX1"
 CAPTURE_2 = "alsa_input.hw_U192k_0:capture_AUX2"
 CAPTURE_3 = "alsa_input.hw_U192k_0:capture_AUX3"
 AMP_INPUT = "rigforge.mod-host-input:playback_AUX0"
+AMP_INPUT_1 = "rigforge.mod-host-input:playback_AUX1"
+AMP_INPUT_2 = "rigforge.mod-host-input:playback_AUX2"
+AMP_INPUT_3 = "rigforge.mod-host-input:playback_AUX3"
 AMP_OUTPUT = "effect_0:output"
 CAB_INPUT = "effect_1:in"
 CAB_OUTPUT = "rigforge.mod-host-output:capture_AUX0"
+CAB_OUTPUT_1 = "rigforge.mod-host-output:capture_AUX1"
+CAB_OUTPUT_2 = "rigforge.mod-host-output:capture_AUX2"
+CAB_OUTPUT_3 = "rigforge.mod-host-output:capture_AUX3"
 MIX_INPUT_0 = "rigforge.direct-mix.input:playback_AUX0"
 MIX_INPUT_2 = "rigforge.direct-mix.input:playback_AUX2"
 MIX_INPUT_4 = "rigforge.direct-mix.input:playback_AUX4"
@@ -63,6 +69,12 @@ class PipeWireObserverTests(unittest.TestCase):
             for link in cls.state["routing"]["managed_links"]
             if (link["from"], link["to"]) in existing_test_edges
         ]
+        cls.state["routing"]["managed_links"].append(
+            {"from": CAPTURE_2, "to": MIX_INPUT_2, "status": "observed"}
+        )
+        cls.state["routing"]["managed_unlinks"] = [
+            cls.desired_state["routing"]["managed_unlinks"][0]
+        ]
 
     def test_empty_managed_set_ignores_wireplumber_hardware_links(self):
         state = copy.deepcopy(self.state)
@@ -224,16 +236,30 @@ class PipeWireObserverTests(unittest.TestCase):
         self.assertEqual(validate_managed_links(self.state), [])
         self.assertEqual(observe(self.state, links), [])
 
-    def test_desired_graph_keeps_direct_guitar_and_routes_looper_channels_through_mix(self):
+    def test_desired_graph_routes_all_sources_through_their_mod_ui_channel_to_mix_and_looper(self):
         links = {
             (link["from"], link["to"])
             for link in self.desired_state["routing"]["managed_links"]
         }
         self.assertIn((CAB_OUTPUT, MIX_INPUT_0), links)
         self.assertIn((CAB_OUTPUT, LOOPER_INPUT_1), links)
-        self.assertIn((CAPTURE_1, LOOPER_INPUT_2), links)
-        self.assertIn((CAPTURE_2, LOOPER_INPUT_3), links)
-        self.assertIn((CAPTURE_3, LOOPER_INPUT_4), links)
+        self.assertTrue(
+            {
+                (CAPTURE_0, AMP_INPUT),
+                (CAPTURE_1, AMP_INPUT_1),
+                (CAPTURE_2, AMP_INPUT_2),
+                (CAPTURE_3, AMP_INPUT_3),
+                (CAB_OUTPUT, MIX_INPUT_0),
+                (CAB_OUTPUT_1, "rigforge.direct-mix.input:playback_AUX1"),
+                (CAB_OUTPUT_2, MIX_INPUT_2),
+                (CAB_OUTPUT_3, "rigforge.direct-mix.input:playback_AUX3"),
+                (CAB_OUTPUT, LOOPER_INPUT_1),
+                (CAB_OUTPUT_1, LOOPER_INPUT_2),
+                (CAB_OUTPUT_2, LOOPER_INPUT_3),
+                (CAB_OUTPUT_3, LOOPER_INPUT_4),
+            }
+            <= links
+        )
         self.assertTrue(
             {
                 (LOOPER_OUTPUT_1, MIX_INPUT_4),

Някои файлове не бяха показани, защото твърде много файлове са промени