simple-carla 1.3.0__py2.py3-none-any.whl → 1.4.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
@@ -22,7 +22,7 @@ An easy-to-use, object-oriented interface to the carla plugin host.
22
22
  """
23
23
  import os, sys, threading, time, logging, traceback
24
24
  from ctypes import byref, cast, c_char_p, c_void_p, POINTER
25
- from functools import wraps, cache
25
+ from functools import wraps
26
26
  from struct import pack
27
27
  from numpy import zeros as np_zeros
28
28
  from log_soso import StreamToLogger
@@ -233,8 +233,10 @@ from carla_backend import (
233
233
  FILE_CALLBACK_SAVE
234
234
  )
235
235
 
236
+ from resources_rc import qCleanupResources
236
237
 
237
- __version__ = "1.3.0"
238
+
239
+ __version__ = "1.4.0"
238
240
 
239
241
 
240
242
  # -------------------------------------------------------------------
@@ -698,6 +700,8 @@ class _SimpleCarla(CarlaHostDLL):
698
700
  """
699
701
  Remove all plugins.
700
702
  """
703
+ for plugin in self._plugin_by_uuid.values():
704
+ plugin.removing_from_carla = True
701
705
  return bool(self.lib.carla_remove_all_plugins(self.handle))
702
706
 
703
707
  @polite_function
@@ -1532,7 +1536,7 @@ class _SimpleCarla(CarlaHostDLL):
1532
1536
  self._plugin_by_uuid[plugin.uuid] = plugin
1533
1537
  if self.is_engine_running():
1534
1538
  if not self._add_plugin( # Carla parameter
1535
- # ---------------
1539
+ # ----------------------------------------- # ---------------
1536
1540
  plugin.plugin_def['build'], # btype
1537
1541
  plugin.plugin_def['type'], # ptype
1538
1542
  plugin.plugin_def['filename'], # filename
@@ -1541,7 +1545,7 @@ class _SimpleCarla(CarlaHostDLL):
1541
1545
  int(plugin.plugin_def['uniqueId'] or 0), # uniqueId
1542
1546
  None, # extraPtr
1543
1547
  PLUGIN_OPTIONS_NULL # options
1544
- # ---------------
1548
+ # ----------------------------------------- # ---------------
1545
1549
  ): raise Exception("Failed to add plugin")
1546
1550
 
1547
1551
  # -------------------------------------------------------------------
@@ -2678,7 +2682,7 @@ class Plugin(PatchbayClient):
2678
2682
  # -------------------------------------------------------------------
2679
2683
  # Internal lifecycle events
2680
2684
 
2681
- def __init__(self, plugin_def=None, saved_state=None):
2685
+ def __init__(self, plugin_def = None, saved_state = None):
2682
2686
  if plugin_def is None:
2683
2687
  if self.plugin_def is None:
2684
2688
  raise RuntimeError("No definition for plugin")
@@ -2891,7 +2895,7 @@ class Plugin(PatchbayClient):
2891
2895
  self.parameters[int(key)].value = value
2892
2896
 
2893
2897
  # -------------------------------------------------------------------
2894
- # Misc functions
2898
+ # Port parameter counts
2895
2899
 
2896
2900
  @property
2897
2901
  def audio_in_count(self):
@@ -2995,7 +2999,7 @@ class Plugin(PatchbayClient):
2995
2999
 
2996
3000
  def parameter_internal_value_changed(self, parameter, value):
2997
3001
  """
2998
- Called by the Carls host engine when the internal value of a parameter has changed.
3002
+ Called by the Carla host engine when the internal value of a parameter has changed.
2999
3003
  "parameter" is a Parameter object.
3000
3004
  "value" is the new value of the Parameter.
3001
3005
  The value of the Parameter object will have already been set when this is called.
@@ -3227,7 +3231,7 @@ class Plugin(PatchbayClient):
3227
3231
  self._ctrl_channel = value
3228
3232
 
3229
3233
  # -------------------------------------------------------------------
3230
- # Functions called from GUI
3234
+ # Functions called from outside
3231
3235
 
3232
3236
  def mute(self):
