simple-carla 2.1.2__tar.gz → 2.3.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simple_carla
3
- Version: 2.1.2
3
+ Version: 2.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
@@ -18,7 +18,7 @@ build-backend = "flit_core.buildapi"
18
18
  sc-plugin-def = "simple_carla.scripts.sc_plugin_def:main"
19
19
 
20
20
  [bumpver]
21
- current_version = "2.1.2"
21
+ current_version = "2.3.0"
22
22
  version_pattern = "MAJOR.MINOR.PATCH"
23
23
  commit_message = "Bump version {old_version} -> {new_version}"
24
24
  commit = true
@@ -240,7 +240,7 @@ from carla_backend import (
240
240
  )
241
241
 
242
242
 
243
- __version__ = "2.1.2"
243
+ __version__ = "2.3.0"
244
244
 
245
245
 
246
246
  # -------------------------------------------------------------------
@@ -286,7 +286,7 @@ class _SimpleCarla(CarlaHostDLL):
286
286
  Inherited by: Carla, CarlaQt
287
287
  """
288
288
 
289
- idle_interval = 1 / 50
289
+ idle_interval = 1 / 20
290
290
  instance = None
291
291
  client_name = None
292
292
  _autoload_plugin = None
@@ -310,9 +310,10 @@ class _SimpleCarla(CarlaHostDLL):
310
310
  self._plugins = {} # Plugin, indexed on Carla -generated "plugin_id"
311
311
  self._clients = {} # PatchbayClient, indexed on Carla -generated "client_id"
312
312
  self._sys_clients = {} # SystemPatchbayClient, indexed on "client_name"
313
- self._connections = {} # PatchbayConnection, indexed on Carla -generated "connection_id"
314
- self._plugin_by_uuid = {} # Plugin, indexed on "uuid", used for identifying plugin during instantiation
315
- self._uuid = 0 # Current "uuid", incremented sequentially
313
+ self._connections = {} # PatchbayConnection,
314
+ # indexed on Carla -generated "connection_id"
315
+ self._plugin_by_uuid = {} # Plugin, indexed on "unique_name",
316
+ # used for identifying plugin during instantiation
316
317
  libname = "libcarla_standalone2.so"
317
318
  CarlaHostDLL.__init__(self, os.path.join(carla_binaries_path, libname), False)
318
319
 
@@ -1281,13 +1282,14 @@ class _SimpleCarla(CarlaHostDLL):
1281
1282
  def cb_plugin_added(self, plugin_id, plugin_type, carla_plugin_name):
1282
1283
  """
1283
1284
  After Carla adds a plugin, it signals this with an assigned plugin_id. This
1284
- function uses the uuid given to the Plugin by this class to retrieve the
1285
+ function uses the unique_name given to the Plugin by this class to retrieve the
1285
1286
  plugin from the "_plugin_by_uuid" dict, and add the association with the plugin_id in
1286
1287
  the "_plugins" dict.
