patch_mod_ui_rigforge.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. #!/usr/bin/env python3
  2. """Apply the small Rigforge integration patch to the pinned mod-ui source tree."""
  3. import sys
  4. from pathlib import Path
  5. def replace_once(path, original, replacement):
  6. text = path.read_text(encoding="utf-8")
  7. if replacement in text:
  8. return
  9. if text.count(original) != 1:
  10. raise RuntimeError(f"expected one upstream match in {path}")
  11. path.write_text(text.replace(original, replacement), encoding="utf-8")
  12. def replace_if_present(path, original, replacement):
  13. text = path.read_text(encoding="utf-8")
  14. if (replacement and replacement in text) or original not in text:
  15. return
  16. if text.count(original) != 1:
  17. raise RuntimeError(f"expected at most one upstream match in {path}")
  18. path.write_text(text.replace(original, replacement), encoding="utf-8")
  19. def apply(source_root):
  20. app = Path(source_root)
  21. helper = Path(__file__).with_name("mod_ui_pipewire.py")
  22. (app / "mod" / "rigforge_pipewire.py").write_bytes(helper.read_bytes())
  23. replace_if_present(
  24. app / "mod" / "host.py",
  25. "from mod import (\n",
  26. "from mod.rigforge_pipewire import boundary_connection, connect_link, disconnect_link\n"
  27. "from mod import (\n",
  28. )
  29. replace_if_present(
  30. app / "mod" / "host.py",
  31. ''' self.jack_hw_capture_prefix = "mod-host:out" if self.descriptor.get('has_noisegate', False) else "system:capture_"
  32. ''',
  33. ''' self.jack_hw_capture_prefix = "mod-host:out" if self.descriptor.get('has_noisegate', False) else "system:capture_"
  34. self.rigforge_capture_ports = {
  35. "capture_%d" % (index + 1): port
  36. for index, port in enumerate(
  37. os.environ.get("MOD_RIGFORGE_CAPTURE_PORTS", "").split(",")
  38. )
  39. if port
  40. }
  41. self.rigforge_playback_ports = {
  42. "playback_%d" % (index + 1): port
  43. for index, port in enumerate(
  44. os.environ.get("MOD_RIGFORGE_PLAYBACK_PORTS", "").split(",")
  45. )
  46. if port
  47. }
  48. ''',
  49. )
  50. replace_if_present(
  51. app / "mod" / "host.py",
  52. ''' self.rigforge_capture_port = os.environ.get("MOD_RIGFORGE_CAPTURE_PORT")
  53. self.rigforge_playback_port = os.environ.get("MOD_RIGFORGE_PLAYBACK_PORT")
  54. ''',
  55. "",
  56. )
  57. replace_if_present(
  58. app / "mod" / "host.py",
  59. ''' if self.rigforge_capture_port and self.rigforge_playback_port:
  60. # These graph symbols map to Rigforge's stable virtual PipeWire boundary ports.
  61. self.audioportsIn = ["capture_1"]
  62. self.audioportsOut = ["playback_1"]
  63. ''',
  64. ''' if self.rigforge_capture_ports and self.rigforge_playback_ports:
  65. # These graph symbols map to Rigforge's stable virtual PipeWire boundary ports.
  66. self.audioportsIn = [
  67. "capture_%d" % index
  68. for index in range(1, len(self.rigforge_capture_ports) + 1)
  69. ]
  70. self.audioportsOut = [
  71. "playback_%d" % index
  72. for index in range(1, len(self.rigforge_playback_ports) + 1)
  73. ]
  74. ''',
  75. )
  76. replace_once(
  77. app / "mod" / "host.py",
  78. ''' for port in get_jack_hardware_ports(True, False):
  79. client_name, port_name = port.split(":",1)
  80. if client_name == "mod-spi2jack":
  81. cv_port_name = CV_PREFIX + port_name
  82. self.cvportsIn.append(cv_port_name)
  83. self.addressings.add_hw_cv_port('/cv/graph/' + cv_port_name)
  84. else:
  85. self.audioportsIn.append(port_name)
  86. for port in get_jack_hardware_ports(True, True):
  87. client_name, port_name = port.split(":",1)
  88. if client_name == "mod-jack2spi":
  89. self.cvportsOut.append(CV_PREFIX + port_name)
  90. else:
  91. self.audioportsOut.append(port_name)
  92. ''',
  93. ''' if self.rigforge_capture_ports and self.rigforge_playback_ports:
  94. # These graph symbols map to Rigforge's stable virtual PipeWire boundary ports.
  95. self.audioportsIn = [
  96. "capture_%d" % index
  97. for index in range(1, len(self.rigforge_capture_ports) + 1)
  98. ]
  99. self.audioportsOut = [
  100. "playback_%d" % index
  101. for index in range(1, len(self.rigforge_playback_ports) + 1)
  102. ]
  103. else:
  104. for port in get_jack_hardware_ports(True, False):
  105. client_name, port_name = port.split(":",1)
  106. if client_name == "mod-spi2jack":
  107. cv_port_name = CV_PREFIX + port_name
  108. self.cvportsIn.append(cv_port_name)
  109. self.addressings.add_hw_cv_port('/cv/graph/' + cv_port_name)
  110. else:
  111. self.audioportsIn.append(port_name)
  112. for port in get_jack_hardware_ports(True, True):
  113. client_name, port_name = port.split(":",1)
  114. if client_name == "mod-jack2spi":
  115. self.cvportsOut.append(CV_PREFIX + port_name)
  116. else:
  117. self.audioportsOut.append(port_name)
  118. ''',
  119. )
  120. replace_if_present(
  121. app / "mod" / "host.py",
  122. ''' if data[2] == "capture_1" and self.rigforge_capture_port:
  123. return self.rigforge_capture_port
  124. if data[2] == "playback_1" and self.rigforge_playback_port:
  125. return self.rigforge_playback_port
  126. ''',
  127. ''' if data[2] in self.rigforge_capture_ports:
  128. return self.rigforge_capture_ports[data[2]]
  129. if data[2] in self.rigforge_playback_ports:
  130. return self.rigforge_playback_ports[data[2]]
  131. ''',
  132. )
  133. replace_if_present(
  134. app / "mod" / "host.py",
  135. ''' if len(data) == 3:
  136. # Handle special cases
  137. if data[2] in self.rigforge_capture_ports:
  138. return self.rigforge_capture_ports[data[2]]
  139. if data[2] in self.rigforge_playback_ports:
  140. return self.rigforge_playback_ports[data[2]]
  141. if data[2] == "serial_midi_in":
  142. ''' + " \n",
  143. ''' if len(data) == 3:
  144. # Handle special cases
  145. if data[2] in self.rigforge_capture_ports:
  146. return self.rigforge_capture_ports[data[2]]
  147. if data[2] in self.rigforge_playback_ports:
  148. return self.rigforge_playback_ports[data[2]]
  149. if data[2] == "serial_midi_in":
  150. ''',
  151. )
  152. replace_once(
  153. app / "mod" / "host.py",
  154. ''' def connect(self, port_from, port_to, callback):
  155. if (port_from, port_to) in self.connections:
  156. ''',
  157. ''' def _rigforge_pipewire_boundary(self, port_from, port_to):
  158. return boundary_connection(
  159. port_from,
  160. port_to,
  161. self.rigforge_capture_ports,
  162. self.rigforge_playback_ports,
  163. self._fix_host_connection_port,
  164. )
  165. def connect(self, port_from, port_to, callback):
  166. if (port_from, port_to) in self.connections:
  167. ''',
  168. )
  169. replace_once(
  170. app / "mod" / "host.py",
  171. ''' def host_callback(ok):
  172. callback(ok)
  173. if ok:
  174. self.connections.append((port_from, port_to))
  175. self.msg_callback("connect %s %s" % (port_from, port_to))
  176. else:
  177. logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
  178. self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
  179. self._fix_host_connection_port(port_to)), host_callback)
  180. ''',
  181. ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
  182. if pipewire_link is not None:
  183. ok = connect_link(*pipewire_link)
  184. callback(ok)
  185. if ok:
  186. self.connections.append((port_from, port_to))
  187. self.pedalboard_modified = True
  188. self.msg_callback("connect %s %s" % (port_from, port_to))
  189. else:
  190. logging.error(
  191. "[host] PipeWire backend failed to connect ports: '%s' => '%s'",
  192. pipewire_link[0], pipewire_link[1]
  193. )
  194. return
  195. def host_callback(ok):
  196. callback(ok)
  197. if ok:
  198. self.connections.append((port_from, port_to))
  199. self.msg_callback("connect %s %s" % (port_from, port_to))
  200. else:
  201. logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
  202. self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
  203. self._fix_host_connection_port(port_to)), host_callback)
  204. ''',
  205. )
  206. replace_once(
  207. app / "mod" / "host.py",
  208. ''' def disconnect(self, port_from, port_to, callback):
  209. def host_callback(ok):
  210. ''',
  211. ''' def disconnect(self, port_from, port_to, callback):
  212. pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
  213. if pipewire_link is not None:
  214. ok = disconnect_link(*pipewire_link)
  215. callback(ok)
  216. if ok:
  217. self.msg_callback("disconnect %s %s" % (port_from, port_to))
  218. self.pedalboard_modified = True
  219. try:
  220. self.connections.remove((port_from, port_to))
  221. except ValueError:
  222. logging.info(
  223. "[host] Requested '%s' => '%s' connection was not in the UI state",
  224. port_from, port_to
  225. )
  226. else:
  227. logging.error(
  228. "[host] PipeWire backend failed to disconnect ports: '%s' => '%s'",
  229. pipewire_link[0], pipewire_link[1]
  230. )
  231. return
  232. def host_callback(ok):
  233. ''',
  234. )
  235. replace_once(
  236. app / "mod" / "host.py",
  237. ''' def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
  238. mappedNewMidiIns, mappedNewMidiOuts):
  239. ''',
  240. ''' def _rigforge_restore_pipewire_boundary(
  241. self, pipewire_link, port_from, port_to, connection_list, attempts_left
  242. ):
  243. if self.connections is not connection_list:
  244. return
  245. if connect_link(*pipewire_link):
  246. edge = (port_from, port_to)
  247. if edge not in connection_list:
  248. connection_list.append(edge)
  249. self.msg_callback("connect %s %s" % (port_from, port_to))
  250. return
  251. if attempts_left <= 1:
  252. logging.error(
  253. "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
  254. pipewire_link[0], pipewire_link[1]
  255. )
  256. return
  257. IOLoop.instance().call_later(
  258. 0.5,
  259. self._rigforge_restore_pipewire_boundary,
  260. pipewire_link,
  261. port_from,
  262. port_to,
  263. connection_list,
  264. attempts_left - 1
  265. )
  266. def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts,
  267. mappedNewMidiIns, mappedNewMidiOuts):
  268. ''',
  269. )
  270. replace_if_present(
  271. app / "mod" / "host.py",
  272. ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
  273. if pipewire_link is not None:
  274. if not connect_link(*pipewire_link, retries=60, retry_interval=0.1):
  275. logging.error(
  276. "[host] PipeWire backend failed to restore ports: '%s' => '%s'",
  277. pipewire_link[0], pipewire_link[1]
  278. )
  279. continue
  280. else:
  281. self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
  282. self.connections.append((port_from, port_to))
  283. ''',
  284. ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
  285. if pipewire_link is not None:
  286. self._rigforge_restore_pipewire_boundary(
  287. pipewire_link,
  288. port_from,
  289. port_to,
  290. self.connections,
  291. attempts_left=60
  292. )
  293. continue
  294. self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
  295. self.connections.append((port_from, port_to))
  296. ''',
  297. )
  298. replace_once(
  299. app / "mod" / "host.py",
  300. ''' self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
  301. self.connections.append((port_from, port_to))
  302. ''',
  303. ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
  304. if pipewire_link is not None:
  305. self._rigforge_restore_pipewire_boundary(
  306. pipewire_link,
  307. port_from,
  308. port_to,
  309. self.connections,
  310. attempts_left=60
  311. )
  312. continue
  313. self.send_notmodified("connect %s %s" % (port_from_2, port_to_2))
  314. self.connections.append((port_from, port_to))
  315. ''',
  316. )
  317. replace_once(
  318. app / "mod" / "host.py",
  319. ''' if len(data) == 3:
  320. # Handle special cases
  321. if data[2] == "serial_midi_in":
  322. ''',
  323. ''' if len(data) == 3:
  324. # Handle special cases
  325. if data[2] in self.rigforge_capture_ports:
  326. return self.rigforge_capture_ports[data[2]]
  327. if data[2] in self.rigforge_playback_ports:
  328. return self.rigforge_playback_ports[data[2]]
  329. if data[2] == "serial_midi_in":
  330. ''',
  331. )
  332. replace_once(
  333. app / "mod" / "host.py",
  334. ''' def connect(self, port_from, port_to, callback):
  335. if (port_from, port_to) in self.connections:
  336. ''',
  337. ''' def _rigforge_pipewire_boundary(self, port_from, port_to):
  338. return boundary_connection(
  339. port_from,
  340. port_to,
  341. self.rigforge_capture_ports,
  342. self.rigforge_playback_ports,
  343. self._fix_host_connection_port,
  344. )
  345. def connect(self, port_from, port_to, callback):
  346. if (port_from, port_to) in self.connections:
  347. ''',
  348. )
  349. replace_once(
  350. app / "mod" / "host.py",
  351. ''' def host_callback(ok):
  352. callback(ok)
  353. if ok:
  354. self.connections.append((port_from, port_to))
  355. self.msg_callback("connect %s %s" % (port_from, port_to))
  356. else:
  357. logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
  358. self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
  359. self._fix_host_connection_port(port_to)), host_callback)
  360. ''',
  361. ''' pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
  362. if pipewire_link is not None:
  363. ok = connect_link(*pipewire_link)
  364. callback(ok)
  365. if ok:
  366. self.connections.append((port_from, port_to))
  367. self.pedalboard_modified = True
  368. self.msg_callback("connect %s %s" % (port_from, port_to))
  369. else:
  370. logging.error(
  371. "[host] PipeWire backend failed to connect ports: '%s' => '%s'",
  372. pipewire_link[0], pipewire_link[1]
  373. )
  374. return
  375. def host_callback(ok):
  376. callback(ok)
  377. if ok:
  378. self.connections.append((port_from, port_to))
  379. self.msg_callback("connect %s %s" % (port_from, port_to))
  380. else:
  381. logging.error("[host] backend failed to connect ports: '%s' => '%s'", port_from, port_to)
  382. self.send_modified("connect %s %s" % (self._fix_host_connection_port(port_from),
  383. self._fix_host_connection_port(port_to)), host_callback)
  384. ''',
  385. )
  386. replace_once(
  387. app / "mod" / "host.py",
  388. ''' def disconnect(self, port_from, port_to, callback):
  389. def host_callback(ok):
  390. ''',
  391. ''' def disconnect(self, port_from, port_to, callback):
  392. pipewire_link = self._rigforge_pipewire_boundary(port_from, port_to)
  393. if pipewire_link is not None:
  394. ok = disconnect_link(*pipewire_link)
  395. callback(ok)
  396. if ok:
  397. self.msg_callback("disconnect %s %s" % (port_from, port_to))
  398. self.pedalboard_modified = True
  399. try:
  400. self.connections.remove((port_from, port_to))
  401. except ValueError:
  402. logging.info(
  403. "[host] Requested '%s' => '%s' connection was not in the UI state",
  404. port_from, port_to
  405. )
  406. else:
  407. logging.error(
  408. "[host] PipeWire backend failed to disconnect ports: '%s' => '%s'",
  409. pipewire_link[0], pipewire_link[1]
  410. )
  411. return
  412. def host_callback(ok):
  413. ''',
  414. )
  415. replace_once(
  416. app / "mod" / "session.py",
  417. ''' # Set a plugin block position within the canvas
  418. ''',
  419. ''' def ws_rigforge_patch_set(self, request_id, instance, uri, valuetype, valuedata, ws):
  420. if valuetype != "p":
  421. ws.write_message("rigforge_patch_set_ack %s 0" % request_id)
  422. return
  423. def completed(ok):
  424. status = 1 if ok else 0
  425. if ok:
  426. self.msg_callback_broadcast(
  427. "patch_set %s 1 %s %c %s" % (instance, uri, valuetype, valuedata),
  428. ws,
  429. )
  430. ws.write_message("rigforge_patch_set_ack %s %d" % (request_id, status))
  431. self.host.patch_set(instance, uri, valuedata, completed)
  432. # Set a plugin block position within the canvas
  433. ''',
  434. )
  435. replace_once(
  436. app / "mod" / "webserver.py",
  437. ''' elif cmd == "plugin_pos":
  438. ''',
  439. ''' elif cmd == "rigforge_patch_set":
  440. data = data[1].split(" ", 4)
  441. if len(data) != 5:
  442. self.write_message("rigforge_patch_set_ack invalid 0")
  443. return
  444. request_id, inst, uri, vtype, value = data
  445. if not request_id.isalnum():
  446. self.write_message("rigforge_patch_set_ack invalid 0")
  447. return
  448. SESSION.ws_rigforge_patch_set(
  449. request_id, inst, uri, vtype, value, self
  450. )
  451. elif cmd == "plugin_pos":
  452. ''',
  453. )
  454. replace_once(
  455. app / "server.py",
  456. "os.environ['MOD_DEVICE_WEBSERVER_PORT'] = '8888'",
  457. "os.environ.setdefault('MOD_DEVICE_WEBSERVER_PORT', '8888')",
  458. )
  459. replace_once(
  460. app / "server.py",
  461. "os.environ['MOD_DEFAULT_PEDALBOARD'] = os.path.join(ROOT, 'default.pedalboard')",
  462. "os.environ.setdefault('MOD_DEFAULT_PEDALBOARD', os.path.join(ROOT, 'default.pedalboard'))",
  463. )
  464. replace_if_present(
  465. app / "html" / "js" / "pedalboard.js",
  466. ''' var captureTitles = {
  467. 1: 'Guitar - Mod-UI Input',
  468. 2: 'Bass - Mod-UI Input',
  469. 3: 'Micro - Mod-UI Input',
  470. 4: 'Synth - Mod-UI Input'
  471. }
  472. var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
  473. var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
  474. ''',
  475. ''' var captureTitles = {
  476. 1: 'Guitare - Entrée mod-ui',
  477. 2: 'Basse - Entrée mod-ui',
  478. 3: 'Micro - Entrée mod-ui',
  479. 4: 'Synthé - Entrée mod-ui'
  480. }
  481. var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
  482. var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
  483. ''',
  484. )
  485. replace_if_present(
  486. app / "html" / "js" / "pedalboard.js",
  487. ''' var playbackTitles = {
  488. 1: 'Guitar - Mod-UI Output',
  489. 2: 'Bass - Mod-UI Output',
  490. 3: 'Micro - Mod-UI Output',
  491. 4: 'Synth - Mod-UI Output'
  492. }
  493. var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
  494. var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
  495. ''',
  496. ''' var playbackTitles = {
  497. 1: 'Guitare - Sortie mod-ui',
  498. 2: 'Basse - Sortie mod-ui',
  499. 3: 'Micro - Sortie mod-ui',
  500. 4: 'Synthé - Sortie mod-ui'
  501. }
  502. var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
  503. var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
  504. ''',
  505. )
  506. replace_if_present(
  507. app / "html" / "js" / "pedalboard.js",
  508. ''' var captureTitle = (i === 1) ? 'Rigforge Mod-Host Input' : ('Hardware Capture ' + i)
  509. var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
  510. ''',
  511. ''' var captureTitles = {
  512. 1: 'Guitare - Entrée mod-ui',
  513. 2: 'Basse - Entrée mod-ui',
  514. 3: 'Micro - Entrée mod-ui',
  515. 4: 'Synthé - Entrée mod-ui'
  516. }
  517. var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
  518. var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
  519. ''',
  520. )
  521. replace_if_present(
  522. app / "html" / "js" / "pedalboard.js",
  523. ''' var playbackTitle = (i === 1) ? 'Rigforge Mod-Host Output' : ('Hardware Playback ' + i)
  524. var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
  525. ''',
  526. ''' var playbackTitles = {
  527. 1: 'Guitare - Sortie mod-ui',
  528. 2: 'Basse - Sortie mod-ui',
  529. 3: 'Micro - Sortie mod-ui',
  530. 4: 'Synthé - Sortie mod-ui'
  531. }
  532. var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
  533. var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
  534. ''',
  535. )
  536. replace_once(
  537. app / "html" / "js" / "pedalboard.js",
  538. ''' var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="Hardware Capture ' + i + '">')
  539. ''',
  540. ''' var captureTitles = {
  541. 1: 'Guitare - Entrée mod-ui',
  542. 2: 'Basse - Entrée mod-ui',
  543. 3: 'Micro - Entrée mod-ui',
  544. 4: 'Synthé - Entrée mod-ui'
  545. }
  546. var captureTitle = captureTitles[i] || ('Hardware Capture ' + i)
  547. var hw = $('<div class="ignore-arrive hardware-output" mod-port-index="' + i + '" title="' + captureTitle + '">')
  548. ''',
  549. )
  550. replace_once(
  551. app / "html" / "js" / "pedalboard.js",
  552. ''' var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="Hardware Playback ' + i + '">')
  553. ''',
  554. ''' var playbackTitles = {
  555. 1: 'Guitare - Sortie mod-ui',
  556. 2: 'Basse - Sortie mod-ui',
  557. 3: 'Micro - Sortie mod-ui',
  558. 4: 'Synthé - Sortie mod-ui'
  559. }
  560. var playbackTitle = playbackTitles[i] || ('Hardware Playback ' + i)
  561. var hw = $('<div class="ignore-arrive hardware-input" mod-port-index="' + i + '" title="' + playbackTitle + '">')
  562. ''',
  563. )
  564. js_file = app / "html" / "js" / "pedalboard.js"
  565. if not js_file.read_bytes().endswith(b"\n"):
  566. js_file.write_bytes(js_file.read_bytes() + b"\n")
  567. if __name__ == "__main__":
  568. if len(sys.argv) != 2:
  569. raise SystemExit("Usage: patch_mod_ui_rigforge.py path/to/mod-ui/app")
  570. apply(Path(sys.argv[1]))