3233
3237
  """
@@ -3305,27 +3309,17 @@ class Parameter:
3305
3309
  setattr(self, k, v)
3306
3310
  self.range = self.max - self.min
3307
3311
 
3308
- #logging.debug('%s min %s max %s step %s stepSmall %s stepLarge %s using unit "%s"',
3309
- #self.name, self.min, self.max, self.step, self.stepSmall, self.stepLarge, self.unit)
3310
-
3311
3312
  # Scale points (get_parameter_scalepoint_info) if necessary
3312
- self.__scale_points = {
3313
- sp['label']:sp['value'] \
3314
- for sp in [
3315
- carla.get_parameter_scalepoint_info(self.plugin_id, self.parameter_id, sc_idx) \
3316
- for sc_idx in range(self.scalePointCount)
3317
- ]} if self.uses_scalepoints else None
3318
- if not self.__scale_points is None and len(self.__scale_points) > 2:
3319
- logging.debug('%s SCALEPOINTS USED:', str(self.plugin()))
3320
- with StreamToLogger() as slog:
3321
- print(self.__scale_points, file = slog)
3313
+ self.scale_points = [ ( sp['label'], sp['value'] ) for sp in [
3314
+ carla.get_parameter_scalepoint_info(self.plugin_id, self.parameter_id, sc_idx) \
3315
+ for sc_idx in range(self.scalePointCount)
3316
+ ]] if self.uses_scalepoints else None
3322
3317
 
3323
3318
  def internal_value_changed(self, value):
3324
3319
  """
3325
- Called from Carla engine when the value of this Parameter changed.
3320
+ Called from Carla engine when the value of this Parameter changed, as by a
3321
+ custom dialog rendered via carla.
3326
3322
  """
3327
- #TODO: Test if called when parameter is set, and note in docs
3328
- #logging.debug('internal_value_changed %s %s', self, value)
3329
3323
  self.__value = value
3330
3324
 
3331
3325
  @property
@@ -3342,19 +3336,13 @@ class Parameter:
3342
3336
  Sets the value of this Parameter both in Carla and cached.
3343
3337
  "value" must be in the range of this Parameter's "min" and "max".
3344
3338
  """
3345
- if hasattr(self, "min"):
3346
- if hasattr(self, "max"):
3347
- if self.min <= value <= self.max:
3348
- if self.__value != value:
3349
- self.__value = value
3350
- Carla.instance.set_parameter_value(self.plugin_id, self.parameter_id, value)
3351
- else:
3352
- logging.warning('Parameter "%s" (%s) out of range. Min: %s Max %s',
3353
- self.name, value, self.min, self.max)
3339
+ if self.__value != value:
3340
+ if self.min <= value <= self.max:
3341
+ self.__value = value
3342
+ Carla.instance.set_parameter_value(self.plugin_id, self.parameter_id, value)
3354
3343
  else:
3355
- logging.debug('PLUGIN %s PARAMETER %s HAS NO max', self.plugin(), self)
3356
- else:
3357
- logging.debug('PLUGIN %s PARAMETER %s HAS NO min', self.plugin(), self)
3344
+ logging.warning('Parameter "%s" (%s) out of range. Min: %s Max %s',
3345
+ self.name, value, self.min, self.max)
3358
3346
 
3359
3347
  def get_internal_value(self):
3360
3348
  """
simple_carla/qt.py CHANGED
@@ -22,8 +22,9 @@ Qt -enabled classes which utilize signals rather than callbacks.
22
22
  """
23
23
  import logging, traceback, os, sys
24
24
  import qt_extras.autofit
25
- from PyQt5.QtCore import QObject, pyqtSignal
26
- from simple_carla import _SimpleCarla, Plugin, PatchbayClient, PatchbayPort, PatchbayConnection
25
+ from PyQt5.QtCore import QObject, pyqtSignal
26
+ from simple_carla import _SimpleCarla, Plugin, Parameter, \
27
+ PatchbayClient, PatchbayPort, PatchbayConnection
27
28
 