1287
1288
  """
1288
1289
  if plugin_id in self._plugins:
1289
1290
  logging.error('cb_plugin_added: Cannot add plugin %s', plugin_id)
1290
- logging.error('"%s" - plugin %s already in _plugins"', carla_plugin_name, self._plugins[plugin_id])
1291
+ logging.error('"%s" - plugin %s already in _plugins"',
1292
+ carla_plugin_name, self._plugins[plugin_id])
1291
1293
  return
1292
1294
  if carla_plugin_name in self._plugin_by_uuid:
1293
1295
  self._plugins[plugin_id] = self._plugin_by_uuid[carla_plugin_name]
@@ -1299,11 +1301,11 @@ class _SimpleCarla(CarlaHostDLL):
1299
1301
  def cb_plugin_removed(self, plugin_id):
1300
1302
  if plugin_id in self._plugins:
1301
1303
  plugin = self._plugins[plugin_id]
1302
- if plugin.uuid in self._plugin_by_uuid:
1303
- del self._plugin_by_uuid[plugin.uuid]
1304
+ if plugin.unique_name in self._plugin_by_uuid:
1305
+ del self._plugin_by_uuid[plugin.unique_name]
1304
1306
  else:
1305
- logging.error('cb_plugin_removed: "%s" uuid %s not in self._plugin_by_uuid',
1306
- plugin, plugin.uuid)
1307
+ logging.error('cb_plugin_removed: "%s" unique_name %s not in self._plugin_by_uuid',
1308
+ plugin, plugin.unique_name)
1307
1309
  self._alert_plugin_removed(plugin)
1308
1310
  # Renumber plugins per Carla plugin_id conventions:
1309
1311
  for i in range(plugin_id, len(self._plugins) - 1):
@@ -1512,14 +1514,14 @@ class _SimpleCarla(CarlaHostDLL):
1512
1514
  # ================================================================================
1513
1515
 
1514
1516
  def add_plugin(self, plugin):
1515
- self._plugin_by_uuid[plugin.uuid] = plugin
1517
+ self._plugin_by_uuid[plugin.unique_name] = plugin
1516
1518
  if self.is_engine_running():
1517
1519
  if not self._add_plugin( # Carla parameter
1518
1520
  # ----------------------------------------- # ---------------
1519
1521
  plugin.plugin_def['build'], # btype
1520
1522
  plugin.plugin_def['type'], # ptype
1521
1523
  plugin.plugin_def['filename'], # filename
1522
- plugin.uuid, # name
1524
+ plugin.unique_name, # name
1523
1525
  plugin.plugin_def['label'], # label
1524
1526
  int(plugin.plugin_def['uniqueId'] or 0), # uniqueId
1525
1527
  None, # extraPtr
@@ -1553,12 +1555,12 @@ class _SimpleCarla(CarlaHostDLL):
1553
1555
  return self._plugins[plugin_id]
1554
1556
  raise IndexError()
1555
1557
 
1556
- def plugin_from_uuid(self, uuid):
1558
+ def plugin_from_uuid(self, unique_name):
1557
1559
  """
1558
1560
  Returns plugin.
1559
- "uuid" is the uuid property of a Plugin object, generated by this class.
1561
+ "unique_name" is the unique_name property of a Plugin object, generated by this class.
1560
1562
  """
1561
- return self._plugin_by_uuid[uuid] if uuid in self._plugin_by_uuid else None
1563
+ return self._plugin_by_uuid[unique_name] if unique_name in self._plugin_by_uuid else None
1562
1564
 
1563
1565
  def client(self, client_id):
1564
1566
  """
@@ -1705,7 +1707,7 @@ class _SimpleCarla(CarlaHostDLL):
1705
1707
  """
1706
1708
  if not self.patchbay_connect(True, port1.client_id, port1.port_id,
1707
1709
  port2.client_id, port2.port_id):
1708
- logging.error('Patchbay connect FAILED! %s -> %s', port1, port2)
1710
+ raise RuntimeError('Patchbay connect FAILED! %s -> %s', port1, port2)
1709
1711
 
1710
1712
  # -------------------------------------------------------------------
1711
1713
  # Plugin filename autoload trick
@@ -1793,26 +1795,21 @@ class _SimpleCarla(CarlaHostDLL):
1793
1795
  return None
1794
1796
 
1795
1797
  # -------------------------------------------------------------------
1796
- # Plugin autogenerate uuid / moniker helper
1798
+ # Plugin autogenerate unique_name / moniker helper
1797
1799
 
1798
- def provide_identity(self, plugin):
1800
+ def get_unique_name(self, plugin):
1799
1801
  """
1800
- Helper function which generates a unique "uuid" string for internal plugin
1801
- identification, and a unique "moniker" for human-readable identification.
1802
+ Generates a "unique_name" string for internal plugin identification.
1802
1803
  """
1803
- self._uuid += 1
1804
- plugin.uuid = '%03d' % self._uuid
1805
- while plugin.uuid in self._plugin_by_uuid:
1806
- self._uuid += 1
1807
- plugin.uuid = '%03d' % self._uuid
1808
- monikers = [ existing_plugin.moniker \
1804
+ unique_names = [ existing_plugin.unique_name \
1809
1805
  for existing_plugin in self._plugin_by_uuid.values() \
1810
1806
  if existing_plugin.original_plugin_name == plugin.original_plugin_name ]
1811
- idx = 1
1812
- plugin.moniker = '{} {}'.format(plugin.original_plugin_name, idx)
1813
- while plugin.moniker in monikers:
1807
+ idx = len(unique_names) + 1
1808
+ unique_name = f'{plugin.original_plugin_name} {idx}'
1809
+ while unique_name in unique_names:
1814
1810
  idx += 1
1815
- plugin.moniker = '{} {}'.format(plugin.original_plugin_name, idx)
1811
+ unique_name = f'{plugin.original_plugin_name} {idx}'
1812
+ return unique_name
1816
1813
 
1817
1814
 
1818
1815
  class Carla(_SimpleCarla):
@@ -2385,6 +2382,22 @@ class PatchbayClient:
2385
2382
  """
