|
|
@@ -30,7 +30,7 @@ def apply(source_root):
|
|
|
replace_if_present(
|
|
|
app / "mod" / "host.py",
|
|
|
"from mod import (\n",
|
|
|
- "from mod.rigforge_pipewire import boundary_connection, connect_link, disconnect_link\n"
|
|
|
+ "from mod.rigforge_pipewire import boundary_connection, connect_link, disconnect_link, pedalboard_connection\n"
|
|
|
"from mod import (\n",
|
|
|
)
|
|
|
|
|
|
@@ -144,10 +144,6 @@ def apply(source_root):
|
|
|
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:
|
|
|
@@ -159,7 +155,7 @@ def apply(source_root):
|
|
|
if data[2] == "serial_midi_in":
|
|
|
''',
|
|
|
)
|
|
|
- replace_once(
|
|
|
+ replace_if_present(
|
|
|
app / "mod" / "host.py",
|
|
|
''' def connect(self, port_from, port_to, callback):
|
|
|
if (port_from, port_to) in self.connections:
|
|
|
@@ -177,7 +173,7 @@ def apply(source_root):
|
|
|
if (port_from, port_to) in self.connections:
|
|
|
''',
|
|
|
)
|
|
|
- replace_once(
|
|
|
+ replace_if_present(
|
|
|
app / "mod" / "host.py",
|
|
|
''' def host_callback(ok):
|
|
|
callback(ok)
|
|
|
@@ -190,8 +186,12 @@ def apply(source_root):
|
|
|
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:
|
|
|
+ ''' 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:
|
|
|
@@ -213,8 +213,12 @@ def apply(source_root):
|
|
|
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)
|
|
|
+ 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(
|
|
|
@@ -247,7 +251,7 @@ def apply(source_root):
|
|
|
def host_callback(ok):
|
|
|
''',
|
|
|
)
|
|
|
- replace_once(
|
|
|
+ replace_if_present(
|
|
|
app / "mod" / "host.py",
|
|
|
''' def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
|
|
|
mappedNewMidiIns, mappedNewMidiOuts):
|
|
|
@@ -286,21 +290,7 @@ def apply(source_root):
|
|
|
mappedNewMidiIns, mappedNewMidiOuts):
|
|
|
''',
|
|
|
)
|
|
|
- replace_if_present(
|
|
|
- app / "mod" / "host.py",
|
|
|
- ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
|
|
|
- if pipewire_link is not None:
|
|
|
- if not connect_link(*pipewire_link, retries=60, retry_interval=0.1):
|
|
|
- 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))
|
|
|
-''',
|
|
|
- ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
|
|
|
+ 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,
|
|
|
@@ -312,14 +302,29 @@ def apply(source_root):
|
|
|
continue
|
|
|
self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
|
|
|
self.connections.append((port_from, port_to))
|
|
|
-''',
|
|
|
- )
|
|
|
- replace_once(
|
|
|
- app / "mod" / "host.py",
|
|
|
- ''' self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
|
|
|
+ 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))
|
|
|
-''',
|
|
|
- ''' pipewire_link = self._rigforge_pipewire_boundary(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,
|
|
|
@@ -331,9 +336,29 @@ def apply(source_root):
|
|
|
continue
|
|
|
self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
|
|
|
self.connections.append((port_from, port_to))
|
|
|
-''',
|
|
|
- )
|
|
|
- replace_once(
|
|
|
+'''
|
|
|
+ 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(
|
|
|
app / "mod" / "host.py",
|
|
|
''' if len(data) == 3:
|
|
|
# Handle special cases
|
|
|
@@ -349,25 +374,7 @@ def apply(source_root):
|
|
|
''',
|
|
|
)
|
|
|
|
|
|
- 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(
|
|
|
+ replace_if_present(
|
|
|
app / "mod" / "host.py",
|
|
|
''' def host_callback(ok):
|
|
|
callback(ok)
|
|
|
@@ -437,7 +444,7 @@ def apply(source_root):
|
|
|
def host_callback(ok):
|
|
|
''',
|
|
|
)
|
|
|
- replace_once(
|
|
|
+ replace_if_present(
|
|
|
app / "mod" / "session.py",
|
|
|
''' # Set a plugin block position within the canvas
|
|
|
''',
|
|
|
@@ -461,7 +468,7 @@ def apply(source_root):
|
|
|
''',
|
|
|
)
|
|
|
|
|
|
- replace_once(
|
|
|
+ replace_if_present(
|
|
|
app / "mod" / "webserver.py",
|
|
|
''' elif cmd == "plugin_pos":
|
|
|
''',
|
|
|
@@ -482,12 +489,12 @@ def apply(source_root):
|
|
|
''',
|
|
|
)
|
|
|
|
|
|
- replace_once(
|
|
|
+ replace_if_present(
|
|
|
app / "server.py",
|
|
|
"os.environ['MOD_DEVICE_WEBSERVER_PORT'] = '8888'",
|
|
|
"os.environ.setdefault('MOD_DEVICE_WEBSERVER_PORT', '8888')",
|
|
|
)
|
|
|
- replace_once(
|
|
|
+ replace_if_present(
|
|
|
app / "server.py",
|
|
|
"os.environ['MOD_DEFAULT_PEDALBOARD'] = os.path.join(ROOT, 'default.pedalboard')",
|
|
|
"os.environ.setdefault('MOD_DEFAULT_PEDALBOARD', os.path.join(ROOT, 'default.pedalboard'))",
|