|
@@ -23,6 +23,238 @@ def replace_if_present(path, original, replacement):
|
|
|
path.write_text(text.replace(original, replacement), encoding="utf-8")
|
|
path.write_text(text.replace(original, replacement), encoding="utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def replace_host_method(path, method_name, replacement):
|
|
|
|
|
+ """Replace a complete Host method, independent of its upstream body variant."""
|
|
|
|
|
+ text = path.read_text(encoding="utf-8")
|
|
|
|
|
+ marker = f" def {method_name}("
|
|
|
|
|
+ start = text.find(marker)
|
|
|
|
|
+ if start < 0:
|
|
|
|
|
+ raise RuntimeError(f"could not find Host.{method_name} in {path}")
|
|
|
|
|
+ next_method = text.find("\n def ", start + len(marker))
|
|
|
|
|
+ end = len(text) if next_method < 0 else next_method + 1
|
|
|
|
|
+ replacement = replacement.rstrip() + "\n\n"
|
|
|
|
|
+ updated = text[:start] + replacement + text[end:]
|
|
|
|
|
+ if updated != text:
|
|
|
|
|
+ path.write_text(updated, encoding="utf-8")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def patch_host_connection_methods(host):
|
|
|
|
|
+ """Normalize manual connection handling across old Rigforge patch variants."""
|
|
|
|
|
+ replace_host_method(
|
|
|
|
|
+ host,
|
|
|
|
|
+ "connect",
|
|
|
|
|
+ ''' def connect(self, port_from, port_to, callback):
|
|
|
|
|
+ if (port_from, port_to) in self.connections:
|
|
|
|
|
+ logging.info("[host] NOTE: Requested connection already exists")
|
|
|
|
|
+ callback(True)
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ resolved = pedalboard_connection(
|
|
|
|
|
+ port_from, port_to, self.rigforge_capture_ports,
|
|
|
|
|
+ self.rigforge_playback_ports, self._fix_host_connection_port
|
|
|
|
|
+ )
|
|
|
|
|
+ if resolved is not None and resolved[0] == "pipewire":
|
|
|
|
|
+ pipewire_link = resolved[1]
|
|
|
|
|
+ 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)
|
|
|
|
|
+
|
|
|
|
|
+ if resolved is not None:
|
|
|
|
|
+ port_from_2, port_to_2 = resolved[1]
|
|
|
|
|
+ else:
|
|
|
|
|
+ port_from_2 = self._fix_host_connection_port(port_from)
|
|
|
|
|
+ port_to_2 = self._fix_host_connection_port(port_to)
|
|
|
|
|
+ self.send_modified(
|
|
|
|
|
+ "connect %s %s" % (port_from_2, port_to_2),
|
|
|
|
|
+ host_callback,
|
|
|
|
|
+ datatype='boolean'
|
|
|
|
|
+ )''',
|
|
|
|
|
+ )
|
|
|
|
|
+ text = host.read_text(encoding="utf-8")
|
|
|
|
|
+ if " def _rigforge_pipewire_boundary(" in text:
|
|
|
|
|
+ replace_host_method(
|
|
|
|
|
+ host,
|
|
|
|
|
+ "_rigforge_pipewire_boundary",
|
|
|
|
|
+ ''' def _rigforge_pipewire_boundary(self, port_from, port_to):
|
|
|
|
|
+ resolved = pedalboard_connection(
|
|
|
|
|
+ port_from, port_to, self.rigforge_capture_ports,
|
|
|
|
|
+ self.rigforge_playback_ports, self._fix_host_connection_port
|
|
|
|
|
+ )
|
|
|
|
|
+ if resolved is not None and resolved[0] == "pipewire":
|
|
|
|
|
+ return resolved[1]
|
|
|
|
|
+ return None''',
|
|
|
|
|
+ )
|
|
|
|
|
+ replace_host_method(
|
|
|
|
|
+ host,
|
|
|
|
|
+ "disconnect",
|
|
|
|
|
+ ''' def disconnect(self, port_from, port_to, callback):
|
|
|
|
|
+ resolved = pedalboard_connection(
|
|
|
|
|
+ port_from, port_to, self.rigforge_capture_ports,
|
|
|
|
|
+ self.rigforge_playback_ports, self._fix_host_connection_port
|
|
|
|
|
+ )
|
|
|
|
|
+ if resolved is not None and resolved[0] == "pipewire":
|
|
|
|
|
+ pipewire_link = resolved[1]
|
|
|
|
|
+ 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):
|
|
|
|
|
+ # Upstream disconnect failures are not fatal to the UI state.
|
|
|
|
|
+ callback(True)
|
|
|
|
|
+ self.msg_callback("disconnect %s %s" % (port_from, port_to))
|
|
|
|
|
+ if not ok:
|
|
|
|
|
+ logging.error("[host] disconnect '%s' => '%s' failed", port_from, port_to)
|
|
|
|
|
+ self.pedalboard_modified = True
|
|
|
|
|
+ try:
|
|
|
|
|
+ self.connections.remove((port_from, port_to))
|
|
|
|
|
+ except ValueError:
|
|
|
|
|
+ logging.info(
|
|
|
|
|
+ "[host] NOTE: Requested '%s' => '%s' connection doesn't exist",
|
|
|
|
|
+ port_from, port_to
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ if resolved is not None:
|
|
|
|
|
+ port_from_2, port_to_2 = resolved[1]
|
|
|
|
|
+ else:
|
|
|
|
|
+ try:
|
|
|
|
|
+ port_from_2 = self._fix_host_connection_port(port_from)
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ logging.info("[host] NOTE: Requested '%s' source port doesn't exist, assume disconnected", port_from)
|
|
|
|
|
+ return host_callback(True)
|
|
|
|
|
+ try:
|
|
|
|
|
+ port_to_2 = self._fix_host_connection_port(port_to)
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ logging.info("[host] NOTE: Requested '%s' target port doesn't exist, assume disconnected", port_to)
|
|
|
|
|
+ return host_callback(True)
|
|
|
|
|
+
|
|
|
|
|
+ if len(self.connections) == 0:
|
|
|
|
|
+ return host_callback(False)
|
|
|
|
|
+ self.send_modified(
|
|
|
|
|
+ "disconnect %s %s" % (port_from_2, port_to_2),
|
|
|
|
|
+ host_callback,
|
|
|
|
|
+ datatype='boolean'
|
|
|
|
|
+ )''',
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def patch_load_connections(host):
|
|
|
|
|
+ """Make pedalboard restore use the same resolution as manual UI actions."""
|
|
|
|
|
+ text = host.read_text(encoding="utf-8")
|
|
|
|
|
+ method_marker = " def load_pb_connections("
|
|
|
|
|
+ method_start = text.find(method_marker)
|
|
|
|
|
+ if method_start < 0:
|
|
|
|
|
+ raise RuntimeError(f"could not find Host.load_pb_connections in {host}")
|
|
|
|
|
+ block_start = text.find(" if doConnectionNow:", method_start)
|
|
|
|
|
+ block_end = text.find(
|
|
|
|
|
+ "\n elif aliasname1 is not None or aliasname2 is not None:",
|
|
|
|
|
+ block_start,
|
|
|
|
|
+ )
|
|
|
|
|
+ if block_start < 0 or block_end < 0:
|
|
|
|
|
+ raise RuntimeError(
|
|
|
|
|
+ f"could not identify mod-ui pedalboard connection restoration block in {host}"
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ replacement = ''' if doConnectionNow:
|
|
|
|
|
+ resolved = pedalboard_connection(
|
|
|
|
|
+ port_from, port_to, self.rigforge_capture_ports,
|
|
|
|
|
+ self.rigforge_playback_ports, self._fix_host_connection_port
|
|
|
|
|
+ )
|
|
|
|
|
+ if resolved is not None and resolved[0] == "pipewire":
|
|
|
|
|
+ self._rigforge_restore_pipewire_boundary(
|
|
|
|
|
+ resolved[1],
|
|
|
|
|
+ port_from,
|
|
|
|
|
+ port_to,
|
|
|
|
|
+ self.connections,
|
|
|
|
|
+ attempts_left=60
|
|
|
|
|
+ )
|
|
|
|
|
+ continue
|
|
|
|
|
+ try:
|
|
|
|
|
+ if resolved is not None:
|
|
|
|
|
+ port_from_2, port_to_2 = resolved[1]
|
|
|
|
|
+ else:
|
|
|
|
|
+ port_from_2 = self._fix_host_connection_port(port_from)
|
|
|
|
|
+ port_to_2 = self._fix_host_connection_port(port_to)
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ continue
|
|
|
|
|
+ self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
|
|
|
|
|
+ self.connections.append((port_from, port_to))
|
|
|
|
|
+ self.msg_callback("connect %s %s" % (port_from, port_to))'''
|
|
|
|
|
+ updated = text[:block_start] + replacement + text[block_end:]
|
|
|
|
|
+
|
|
|
|
|
+ if " def _rigforge_restore_pipewire_boundary(" not in updated:
|
|
|
|
|
+ marker = " def load_pb_connections("
|
|
|
|
|
+ position = updated.find(marker)
|
|
|
|
|
+ restore_method = ''' def _rigforge_restore_pipewire_boundary(
|
|
|
|
|
+ self, pipewire_link, port_from, port_to, connection_list, attempts_left
|
|
|
|
|
+ ):
|
|
|
|
|
+ if self.connections is not connection_list:
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ if connect_link(*pipewire_link):
|
|
|
|
|
+ edge = (port_from, port_to)
|
|
|
|
|
+ if edge not in connection_list:
|
|
|
|
|
+ connection_list.append(edge)
|
|
|
|
|
+ self.msg_callback("connect %s %s" % (port_from, port_to))
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ if attempts_left <= 1:
|
|
|
|
|
+ logging.error(
|
|
|
|
|
+ "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
|
|
|
|
|
+ pipewire_link[0], pipewire_link[1]
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ IOLoop.instance().call_later(
|
|
|
|
|
+ 0.5,
|
|
|
|
|
+ self._rigforge_restore_pipewire_boundary,
|
|
|
|
|
+ pipewire_link,
|
|
|
|
|
+ port_from,
|
|
|
|
|
+ port_to,
|
|
|
|
|
+ connection_list,
|
|
|
|
|
+ attempts_left - 1
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+'''
|
|
|
|
|
+ if position < 0:
|
|
|
|
|
+ raise RuntimeError(f"could not insert PipeWire restore method in {host}")
|
|
|
|
|
+ updated = updated[:position] + restore_method + updated[position:]
|
|
|
|
|
+
|
|
|
|
|
+ if updated != text:
|
|
|
|
|
+ host.write_text(updated, encoding="utf-8")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def apply(source_root):
|
|
def apply(source_root):
|
|
|
app = Path(source_root)
|
|
app = Path(source_root)
|
|
|
helper = Path(__file__).with_name("mod_ui_pipewire.py")
|
|
helper = Path(__file__).with_name("mod_ui_pipewire.py")
|
|
@@ -155,209 +387,6 @@ def apply(source_root):
|
|
|
if data[2] == "serial_midi_in":
|
|
if data[2] == "serial_midi_in":
|
|
|
''',
|
|
''',
|
|
|
)
|
|
)
|
|
|
- replace_if_present(
|
|
|
|
|
- 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_if_present(
|
|
|
|
|
- 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),
|
|
|
|
|
- self._fix_host_connection_port(port_to)), host_callback)
|
|
|
|
|
-''',
|
|
|
|
|
- ''' resolved = pedalboard_connection(
|
|
|
|
|
- port_from, port_to, self.rigforge_capture_ports,
|
|
|
|
|
- self.rigforge_playback_ports, self._fix_host_connection_port
|
|
|
|
|
- )
|
|
|
|
|
- if resolved is not None and resolved[0] == "pipewire":
|
|
|
|
|
- pipewire_link = resolved[1]
|
|
|
|
|
- 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)
|
|
|
|
|
-
|
|
|
|
|
- if resolved is not None:
|
|
|
|
|
- port_from_2, port_to_2 = resolved[1]
|
|
|
|
|
- else:
|
|
|
|
|
- port_from_2 = self._fix_host_connection_port(port_from)
|
|
|
|
|
- port_to_2 = self._fix_host_connection_port(port_to)
|
|
|
|
|
- self.send_modified("connect %s %s" % (port_from_2, port_to_2), host_callback)
|
|
|
|
|
-''',
|
|
|
|
|
- )
|
|
|
|
|
- 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_if_present(
|
|
|
|
|
- app / "mod" / "host.py",
|
|
|
|
|
- ''' def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
|
|
|
|
|
- mappedNewMidiIns, mappedNewMidiOuts):
|
|
|
|
|
-''',
|
|
|
|
|
- ''' def _rigforge_restore_pipewire_boundary(
|
|
|
|
|
- self, pipewire_link, port_from, port_to, connection_list, attempts_left
|
|
|
|
|
- ):
|
|
|
|
|
- if self.connections is not connection_list:
|
|
|
|
|
- return
|
|
|
|
|
-
|
|
|
|
|
- if connect_link(*pipewire_link):
|
|
|
|
|
- edge = (port_from, port_to)
|
|
|
|
|
- if edge not in connection_list:
|
|
|
|
|
- connection_list.append(edge)
|
|
|
|
|
- self.msg_callback("connect %s %s" % (port_from, port_to))
|
|
|
|
|
- return
|
|
|
|
|
-
|
|
|
|
|
- if attempts_left <= 1:
|
|
|
|
|
- logging.error(
|
|
|
|
|
- "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
|
|
|
|
|
- pipewire_link[0], pipewire_link[1]
|
|
|
|
|
- )
|
|
|
|
|
- return
|
|
|
|
|
-
|
|
|
|
|
- IOLoop.instance().call_later(
|
|
|
|
|
- 0.5,
|
|
|
|
|
- self._rigforge_restore_pipewire_boundary,
|
|
|
|
|
- pipewire_link,
|
|
|
|
|
- port_from,
|
|
|
|
|
- port_to,
|
|
|
|
|
- connection_list,
|
|
|
|
|
- attempts_left - 1
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
|
|
|
|
|
- mappedNewMidiIns, mappedNewMidiOuts):
|
|
|
|
|
-''',
|
|
|
|
|
- )
|
|
|
|
|
- load_connections_original = ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
|
|
|
|
|
- if pipewire_link is not None:
|
|
|
|
|
- self._rigforge_restore_pipewire_boundary(
|
|
|
|
|
- pipewire_link,
|
|
|
|
|
- port_from,
|
|
|
|
|
- port_to,
|
|
|
|
|
- self.connections,
|
|
|
|
|
- attempts_left=60
|
|
|
|
|
- )
|
|
|
|
|
- continue
|
|
|
|
|
- self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
|
|
|
|
|
- self.connections.append((port_from, port_to))
|
|
|
|
|
- self.msg_callback("connect %s %s" % (port_from, port_to))
|
|
|
|
|
-'''
|
|
|
|
|
- load_connections_patched = ''' resolved = pedalboard_connection(
|
|
|
|
|
- port_from, port_to, self.rigforge_capture_ports,
|
|
|
|
|
- self.rigforge_playback_ports, self._fix_host_connection_port
|
|
|
|
|
- )
|
|
|
|
|
- if resolved is not None and resolved[0] == "pipewire":
|
|
|
|
|
- pipewire_link = resolved[1]
|
|
|
|
|
- self._rigforge_restore_pipewire_boundary(
|
|
|
|
|
- pipewire_link,
|
|
|
|
|
- port_from,
|
|
|
|
|
- port_to,
|
|
|
|
|
- self.connections,
|
|
|
|
|
- attempts_left=60
|
|
|
|
|
- )
|
|
|
|
|
- continue
|
|
|
|
|
- if resolved is not None:
|
|
|
|
|
- port_from_2, port_to_2 = resolved[1]
|
|
|
|
|
- self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
|
|
|
|
|
- self.connections.append((port_from, port_to))
|
|
|
|
|
- self.msg_callback("connect %s %s" % (port_from, port_to))
|
|
|
|
|
-'''
|
|
|
|
|
- load_connections_old = ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
|
|
|
|
|
- if pipewire_link is not None:
|
|
|
|
|
- self._rigforge_restore_pipewire_boundary(
|
|
|
|
|
- pipewire_link,
|
|
|
|
|
- port_from,
|
|
|
|
|
- port_to,
|
|
|
|
|
- self.connections,
|
|
|
|
|
- attempts_left=60
|
|
|
|
|
- )
|
|
|
|
|
- continue
|
|
|
|
|
- self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
|
|
|
|
|
- self.connections.append((port_from, port_to))
|
|
|
|
|
-'''
|
|
|
|
|
- text = (app / "mod" / "host.py").read_text(encoding="utf-8")
|
|
|
|
|
- if load_connections_patched not in text:
|
|
|
|
|
- if text.count(load_connections_original) == 1:
|
|
|
|
|
- original = load_connections_original
|
|
|
|
|
- elif text.count(load_connections_old) == 1:
|
|
|
|
|
- original = load_connections_old
|
|
|
|
|
- else:
|
|
|
|
|
- marker = " def load_pb_connections(self, connections, mappedOldMidiIns"
|
|
|
|
|
- start = text.find(marker)
|
|
|
|
|
- body = text.find(" pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)", start)
|
|
|
|
|
- if start < 0 or body < 0:
|
|
|
|
|
- raise RuntimeError("could not identify mod-ui pedalboard connection restoration block")
|
|
|
|
|
- end = text.find("\n\n elif aliasname1", body)
|
|
|
|
|
- if end < 0:
|
|
|
|
|
- raise RuntimeError("could not find end of mod-ui pedalboard connection restoration block")
|
|
|
|
|
- original = text[body:end]
|
|
|
|
|
- replace_once(
|
|
|
|
|
- app / "mod" / "host.py",
|
|
|
|
|
- original,
|
|
|
|
|
- load_connections_patched.rstrip("\n"),
|
|
|
|
|
- )
|
|
|
|
|
replace_if_present(
|
|
replace_if_present(
|
|
|
app / "mod" / "host.py",
|
|
app / "mod" / "host.py",
|
|
|
''' if len(data) == 3:
|
|
''' if len(data) == 3:
|
|
@@ -373,77 +402,10 @@ def apply(source_root):
|
|
|
if data[2] == "serial_midi_in":
|
|
if data[2] == "serial_midi_in":
|
|
|
''',
|
|
''',
|
|
|
)
|
|
)
|
|
|
|
|
+ host_file = app / "mod" / "host.py"
|
|
|
|
|
+ patch_load_connections(host_file)
|
|
|
|
|
+ patch_host_connection_methods(host_file)
|
|
|
|
|
|
|
|
- replace_if_present(
|
|
|
|
|
- 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),
|
|
|
|
|
- self._fix_host_connection_port(port_to)), host_callback)
|
|
|
|
|
-''',
|
|
|
|
|
- ''' 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),
|
|
|
|
|
- self._fix_host_connection_port(port_to)), host_callback)
|
|
|
|
|
-''',
|
|
|
|
|
- )
|
|
|
|
|
- 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_if_present(
|
|
replace_if_present(
|
|
|
app / "mod" / "session.py",
|
|
app / "mod" / "session.py",
|
|
|
''' # Set a plugin block position within the canvas
|
|
''' # Set a plugin block position within the canvas
|