2386
2383
  return self._exclusive_clients(self.input_ports())
2387
2384
 
2385
+ def audio_input_clients(self):
2386
+ """
2387
+ Returns list of PatchbayClient.
2388
+ Return all clients which are connected to all of this PatchbayClient's audio input ports.
2389
+ (May return classes extending PatchbayClient, i.e. SystemPatchbayClient / Plugin)
2390
+ """
2391
+ return self._exclusive_clients(self.audio_ins())
2392
+
2393
+ def midi_input_clients(self):
2394
+ """
2395
+ Returns list of PatchbayClient.
2396
+ Return all clients which are connected to all of this PatchbayClient's midi input ports.
2397
+ (May return classes extending PatchbayClient, i.e. SystemPatchbayClient / Plugin)
2398
+ """
2399
+ return self._exclusive_clients(self.midi_ins())
2400
+
2388
2401
  def output_clients(self):
2389
2402
  """
2390
2403
  Returns list of PatchbayClient.
@@ -2393,11 +2406,27 @@ class PatchbayClient:
2393
2406
  """
2394
2407
  return self._exclusive_clients(self.output_ports())
2395
2408
 
2409
+ def audio_output_clients(self):
2410
+ """
2411
+ Returns list of PatchbayClient.
2412
+ Return all clients which are connected to all of this PatchbayClient's audio output ports.
2413
+ (May return classes extending PatchbayClient, i.e. SystemPatchbayClient / Plugin)
2414
+ """
2415
+ return self._exclusive_clients(self.audio_outs())
2416
+
2417
+ def midi_output_clients(self):
2418
+ """
2419
+ Returns list of PatchbayClient.
2420
+ Return all clients which are connected to all of this PatchbayClient's midi output ports.
2421
+ (May return classes extending PatchbayClient, i.e. SystemPatchbayClient / Plugin)
2422
+ """
2423
+ return self._exclusive_clients(self.midi_outs())
2424
+
2396
2425
  def _exclusive_clients(self, ports):
2397
2426
  """
2398
2427
  Returns list of PatchbayClient.
2399
2428
  Implements the reduction of port clients to an exlusive set.
2400
- Used by both "input_clients" and "output_clients" functions.
2429
+ Used by "input_clients", "audio_input_clients", "output_clients", etc.
2401
2430
  """