28
29
  from carla_backend import (
29
30
 
@@ -314,27 +315,36 @@ class CarlaQt(_SimpleCarla, QObject):
314
315
 
315
316
 
316
317
 
317
- class QtPlugin(Plugin, QObject):
318
+ class AbstractQtPlugin(Plugin):
318
319
  """
319
- This is an abstract class which inherits from QObject, for use by plugins which
320
- have no direct user-interface, (i.e. track & channel filter instantiated by a
321
- TrackWidget). (Qt does not allow inheriting from multiple classes which
322
- extend QObject)
320
+ This is an abstract class for use by classes which you wish to inherit from a
321
+ class which itself already inherits from QObject.
323
322
 
324
- To use:
325
- plugin = QtPlugin(plugin_def)
326
- plugin.sig_ready.connect(self.plugin_ready)
327
- plugin.add_to_carla()
323
+ Qt does not allow inheriting from multiple classes which extend QObject, so
324
+ extending QObject in THIS class would make it impossible for you to use it as
325
+ a base class.
328
326
 
329
- """
327
+ For example:
330
328
 
331
- sig_ready = pyqtSignal(Plugin)
332
- sig_removed = pyqtSignal(Plugin)
333
- sig_connection_change = pyqtSignal(PatchbayPort, PatchbayPort, bool)
329
+ class MyVisualPlugin(QFrame, AbstractQtPlugin):
334
330
 
335
- def __init__(self, plugin_def=None, saved_state=None):
336
- QObject.__init__(self)
337
- Plugin.__init__(self, plugin_def, saved_state)
331
+ # You must define these signals!
332
+ sig_ready = pyqtSignal(Plugin)
333
+ sig_removed = pyqtSignal(Plugin)
334
+ sig_connection_change = pyqtSignal(PatchbayPort, PatchbayPort, bool)
335
+ sig_parameter_changed = pyqtSignal(Plugin, Parameter, float)
336
+
337
+ plugin_def = {...}
338
+
339
+ def __init__(self, parent, plugin_def, saved_state = None):
340
+ QFrame.__init__(self, parent)
341
+ AbstractQtPlugin.__init__(self, plugin_def, saved_state)
342
+
343
+ plugin = MyVisualPlugin()
344
+ plugin.sig_ready.connect(self.plugin_ready)
345
+ plugin.add_to_carla()
346
+ layout.addWidget(plugin)
347
+ """
338
348
 
339
349
  def ready(self):
340
350
  """
@@ -354,5 +364,40 @@ class QtPlugin(Plugin, QObject):
354
364
  if not self.removing_from_carla:
355
365
  self.sig_connection_change.emit(connection.out_port, connection.in_port, state)
356
366
 
367
+ def parameter_internal_value_changed(self, parameter, value):
368
+ """
369
+ Called by the Carla host engine when the internal value of a parameter has changed.
370
+ "parameter" is a Parameter object.
371
+ "value" is the new value of the Parameter.
372
+
373
+ The value of the Parameter object will have already been set when this is called.
374
+ """
375
+ self.sig_parameter_changed.emit(self, parameter, value)
376
+
377
+
378
+
379
+ class QtPlugin(AbstractQtPlugin, QObject):
380
+ """
381
+ A class which inherits from both Plugin and QObject. It can be used by plugins
382
+ which have no direct user-interface, but still need to emit signals.
383
+
384
+ For example:
385
+
386
+ plugin = QtPlugin(plugin_def)
387
+ plugin.sig_ready.connect(self.plugin_ready)
388
+ plugin.add_to_carla()
389
+
390
+ """
391
+
392
+ sig_ready = pyqtSignal(Plugin)
393
+ sig_removed = pyqtSignal(Plugin)
394
+ sig_connection_change = pyqtSignal(PatchbayPort, PatchbayPort, bool)
395
+ sig_parameter_changed = pyqtSignal(Plugin, Parameter, float)
396
+
397
+ def __init__(self, plugin_def=None, saved_state=None):
398
+ QObject.__init__(self)
399
+ Plugin.__init__(self, plugin_def, saved_state)
400
+
401
+
357
402
 
358
403
  # end simple_carla/qt.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simple_carla
3
- Version: 1.3.0
3
+ Version: 1.4.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=BPxOjFgZho2Yz_kpIQjj9E_YQYSUZqaZEA2vqwQVnwc,107435
2
+ simple_carla/plugin_dialog.py,sha256=AHbEC-Sq_28QcJgZ-2gKJBaVEfa4-dEVQFvX9_7tYuk,1455
3
+ simple_carla/qt.py,sha256=ufN7PHHjFB_IXyoJnuG_JcY2p-5CyuOcEDFYG4BHF-g,13957
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.4.0.dist-info/entry_points.txt,sha256=oqJRVQXTCIUOmspGNnqDWq9mhz397uoRMQQOhBFbIcs,73
7
+ simple_carla-1.4.0.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
8
+ simple_carla-1.4.0.dist-info/WHEEL,sha256=j3d_2VkBU36k09xOc4O9RZyJJ8uFqn4BR2AtKD7MOp8,99
9
+ simple_carla-1.4.0.dist-info/METADATA,sha256=M6lNYWD0f8X7h_ijK0eM07BKDeRyvkeMHMOziDh6UtQ,1717
10
+ simple_carla-1.4.0.dist-info/RECORD,,
@@ -1,10 +0,0 @@
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,,