simple-carla 1.4.0__tar.gz → 1.5.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: 1.4.0
3
+ Version: 1.5.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 = "1.4.0"
21
+ current_version = "1.5.0"
22
22
  version_pattern = "MAJOR.MINOR.PATCH"
23
23
  commit_message = "Bump version {old_version} -> {new_version}"
24
24
  commit = true
@@ -233,10 +233,8 @@ from carla_backend import (
233
233
  FILE_CALLBACK_SAVE
234
234
  )
235
235
 
236
- from resources_rc import qCleanupResources
237
236
 
238
-
239
- __version__ = "1.4.0"
237
+ __version__ = "1.5.0"
240
238
 
241
239
 
242
240
  # -------------------------------------------------------------------
@@ -285,8 +283,9 @@ class _SimpleCarla(CarlaHostDLL):
285
283
  idle_interval = 1 / 50
286
284
  instance = None
287
285
  client_name = None
288
- __autoload_plugin = None
289
- __autoload_filename = None
286
+ _autoload_plugin = None
287
+ _autoload_filename = None
288
+ _cptr_filename = None # Pointer which is held onto so as not to get segfaults
290
289
 
291
290
  # -------------------------------------------------------------------
292
291
  # Singleton instantiation
@@ -296,14 +295,6 @@ class _SimpleCarla(CarlaHostDLL):
296
295
  cls.instance = Carla.instance = super().__new__(cls)
297
296
  return cls.instance
298
297
 
299
- @classmethod
300
- def delete(cls):
301
- """
302
- Close the engine and delete the current instance to avoid hanging when exiting.
303
- """
304
- cls.instance.engine_close()
305
- cls.instance = Carla.instance = None
306
-
307
298
  def __init__(self, client_name):
308
299
  """
309
300
  client_name is the name which appears in JACK audio connection kit.
@@ -324,6 +315,8 @@ class _SimpleCarla(CarlaHostDLL):
324
315
  self.lib.carla_set_engine_callback(self.handle, self._engine_callback, None)
325
316
  self._file_callback = FileCallbackFunc(self.file_callback)
326
317
  self.lib.carla_set_file_callback(self.handle, self._file_callback, None)
318
+ self._open_file_callback = None
319
+ self._save_file_callback = None
327
320
 
328
321
  self.audioDriverForced = "JACK"
329
322
  self.forceStereo = False
@@ -356,6 +349,14 @@ class _SimpleCarla(CarlaHostDLL):
356
349
  self.set_engine_option(ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT, self.showLogs, "")
357
350
  self.set_engine_option(ENGINE_OPTION_CLIENT_NAME_PREFIX, 0, self.client_name)
358
351
 
352
+ @classmethod
353
+ def delete(cls):
354
+ """
355
+ Close the engine and delete the current instance to avoid hanging when exiting.
356
+ """
357
+ cls.instance.engine_close()
358
+ cls.instance = Carla.instance = None
359
+
359
360
  # -------------------------------------------------------------------
360
361
  # Engine control / idle loop
361
362
 
@@ -372,13 +373,6 @@ class _SimpleCarla(CarlaHostDLL):
372
373
  return True
373
374
  return False
374
375
 
375
- def set_ui_parent(self, window):
376
- """
377
- Set the parent window of dialogs opened by the Carla engine.
378
- Not needed if the file open dialog will not be needed.
379
- """
380
- self._file_callback_parent = window
381
-
382
376
  def engine_idle(self):
383
377
  """
384
378
  Overrides CarlaHostDLL engine_idle() function, as this is handled internally.
@@ -1720,34 +1714,74 @@ class _SimpleCarla(CarlaHostDLL):
1720
1714
  liquidsfz does not have an input file parameter, but instead, requests the host to display an open file dialog from which the user may select an SFZ file to load. This function triggers the plugin's host gui display which will call __file_callback(). When there is a plugin to autoload on deck, __file_callback() will return the "autoload_filename" property of the plugin, instead of showing the file open dialog and returning the result.
1721
1715
 