2402
2431
  return list(set( [
2403
2432
  client \
@@ -2685,7 +2714,7 @@ class Plugin(PatchbayClient):
2685
2714
  _cb_ready = None
2686
2715
  _cb_removed = None
2687
2716
 
2688
- _save_state_keys = [ 'uuid', 'moniker',
2717
+ _save_state_keys = [ 'unique_name', 'moniker',
2689
2718
  'active', 'volume', 'dry_wet', 'panning', 'balance_left', 'balance_right',
2690
2719
  'prefer_generic_dialog', 'send_all_sound_off', 'send_channel_pressure', 'send_control_changes',
2691
2720
  'send_note_aftertouch', 'send_pitchbend', 'send_program_changes', 'skip_sending_notes', 'force_stereo' ]
@@ -2732,11 +2761,8 @@ class Plugin(PatchbayClient):
2732
2761
  self.parameters = {} # Parameter objects. Key is parameter_id.
2733
2762
  self._midi_notes = np_zeros((16, 128), dtype=bool) # array for determining whether midi active.
2734
2763
 
2735
- if saved_state is None:
2736
- Carla.instance.provide_identity(self)
2737
- else:
2738
- self.uuid = saved_state["vars"]["uuid"]
2739
- self.moniker = saved_state["vars"]["moniker"]
2764
+ self.unique_name = Carla.instance.get_unique_name(self)
2765
+ self.moniker = self.unique_name if saved_state is None else saved_state["vars"]["moniker"]
2740
2766
 
2741
2767
  def add_to_carla(self):
2742
2768
  """
@@ -2913,7 +2939,7 @@ class Plugin(PatchbayClient):
2913
2939
  self.parameters[int(key)].value = value
2914
2940
 
2915
2941
  # -------------------------------------------------------------------
2916
- # Port parameter counts
2942
+ # Port counts
2917
2943
 
2918
2944
  @property
2919
2945
  def audio_in_count(self):
@@ -2943,19 +2969,8 @@ class Plugin(PatchbayClient):
2943
2969
  """
2944
2970
  return self._midi_out_count
2945
2971
 
2946
- @property
2947
- def input_parameter_count(self):
2948
- """
2949
- Returns (int)
2950
- """
2951
- return len(self.input_parameters())
2952
-
2953
- @property
2954
- def output_parameter_count(self):
2955
- """
2956
- Returns (int)
2957
- """
2958
- return len(self.output_parameters())
2972
+ # -------------------------------------------------------------------
2973
+ # Peaks
2959
2974
 
2960
2975
  @property
2961
2976
  def peak_mono(self):
@@ -2978,6 +2993,23 @@ class Plugin(PatchbayClient):
2978
2993
  """
2979
2994
  return Carla.instance.get_input_peak_value(self.plugin_id, False)
2980
2995
 
2996
+ # -------------------------------------------------------------------
2997
+ # Parameters
2998
+
2999
+ @property
3000
+ def input_parameter_count(self):
3001
+ """
3002
+ Returns (int)
3003
+ """
3004
+ return len(self.input_parameters())
3005
+
3006
+ @property
3007
+ def output_parameter_count(self):
3008
+ """
3009
+ Returns (int)
3010
+ """
3011
+ return len(self.output_parameters())
3012
+
2981
3013
  def input_parameters(self):
2982
3014
  """
2983
3015
  Returns a list of Parameter objects.
@@ -2990,9 +3022,22 @@ class Plugin(PatchbayClient):
2990
3022
  """
2991
3023
  return [ param for param in self.parameters.values() if param.is_used and param.is_output ]
2992
3024
 
3025
+ def parameter(self, name):
3026
+ """
3027
+ Returns the parameter with the given (str) "name"
3028
+
3029
+ Raises IndexError
3030
+ """
3031
+ for param in self.parameters.values():
3032
+ if param.name == name:
3033
+ return param
3034
+ raise IndexError
3035
+
3036
+ # -------------------------------------------------------------------
3037
+ # Str
3038
+
2993
3039
  def __str__(self):
2994
- return '<{0} "{1}" (uuid {2}, client_id {3})>'.format(
2995
- type(self).__name__, self.moniker, self.uuid, self.client_id)
3040
+ return f'<{type(self).__name__} "{self.unique_name}" (client_id {self.client_id})>'
2996
3041
 
2997
3042
  # -------------------------------------------------------------------
2998
3043
  # Functions called from Carla engine callbacks:
@@ -3462,8 +3507,13 @@ class Parameter:
3462
3507
  return '<Parameter [{0}] "{1}" {2} {3} value: {4}>'.format(
3463
3508
  self.index,
3464
3509
  self.name,
3465
- ("input" if self.is_input else "output" if self.is_output else "unused"),
3466
- ("integer" if self.is_integer else "Bool" if self.is_boolean else "log" if self.is_logarithmic else "float"),
3510
+ ("input" if self.is_input \
3511
+ else "output" if self.is_output \
3512
+ else "unused"),
3513
+ ("integer" if self.is_integer \
3514
+ else "Bool" if self.is_boolean \
3515
+ else "log" if self.is_logarithmic \
3516
+ else "float"),
3467
3517
  self.__value
3468
3518
  )
3469
3519
 
File without changes
File without changes
File without changes