|
|
@@ -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 + '">')
|
|
|
''',
|
|
|
)
|