simple-carla 1.1.2__py2.py3-none-any.whl → 1.3.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
simple_carla/__init__.py CHANGED
@@ -234,7 +234,7 @@ from carla_backend import (
234
234
  )
235
235
 
236
236
 
237
- __version__ = "1.1.2"
237
+ __version__ = "1.3.0"
238
238
 
239
239
 
240
240
  # -------------------------------------------------------------------
@@ -354,16 +354,6 @@ class _SimpleCarla(CarlaHostDLL):
354
354
  self.set_engine_option(ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT, self.showLogs, "")
355
355
  self.set_engine_option(ENGINE_OPTION_CLIENT_NAME_PREFIX, 0, self.client_name)
356
356
 
357
- # -------------------------------------------------------------------
358
- # Save state (pathcbay connections)
359
-
360
- def encode_saved_state(self):
361
- """
362
- Return an object comprised of only basic data types for serialization as JSON
363
- in prepration for saving the current project.
364
- """
365
- return [ conn.encode_saved_state() for conn in self._connections.values() ]
366
-
367
357
  # -------------------------------------------------------------------
368
358
  # Engine control / idle loop
369
359
 
@@ -700,7 +690,8 @@ class _SimpleCarla(CarlaHostDLL):
700
690
  Remove a plugin.
701
691
  plugin_id: Plugin to remove.
702
692
  """
703
- return bool(self.lib.carla_remove_plugin(self.handle, plugin_id))
693
+ if not self.lib.carla_remove_plugin(self.handle, plugin_id):
694
+ raise RuntimeError('Carla will not remove plugin')
704
695
 
705
696
  @polite_function
706
697
  def remove_all_plugins(self):
@@ -1515,6 +1506,7 @@ class _SimpleCarla(CarlaHostDLL):
1515
1506
  in_port.connection_added(connection)
1516
1507
  out_client.output_connection_change(connection, True)
1517
1508
  in_client.input_connection_change(connection, True)
1509
+ self._alert_connection_added(connection)
1518
1510
 
1519
1511
  def cb_patchbay_connection_removed(self, connection_id, zero_1, zero_2):
1520
1512
  """
@@ -1526,6 +1518,7 @@ class _SimpleCarla(CarlaHostDLL):
1526
1518
  connection.in_port.connection_removed(connection)
1527
1519
  self._clients[connection.out_port.client_id].output_connection_change(connection, False)
1528
1520
  self._clients[connection.in_port.client_id].input_connection_change(connection, False)
1521
+ self._alert_connection_removed(connection)
1529
1522
  del self._connections[connection_id]
1530
1523
  else:
1531
1524
  logging.warning('cb_patchbay_connection_removed: Connection %s not in ._connections',
@@ -1789,6 +1782,8 @@ class Carla(_SimpleCarla):
1789
1782
  _cb_client_removed = None
1790
1783
  _cb_port_added = None
1791
1784
  _cb_port_removed = None
1785
+ _cb_connection_added = None
1786
+ _cb_connection_removed = None
1792
1787
  _cb_plugin_removed = None
1793
1788
  _cb_last_plugin_removed = None
1794
1789
  _cb_engine_started = None
@@ -1819,6 +1814,12 @@ class Carla(_SimpleCarla):
1819
1814
  def on_port_removed(self, callback):
1820
1815
  self._cb_port_removed = callback
1821
1816
 
1817
+ def on_connection_added(self, callback):
1818
+ self._cb_connection_added = callback
1819
+
1820
+ def on_connection_removed(self, callback):
1821
+ self._cb_connection_removed = callback
1822
+
1822
1823
  def on_plugin_removed(self, callback):
1823
1824
  self._cb_plugin_removed = callback
1824
1825
 
@@ -2071,6 +2072,14 @@ class Carla(_SimpleCarla):
2071
2072
  if self._cb_port_removed is not None:
2072
2073
  self._cb_port_removed(port)
2073
2074
 
2075
+ def _alert_connection_added(self, connection):
2076
+ if self._cb_connection_added is not None:
2077
+ self._cb_connection_added(connection)
2078
+
2079
+ def _alert_connection_removed(self, connection):
2080
+ if self._cb_connection_removed is not None:
2081
+ self._cb_connection_removed(connection)
2082
+
2074
2083
  def _alert_plugin_removed(self, plugin):
2075
2084
  if self._cb_plugin_removed is not None:
2076
2085
  self._cb_plugin_removed(plugin)
@@ -2087,6 +2096,9 @@ class PatchbayClient:
2087
2096
  """
2088
2097
  Patchbay client which has patchbay ports.
2089
2098
 
2099
+ This class is not instantiated directly, but is inherited by
2100
+ SystemPatchbayClient and Plugin
2101
+
2090
2102
  Members of interest
2091
2103
  -------------------
2092
2104
  ports: (dict) PatchbayPort objects indexed on port_id
@@ -2517,12 +2529,14 @@ class PatchbayPort:
2517
2529
  Returns PatchbayClient.
2518
2530
  (May return class extending PatchbayClient, i.e. SystemPatchbayClient / Plugin)
2519
2531
  """
2532
+ # TODO: Make this a cached property
2520
2533
  return Carla.instance.client(self.client_id)
2521
2534
 
2522
2535
  def client_name(self):
2523
2536
  """
2524
2537
  Returns (str) the JACK client name of the PatchbayClient which "owns" this PatchbayPort.
2525
2538
  """
2539
+ # TODO: Make this a property
2526
2540
  return self.client().client_name
2527
2541
 
2528
2542
  def jack_name(self):
@@ -2677,6 +2691,7 @@ class Plugin(PatchbayClient):
2677
2691
  self.moniker = None
2678
2692
  self.ports_ready = False
2679
2693
  self.added_to_carla = False
2694
+ self.removing_from_carla = False
2680
2695
  self.is_ready = False
2681
2696
  self.can_drywet = False
2682
2697
  self.can_volume = False
@@ -2838,6 +2853,7 @@ class Plugin(PatchbayClient):
2838
2853
 
2839
2854
  (See also "got_removed")
2840
2855
  """
2856
+ self.removing_from_carla = True
2841
2857
  Carla.instance.remove_plugin(self.plugin_id)
2842
2858
 
2843
2859
  def plugin_id_changed(self, new_plugin_id):
@@ -2871,7 +2887,7 @@ class Plugin(PatchbayClient):
2871
2887
  for key, value in self.saved_state["vars"].items():
2872
2888
  setattr(self, key, value)
2873
2889
  for key, value in self.saved_state["parameters"].items():
2874
- if not value is None:
2890
+ if not value is None and int(key) in self.parameters:
2875
2891
  self.parameters[int(key)].value = value
2876
2892
 
2877
2893
  # -------------------------------------------------------------------
simple_carla/qt.py CHANGED
@@ -23,7 +23,7 @@ Qt -enabled classes which utilize signals rather than callbacks.
23
23
  import logging, traceback, os, sys
24
24
  import qt_extras.autofit
25
25
  from PyQt5.QtCore import QObject, pyqtSignal
26
- from simple_carla import _SimpleCarla, Plugin, PatchbayClient, PatchbayPort
26
+ from simple_carla import _SimpleCarla, Plugin, PatchbayClient, PatchbayPort, PatchbayConnection
27
27
 
28
28
  from carla_backend import (
29
29
 
@@ -92,6 +92,8 @@ class CarlaQt(_SimpleCarla, QObject):
92
92
  sig_patchbay_client_removed = pyqtSignal(PatchbayClient)
93
93
  sig_patchbay_port_added = pyqtSignal(PatchbayPort)
94
94
  sig_patchbay_port_removed = pyqtSignal(PatchbayPort)
95
+ sig_connection_added = pyqtSignal(PatchbayConnection)
96
+ sig_connection_removed = pyqtSignal(PatchbayConnection)
95
97
  sig_plugin_removed = pyqtSignal(QObject)
96
98
  sig_last_plugin_removed = pyqtSignal()
97
99
  sig_engine_started = pyqtSignal(int, int, int, int, float, str)
@@ -298,6 +300,12 @@ class CarlaQt(_SimpleCarla, QObject):
298
300
  def _alert_port_removed(self, port):
299
301
  self.sig_patchbay_port_removed.emit(port)
300
302
 
303
+ def _alert_connection_added(self, connection):
304
+ self.sig_connection_added.emit(connection)
305
+
306
+ def _alert_connection_removed(self, connection):
307
+ self.sig_connection_removed.emit(connection)
308
+
301
309
  def _alert_plugin_removed(self, plugin):
302
310
  self.sig_plugin_removed.emit(plugin)
303
311
 
@@ -327,26 +335,23 @@ class QtPlugin(Plugin, QObject):
327
335
  def __init__(self, plugin_def=None, saved_state=None):
328
336
  QObject.__init__(self)
329
337
  Plugin.__init__(self, plugin_def, saved_state)
330
- self.was_removed = False
331
338
 
332
339
  def ready(self):
333
340
  """
334
341
  Called after post_embed_init() and all ports ready.
335
342
  You can check the state of this plugin using the "Plugin.is_ready" property.
336
343
  """
337
- #logging.debug('%s ready', self)
338
344
  self.sig_ready.emit(self)
339
345
 
340
346
  def got_removed(self):
341
- self.was_removed = True
342
347
  self.sig_removed.emit(self)
343
348
 
344
349
  def input_connection_change(self, connection, state):
345
- if not self.was_removed:
350
+ if not self.removing_from_carla:
346
351
  self.sig_connection_change.emit(connection.in_port, connection.out_port, state)
347
352
 
348
353
  def output_connection_change(self, connection, state):
349
- if not self.was_removed:
354
+ if not self.removing_from_carla:
350
355
  self.sig_connection_change.emit(connection.out_port, connection.in_port, state)
351
356
 
352
357
 
File without changes
@@ -0,0 +1,69 @@
1
+ # simple_carla/scripts/sc_plugin_def.py
2
+ #
3
+ # Copyright 2025 Leon Dionne <ldionne@dridesign.sh.cn>
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ # MA 02110-1301, USA.
19
+ #
20
+ """
21
+ Allows the user to select a plugin using Carla's plugin dialog and writes it's
22
+ plugin_def usable by simple_carla.Plugin to STDOUT.
23
+ """
24
+ import argparse, logging, sys
25
+ from pretty_repr import Repr
26
+ from PyQt5.QtWidgets import QApplication, QMainWindow
27
+ from PyQt5.QtCore import QTimer
28
+ from simple_carla.plugin_dialog import CarlaPluginDialog
29
+
30
+ ESSENTIALS = ['name', 'build', 'type', 'filename', 'label', 'uniqueId']
31
+
32
+
33
+ class MainWindow(QMainWindow):
34
+
35
+ def __init__(self, options):
36
+ super().__init__()
37
+ self.options = options
38
+
39
+ def show_dialog(self):
40
+ self.plugin_def = CarlaPluginDialog(self).exec_dialog()
41
+ if self.plugin_def is not None:
42
+ if self.options.full:
43
+ print(Repr(self.plugin_def))
44
+ else:
45
+ print(Repr({ k:self.plugin_def[k] for k in ESSENTIALS }))
46
+ self.close()
47
+
48
+ def main():
49
+ p = argparse.ArgumentParser()
50
+ p.epilog = __doc__
51
+ p.add_argument("--full", "-f", action="store_true",
52
+ help="Spit out the full plugin definition.")
53
+ p.add_argument("--verbose", "-v", action="store_true",
54
+ help="Show detailed debug information")
55
+ options = p.parse_args()
56
+ logging.basicConfig(
57
+ level = logging.DEBUG if options.verbose else logging.ERROR,
58
+ format = "[%(filename)24s:%(lineno)-4d] %(levelname)-8s %(message)s"
59
+ )
60
+ app = QApplication([])
61
+ window = MainWindow(options)
62
+ window.show_dialog()
63
+
64
+
65
+ if __name__ == "__main__":
66
+ main()
67
+
68
+
69
+ # end simple_carla/scripts/sc_plugin_def.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simple_carla
3
- Version: 1.1.2
3
+ Version: 1.3.0
4
4
  Summary: An easy-to-use, object-oriented interface to the carla plugin host.
5
5
  Author-email: Leon Dionne <ldionne@dridesign.sh.cn>
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,10 @@
1
+ simple_carla/__init__.py,sha256=97L9pDoBy0vBjuZv1am1HmLuIDico4s4qNpsow5yUyw,107952
2
+ simple_carla/plugin_dialog.py,sha256=AHbEC-Sq_28QcJgZ-2gKJBaVEfa4-dEVQFvX9_7tYuk,1455
3
+ simple_carla/qt.py,sha256=It4X0hc57Lk-1ve1CX77Co503FWsxCaO7Ot9ynuDszQ,12618
4
+ simple_carla/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ simple_carla/scripts/sc_plugin_def.py,sha256=CVseichHuDCmGeD8v7CfHweeyHHXI60-RcvzU8OILqo,2214
6
+ simple_carla-1.3.0.dist-info/entry_points.txt,sha256=oqJRVQXTCIUOmspGNnqDWq9mhz397uoRMQQOhBFbIcs,73
7
+ simple_carla-1.3.0.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
8
+ simple_carla-1.3.0.dist-info/WHEEL,sha256=j3d_2VkBU36k09xOc4O9RZyJJ8uFqn4BR2AtKD7MOp8,99
9
+ simple_carla-1.3.0.dist-info/METADATA,sha256=8fjaucaoTHwJ0KuL0zIvdmBjA2ms2D8VuK5PYL77kAE,1717
10
+ simple_carla-1.3.0.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ sc-plugin-def=simple_carla.scripts.sc_plugin_def:main
3
+
@@ -1,7 +0,0 @@
1
- simple_carla/__init__.py,sha256=Ml_f1koyl8q70R_lPB4fSGPYB06zvUrFdbwx3dyrCVw,107403
2
- simple_carla/plugin_dialog.py,sha256=AHbEC-Sq_28QcJgZ-2gKJBaVEfa4-dEVQFvX9_7tYuk,1455
3
- simple_carla/qt.py,sha256=PMxfLEwdbU5Xkx8q-91MIxoylQ6oWE0QMPdKcC1FE8o,12366
4
- simple_carla-1.1.2.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
5
- simple_carla-1.1.2.dist-info/WHEEL,sha256=j3d_2VkBU36k09xOc4O9RZyJJ8uFqn4BR2AtKD7MOp8,99
6
- simple_carla-1.1.2.dist-info/METADATA,sha256=cSxUt39SUPDU68T4AuAGoKlPDHjKealCm7uhwyi4bL4,1717
7
- simple_carla-1.1.2.dist-info/RECORD,,