1722
1716
  """
1723
- if self.__autoload_plugin is not None:
1724
- raise Exception("Cannot set autoload plugin as it is already used by " + self.__autoload_plugin)
1725
- self.__autoload_plugin = plugin
1726
- self.__autoload_filename = filename
1717
+ if self._autoload_plugin is not None:
1718
+ raise Exception("Cannot set autoload plugin as it is already used by " + self._autoload_plugin)
1719
+ self._autoload_plugin = plugin
1720
+ self._autoload_filename = filename
1727
1721
  #logging.debug('Autoloading "%s"', filename)
1728
1722
  self.show_custom_ui(plugin.plugin_id, True)
1729
- self.__autoload_plugin = None
1730
- self.__autoload_filename = None
1723
+ self._autoload_plugin = None
1724
+ self._autoload_filename = None
1731
1725
  if callable(callback):
1732
1726
  callback()
1733
1727
 
1734
- def file_callback(self, ptr, action, is_dir, title, filter):
1735
- if self.__autoload_plugin is None:
1736
- if self._file_callback_parent is None:
1737
- raise Exception("Cannot open file dialog without parent window (see Carla.set_ui_parent)")
1738
- title = charPtrToString(title)
1728
+ def set_open_file_callback(self, callback):
1729
+ """
1730
+ Set the callback function that Carla will call when it needs a file name.
1731
+
1732
+ The callback must have this signature:
1733
+
1734
+ def funct(self, caption: str, filter: str)
1735
+
1736
+ A typical implementation in Qt might be:
1737
+
1738
+ carla.set_open_file_callback(self.open_file_dialog)
1739
+
1740
+ def open_file_dialog(self, caption, filter):
1741
+ filename, ok = QFileDialog.getOpenFileName(self, caption, "", filter)
1742
+ return filename if ok else None
1743
+
1744
+ """
1745
+ self._open_file_callback = callback
1746
+
1747
+ def set_save_file_callback(self, callback):
1748
+ """
1749
+ Set the callback function that Carla will call when it needs a file name.
1750
+
1751
+ The callback must have this signature:
1752
+
1753
+ def funct(self, caption: str, filter: str, dirs_only: bool)
1754
+
1755
+ A typical implementation in Qt might be:
1756
+
1757
+ carla.set_save_file_callback(self.save_file_dialog)
1758
+
1759
+ def save_file_dialog(self, caption, filter):
1760
+ filename, ok = QFileDialog.getOpenFileName(self, caption, "", filter)
1761
+ return filename if ok else None
1762
+
1763
+ """
1764
+ self._save_file_callback = callback
1765
+
1766
+ def file_callback(self, ptr, action, dirs_only, caption, filter):
1767
+ if self._autoload_plugin is None:
1768
+ caption = charPtrToString(caption)
1739
1769
  filter = charPtrToString(filter)
1740
1770
  if action == FILE_CALLBACK_OPEN:
1741
- ret, ok = QFileDialog.getOpenFileName(self._file_callback_parent, title, "", filter)
1771
+ if self._open_file_callback is None:
1772
+ raise RuntimeError('Carla wants to open a file, but no callback function is defined')
1773
+ str_filename = self._open_file_callback(caption, filter)
1742
1774
  elif action == FILE_CALLBACK_SAVE:
1743
- ret, ok = QFileDialog.getSaveFileName(self._file_callback_parent, title, "", filter, QFileDialog.ShowDirsOnly if is_dir else 0x0)
1775
+ if self._save_file_callback is None:
1776
+ raise RuntimeError('Carla wants to open a file, but no callback function is defined')
1777
+ str_filename = self._save_file_callback(caption, filter)
1744
1778
  else:
1745
1779
  return None
1746
1780
  else:
1747
- ret = self.__autoload_filename
1748
- if ret:
1749
- return_file = c_char_p(ret.encode("utf-8"))
1750
- retval = cast(byref(return_file), POINTER(c_uintptr))
1781
+ str_filename = self._autoload_filename
1782
+ if str_filename:
1783
+ self._cptr_filename = c_char_p(str_filename.encode("utf-8"))
1784
+ retval = cast(byref(self._cptr_filename), POINTER(c_uintptr))
1751
1785
  return retval.contents.value
1752
1786
  return None
1753
1787
 
@@ -2663,7 +2697,6 @@ class Plugin(PatchbayClient):
2663
2697
  """
2664
2698
 
2665
2699
  plugin_def = None
2666
- has_user_interface = False
2667
2700
 
2668
2701
  _cb_ready = None
2669
2702
  _cb_removed = None
@@ -2737,6 +2770,13 @@ class Plugin(PatchbayClient):
2737
2770
 
2738
2771
  carla = Carla.instance
2739
2772
 
2773
+ counts = carla.get_audio_port_count_info(self.plugin_id)
2774
+ self._audio_in_count = counts['ins']
2775
+ self._audio_out_count = counts['outs']
2776
+ counts = carla.get_midi_port_count_info(self.plugin_id)
2777
+ self._midi_in_count = counts['ins']
2778
+ self._midi_out_count = counts['outs']
2779
+
2740
2780
  # basic info
2741
2781
  # 'type', 'category', 'hints', 'optionsAvailable', 'optionsEnabled', 'filename', 'name', 'label', 'maker', 'copyright', 'iconName', 'uniqueId'
2742
2782
  info = carla.get_plugin_info(self.plugin_id)
@@ -2785,13 +2825,6 @@ class Plugin(PatchbayClient):
2785
2825
  with StreamToLogger() as slog:
2786
2826
  print(carla.get_chunk_data(self.plugin_id), file = slog)
2787
2827
 
2788
- counts = carla.get_audio_port_count_info(self.plugin_id)
2789
- self._audio_in_count = counts['ins']
2790
- self._audio_out_count = counts['outs']
2791
- counts = carla.get_midi_port_count_info(self.plugin_id)
2792
- self._midi_in_count = counts['ins']
2793
- self._midi_out_count = counts['outs']
2794
-
2795
2828
  # Parameters
2796
2829
  for parameter_id in range(carla.get_parameter_count(self.plugin_id)):
2797
2830
  param = Parameter(self.plugin_id, parameter_id)
@@ -11,6 +11,7 @@ import sys, os
11
11
  from simple_carla import carla_binaries_path
12
12
  from carla_frontend import CarlaFrontendLib
13
13
  from carla_shared import DLL_EXTENSION
14
+ from resources_rc import qCleanupResources
14
15
 
15
16
 
16
17
  class CarlaPluginDialog():
File without changes
File without changes
File without changes