Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1138 lines
45KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla host code
  4. # Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from PyQt4.QtCore import qCritical, QModelIndex, QTimer
  20. from PyQt4.QtGui import QApplication, QFileSystemModel, QMainWindow, QPalette
  21. # ------------------------------------------------------------------------------------------------------------
  22. # Imports (Custom)
  23. import ui_carla_host
  24. from carla_database import *
  25. from carla_settings import *
  26. from carla_style import *
  27. from carla_widgets import *
  28. # ------------------------------------------------------------------------------------------------------------
  29. # PatchCanvas defines
  30. CANVAS_ANTIALIASING_SMALL = 1
  31. CANVAS_EYECANDY_SMALL = 1
  32. # ------------------------------------------------------------------------------------------------------------
  33. # Session Management support
  34. LADISH_APP_NAME = os.getenv("LADISH_APP_NAME")
  35. NSM_URL = os.getenv("NSM_URL")
  36. # ------------------------------------------------------------------------------------------------------------
  37. # Dummy widget
  38. class CarlaDummyW(object):
  39. def __init__(self, parent):
  40. object.__init__(self)
  41. # -----------------------------------------------------------------
  42. def getPluginCount(self):
  43. return 0
  44. # -----------------------------------------------------------------
  45. def addPlugin(self, pluginId, isProjectLoading):
  46. pass
  47. def removePlugin(self, pluginId):
  48. pass
  49. def renamePlugin(self, pluginId, newName):
  50. pass
  51. def disablePlugin(self, pluginId, errorMsg):
  52. pass
  53. def removeAllPlugins(self):
  54. pass
  55. # -----------------------------------------------------------------
  56. def engineStarted(self):
  57. pass
  58. def engineStopped(self):
  59. pass
  60. def engineChanged(self):
  61. pass
  62. # -----------------------------------------------------------------
  63. def idleFast(self):
  64. pass
  65. def idleSlow(self):
  66. pass
  67. # -----------------------------------------------------------------
  68. def saveSettings(self, settings):
  69. pass
  70. # ------------------------------------------------------------------------------------------------------------
  71. # Host Window
  72. class HostWindow(QMainWindow):
  73. # signals
  74. DebugCallback = pyqtSignal(int, int, int, float, str)
  75. PluginAddedCallback = pyqtSignal(int, str)
  76. PluginRemovedCallback = pyqtSignal(int)
  77. PluginRenamedCallback = pyqtSignal(int, str)
  78. PluginUnavailableCallback = pyqtSignal(int, str)
  79. ParameterValueChangedCallback = pyqtSignal(int, int, float)
  80. ParameterDefaultChangedCallback = pyqtSignal(int, int, float)
  81. ParameterMidiCcChangedCallback = pyqtSignal(int, int, int)
  82. ParameterMidiChannelChangedCallback = pyqtSignal(int, int, int)
  83. ProgramChangedCallback = pyqtSignal(int, int)
  84. MidiProgramChangedCallback = pyqtSignal(int, int)
  85. UiStateChangedCallback = pyqtSignal(int, int)
  86. NoteOnCallback = pyqtSignal(int, int, int, int)
  87. NoteOffCallback = pyqtSignal(int, int, int)
  88. UpdateCallback = pyqtSignal(int)
  89. ReloadInfoCallback = pyqtSignal(int)
  90. ReloadParametersCallback = pyqtSignal(int)
  91. ReloadProgramsCallback = pyqtSignal(int)
  92. ReloadAllCallback = pyqtSignal(int)
  93. PatchbayClientAddedCallback = pyqtSignal(int, int, str)
  94. PatchbayClientRemovedCallback = pyqtSignal(int)
  95. PatchbayClientRenamedCallback = pyqtSignal(int, str)
  96. PatchbayClientIconChangedCallback = pyqtSignal(int, int)
  97. PatchbayPortAddedCallback = pyqtSignal(int, int, int, str)
  98. PatchbayPortRemovedCallback = pyqtSignal(int, int)
  99. PatchbayPortRenamedCallback = pyqtSignal(int, int, str)
  100. PatchbayConnectionAddedCallback = pyqtSignal(int, int, int)
  101. PatchbayConnectionRemovedCallback = pyqtSignal(int, int, int)
  102. EngineStartedCallback = pyqtSignal(int, int, str)
  103. EngineStoppedCallback = pyqtSignal()
  104. ProcessModeChangedCallback = pyqtSignal(int)
  105. TransportModeChangedCallback = pyqtSignal(int)
  106. BufferSizeChangedCallback = pyqtSignal(int)
  107. SampleRateChangedCallback = pyqtSignal(float)
  108. InfoCallback = pyqtSignal(str)
  109. ErrorCallback = pyqtSignal(str)
  110. QuitCallback = pyqtSignal()
  111. SIGTERM = pyqtSignal()
  112. SIGUSR1 = pyqtSignal()
  113. def __init__(self, parent):
  114. QMainWindow.__init__(self, parent)
  115. self.ui = ui_carla_host.Ui_CarlaHostW()
  116. self.ui.setupUi(self)
  117. if False:
  118. Carla.gui = self
  119. self.fContainer = CarlaDummyW(self)
  120. # -------------------------------------------------------------
  121. # Set callback, TODO put somewhere else
  122. Carla.host.set_engine_callback(engineCallback)
  123. # -------------------------------------------------------------
  124. # Internal stuff
  125. self.fIdleTimerFast = 0
  126. self.fIdleTimerSlow = 0
  127. self.fIsProjectLoading = False
  128. self.fProjectFilename = ""
  129. self.fLadspaRdfNeedsUpdate = True
  130. self.fLadspaRdfList = []
  131. self.fLastTransportFrame = 0
  132. self.fLastTransportState = False
  133. self.fTransportText = ""
  134. # when true, call engineChanged() asap
  135. self.fEngineChanged = False
  136. self.fSavedSettings = {}
  137. if LADISH_APP_NAME:
  138. self.fClientName = LADISH_APP_NAME
  139. self.fSessionManagerName = "LADISH"
  140. elif NSM_URL:
  141. self.fClientName = "Carla.tmp"
  142. self.fSessionManagerName = "Non Session Manager"
  143. else:
  144. self.fClientName = "Carla"
  145. self.fSessionManagerName = ""
  146. # -------------------------------------------------------------
  147. # Load Settings
  148. self.loadSettings(True)
  149. # -------------------------------------------------------------
  150. # Set up GUI (engine stopped)
  151. if Carla.isPlugin:
  152. self.ui.act_file_new.setEnabled(False)
  153. self.ui.act_file_open.setEnabled(False)
  154. self.ui.act_engine_start.setEnabled(False)
  155. self.ui.menu_Engine.setEnabled(False)
  156. else:
  157. self.ui.act_engine_start.setEnabled(True)
  158. self.ui.act_file_save.setEnabled(False)
  159. self.ui.act_file_save_as.setEnabled(False)
  160. self.ui.act_engine_stop.setEnabled(False)
  161. self.ui.act_plugin_remove_all.setEnabled(False)
  162. self.ui.menu_PluginMacros.setEnabled(False)
  163. self.ui.menu_Canvas.setEnabled(False)
  164. self.setTransportMenuEnabled(False)
  165. # -------------------------------------------------------------
  166. # Set up GUI (right panel)
  167. self.fDirModel = QFileSystemModel(self)
  168. self.fDirModel.setNameFilters(Carla.host.get_supported_file_extensions().split(";"))
  169. self.fDirModel.setRootPath(HOME)
  170. self.ui.fileTreeView.setModel(self.fDirModel)
  171. self.ui.fileTreeView.setRootIndex(self.fDirModel.index(HOME))
  172. self.ui.fileTreeView.setColumnHidden(1, True)
  173. self.ui.fileTreeView.setColumnHidden(2, True)
  174. self.ui.fileTreeView.setColumnHidden(3, True)
  175. self.ui.fileTreeView.setHeaderHidden(True)
  176. self.setProperWindowTitle()
  177. # -------------------------------------------------------------
  178. # Connect actions to functions
  179. self.ui.act_file_new.triggered.connect(self.slot_fileNew)
  180. self.ui.act_file_open.triggered.connect(self.slot_fileOpen)
  181. self.ui.act_file_save.triggered.connect(self.slot_fileSave)
  182. self.ui.act_file_save_as.triggered.connect(self.slot_fileSaveAs)
  183. self.ui.act_engine_start.triggered.connect(self.slot_engineStart)
  184. self.ui.act_engine_stop.triggered.connect(self.slot_engineStop)
  185. self.ui.act_plugin_add.triggered.connect(self.slot_pluginAdd)
  186. self.ui.act_plugin_add2.triggered.connect(self.slot_pluginAdd)
  187. self.ui.act_plugin_remove_all.triggered.connect(self.slot_pluginRemoveAll)
  188. self.ui.act_transport_play.triggered.connect(self.slot_transportPlayPause)
  189. self.ui.act_transport_stop.triggered.connect(self.slot_transportStop)
  190. self.ui.act_transport_backwards.triggered.connect(self.slot_transportBackwards)
  191. self.ui.act_transport_forwards.triggered.connect(self.slot_transportForwards)
  192. self.ui.act_help_about.triggered.connect(self.slot_aboutCarla)
  193. self.ui.act_help_about_qt.triggered.connect(self.slot_aboutQt)
  194. self.ui.cb_disk.currentIndexChanged.connect(self.slot_diskFolderChanged)
  195. self.ui.b_disk_add.clicked.connect(self.slot_diskFolderAdd)
  196. self.ui.b_disk_remove.clicked.connect(self.slot_diskFolderRemove)
  197. self.ui.fileTreeView.doubleClicked.connect(self.slot_fileTreeDoubleClicked)
  198. self.DebugCallback.connect(self.slot_handleDebugCallback)
  199. self.PluginAddedCallback.connect(self.slot_handlePluginAddedCallback)
  200. self.PluginRemovedCallback.connect(self.slot_handlePluginRemovedCallback)
  201. self.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback)
  202. self.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback)
  203. # parameter (rack, patchbay)
  204. # program, midi-program, ui-state (rack, patchbay)
  205. # note on, off (rack, patchbay)
  206. # update, reload (rack, patchbay)
  207. # patchbay
  208. self.EngineStartedCallback.connect(self.slot_handleEngineStartedCallback)
  209. self.EngineStoppedCallback.connect(self.slot_handleEngineStoppedCallback)
  210. self.ProcessModeChangedCallback.connect(self.slot_handleProcessModeChangedCallback)
  211. self.TransportModeChangedCallback.connect(self.slot_handleTransportModeChangedCallback)
  212. self.BufferSizeChangedCallback.connect(self.slot_handleBufferSizeChangedCallback)
  213. self.SampleRateChangedCallback.connect(self.slot_handleSampleRateChangedCallback)
  214. self.InfoCallback.connect(self.slot_handleInfoCallback)
  215. self.ErrorCallback.connect(self.slot_handleErrorCallback)
  216. self.QuitCallback.connect(self.slot_handleQuitCallback)
  217. self.SIGUSR1.connect(self.slot_handleSIGUSR1)
  218. self.SIGTERM.connect(self.slot_handleSIGTERM)
  219. # -------------------------------------------------------------
  220. # Final setup
  221. if Carla.isPlugin:
  222. QTimer.singleShot(0, self.slot_engineStart)
  223. # -----------------------------------------------------------------
  224. # Called by containers
  225. def openSettingsWindow(self, hasCanvas, hasCanvasGL):
  226. dialog = CarlaSettingsW(self, hasCanvas, hasCanvasGL)
  227. return dialog.exec_()
  228. def setupContainer(self, showMiniCanvas, canvasThemeData = []):
  229. if showMiniCanvas:
  230. canvasWidth, canvasHeight, canvasBg, canvasBrush, canvasPen = canvasThemeData
  231. self.ui.miniCanvasPreview.setViewTheme(canvasBg, canvasBrush, canvasPen)
  232. self.ui.miniCanvasPreview.init(self.fContainer.scene, canvasWidth, canvasHeight, self.fSavedSettings["UseCustomMiniCanvasPaint"])
  233. else:
  234. self.ui.miniCanvasPreview.hide()
  235. self.ui.mainwidget.hide()
  236. del self.ui.mainwidget
  237. self.ui.splitter.insertWidget(0, self.fContainer)
  238. def updateContainer(self, canvasThemeData):
  239. canvasWidth, canvasHeight, canvasBg, canvasBrush, canvasPen = canvasThemeData
  240. self.ui.miniCanvasPreview.setViewTheme(canvasBg, canvasBrush, canvasPen)
  241. self.ui.miniCanvasPreview.init(self.fContainer.scene, canvasWidth, canvasHeight, self.fSavedSettings["UseCustomMiniCanvasPaint"])
  242. # -----------------------------------------------------------------
  243. # Internal stuff (files)
  244. def loadProjectNow(self):
  245. if not self.fProjectFilename:
  246. return qCritical("ERROR: loading project without filename set")
  247. # TESTING
  248. if not Carla.host.is_engine_running():
  249. self.slot_engineStart()
  250. self.fIsProjectLoading = True
  251. Carla.host.load_project(self.fProjectFilename)
  252. self.fIsProjectLoading = False
  253. @pyqtSlot()
  254. def slot_loadProjectNow(self):
  255. self.loadProjectNow()
  256. def loadProjectLater(self, filename):
  257. self.fProjectFilename = filename
  258. self.setProperWindowTitle()
  259. QTimer.singleShot(0, self.slot_loadProjectNow)
  260. def saveProjectNow(self):
  261. if not self.fProjectFilename:
  262. return qCritical("ERROR: saving project without filename set")
  263. Carla.host.save_project(self.fProjectFilename)
  264. # -----------------------------------------------------------------
  265. # Internal stuff (engine)
  266. def setEngineSettings(self, settings = None):
  267. if Carla.isPlugin:
  268. return "Plugin"
  269. if settings is None: settings = QSettings()
  270. forceStereo = settings.value("Engine/ForceStereo", CARLA_DEFAULT_FORCE_STEREO, type=bool)
  271. preferPluginBridges = settings.value("Engine/PreferPluginBridges", CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES, type=bool)
  272. preferUiBridges = settings.value("Engine/PreferUiBridges", CARLA_DEFAULT_PREFER_UI_BRIDGES, type=bool)
  273. uisAlwaysOnTop = settings.value("Engine/OscUiTimeout", CARLA_DEFAULT_UIS_ALWAYS_ON_TOP, type=bool)
  274. uiBridgesTimeout = settings.value("Engine/OscUiTimeout", CARLA_DEFAULT_UI_BRIDGES_TIMEOUT, type=int)
  275. Carla.maxParameters = settings.value("Engine/MaxParameters", CARLA_DEFAULT_MAX_PARAMETERS, type=int)
  276. audioDriver = settings.value("Engine/AudioDriver", CARLA_DEFAULT_AUDIO_DRIVER, type=str)
  277. if audioDriver == "JACK":
  278. #transportMode = settings.value("Engine/TransportMode", TRANSPORT_MODE_JACK, type=int)
  279. transportMode = ENGINE_TRANSPORT_MODE_JACK
  280. else:
  281. transportMode = ENGINE_TRANSPORT_MODE_INTERNAL
  282. audioNumPeriods = settings.value("Engine/AudioBufferSize", CARLA_DEFAULT_AUDIO_NUM_PERIODS, type=int)
  283. audioBufferSize = settings.value("Engine/AudioBufferSize", CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int)
  284. audioSampleRate = settings.value("Engine/AudioSampleRate", CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int)
  285. audioDevice = settings.value("Engine/AudioDevice", "", type=str)
  286. Carla.host.set_engine_option(ENGINE_OPTION_AUDIO_NUM_PERIODS, audioNumPeriods, "")
  287. Carla.host.set_engine_option(ENGINE_OPTION_AUDIO_BUFFER_SIZE, audioBufferSize, "")
  288. Carla.host.set_engine_option(ENGINE_OPTION_AUDIO_SAMPLE_RATE, audioSampleRate, "")
  289. Carla.host.set_engine_option(ENGINE_OPTION_AUDIO_DEVICE, 0, audioDevice)
  290. if Carla.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  291. forceStereo = True
  292. elif Carla.processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS and LADISH_APP_NAME:
  293. print("LADISH detected but using multiple clients (not allowed), forcing single client now")
  294. Carla.processMode = ENGINE_PROCESS_MODE_SINGLE_CLIENT
  295. Carla.host.set_engine_option(ENGINE_OPTION_FORCE_STEREO, forceStereo, "")
  296. Carla.host.set_engine_option(ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, preferPluginBridges, "")
  297. Carla.host.set_engine_option(ENGINE_OPTION_PREFER_UI_BRIDGES, preferUiBridges, "")
  298. Carla.host.set_engine_option(ENGINE_OPTION_UIS_ALWAYS_ON_TOP, uisAlwaysOnTop, "")
  299. Carla.host.set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, uiBridgesTimeout, "")
  300. Carla.host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, Carla.processMode, "")
  301. Carla.host.set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, Carla.maxParameters, "")
  302. Carla.host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, transportMode, "")
  303. return audioDriver
  304. def startEngine(self):
  305. audioDriver = self.setEngineSettings()
  306. if not Carla.host.engine_init(audioDriver, self.fClientName):
  307. #if self.fFirstEngineInit:
  308. #self.fFirstEngineInit = False
  309. #return
  310. audioError = Carla.host.get_last_error()
  311. if audioError:
  312. QMessageBox.critical(self, self.tr("Error"), self.tr("Could not connect to Audio backend '%s', possible reasons:\n%s" % (audioDriver, audioError)))
  313. else:
  314. QMessageBox.critical(self, self.tr("Error"), self.tr("Could not connect to Audio backend '%s'" % audioDriver))
  315. return
  316. #self.fFirstEngineInit = False
  317. def stopEngine(self):
  318. if self.fContainer.getPluginCount() > 0:
  319. ask = QMessageBox.question(self, self.tr("Warning"), self.tr("There are still some plugins loaded, you need to remove them to stop the engine.\n"
  320. "Do you want to do this now?"),
  321. QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
  322. if ask != QMessageBox.Yes:
  323. return
  324. self.ui.act_plugin_remove_all.setEnabled(False)
  325. self.fContainer.removeAllPlugins()
  326. if Carla.host.is_engine_running() and not Carla.host.engine_close():
  327. print(Carla.host.get_last_error())
  328. # -----------------------------------------------------------------
  329. # Internal stuff (plugins)
  330. def getExtraPtr(self, plugin):
  331. ptype = plugin['type']
  332. if ptype == PLUGIN_LADSPA:
  333. uniqueId = plugin['uniqueId']
  334. self.maybeLoadRDFs()
  335. for rdfItem in self.fLadspaRdfList:
  336. if rdfItem.UniqueID == uniqueId:
  337. return pointer(rdfItem)
  338. elif ptype in (PLUGIN_GIG, PLUGIN_SF2, PLUGIN_SFZ):
  339. if plugin['name'].lower().endswith(" (16 outputs)"):
  340. # return a dummy non-null pointer
  341. INTPOINTER = POINTER(c_int)
  342. int1 = c_int(0x1)
  343. addr = addressof(int1)
  344. return cast(addr, INTPOINTER)
  345. return None
  346. def maybeLoadRDFs(self):
  347. if not self.fLadspaRdfNeedsUpdate:
  348. return
  349. self.fLadspaRdfNeedsUpdate = False
  350. self.fLadspaRdfList = []
  351. if not haveLRDF:
  352. return
  353. settingsDir = os.path.join(HOME, ".config", "falkTX")
  354. frLadspaFile = os.path.join(settingsDir, "ladspa_rdf.db")
  355. if os.path.exists(frLadspaFile):
  356. frLadspa = open(frLadspaFile, 'r')
  357. try:
  358. self.fLadspaRdfList = ladspa_rdf.get_c_ladspa_rdfs(json.load(frLadspa))
  359. except:
  360. pass
  361. frLadspa.close()
  362. def setLoadRDFsNeeded(self):
  363. self.fLadspaRdfNeedsUpdate = True
  364. # -----------------------------------------------------------------
  365. # Internal stuff (transport)
  366. def refreshTransport(self, forced = False):
  367. if Carla.sampleRate == 0.0 or not Carla.host.is_engine_running():
  368. return
  369. timeInfo = Carla.host.get_transport_info()
  370. playing = bool(timeInfo['playing'])
  371. frame = int(timeInfo['frame'])
  372. if playing != self.fLastTransportState or forced:
  373. if playing:
  374. icon = getIcon("media-playback-pause")
  375. self.ui.act_transport_play.setChecked(True)
  376. self.ui.act_transport_play.setIcon(icon)
  377. self.ui.act_transport_play.setText(self.tr("&Pause"))
  378. else:
  379. icon = getIcon("media-playback-start")
  380. self.ui.act_transport_play.setChecked(False)
  381. self.ui.act_transport_play.setIcon(icon)
  382. self.ui.act_transport_play.setText(self.tr("&Play"))
  383. self.fLastTransportState = playing
  384. if frame != self.fLastTransportFrame or forced:
  385. time = frame / Carla.sampleRate
  386. secs = time % 60
  387. mins = (time / 60) % 60
  388. hrs = (time / 3600) % 60
  389. self.fTextTransport = "Transport %s, at %02i:%02i:%02i" % ("playing" if playing else "stopped", hrs, mins, secs)
  390. self.fLastTransportFrame = frame
  391. def setTransportMenuEnabled(self, enabled):
  392. self.ui.act_transport_play.setEnabled(enabled)
  393. self.ui.act_transport_stop.setEnabled(enabled)
  394. self.ui.act_transport_backwards.setEnabled(enabled)
  395. self.ui.act_transport_forwards.setEnabled(enabled)
  396. self.ui.menu_Transport.setEnabled(enabled)
  397. # -----------------------------------------------------------------
  398. # Internal stuff (settings)
  399. def loadSettings(self, firstTime):
  400. settings = QSettings()
  401. if firstTime:
  402. self.restoreGeometry(settings.value("Geometry", ""))
  403. showToolbar = settings.value("ShowToolbar", True, type=bool)
  404. self.ui.act_settings_show_toolbar.setChecked(showToolbar)
  405. self.ui.toolBar.setVisible(showToolbar)
  406. #if settings.contains("SplitterState"):
  407. #self.ui.splitter.restoreState(settings.value("SplitterState", ""))
  408. #else:
  409. self.ui.splitter.setSizes([99999, 210])
  410. diskFolders = toList(settings.value("DiskFolders", [HOME]))
  411. self.ui.cb_disk.setItemData(0, HOME)
  412. for i in range(len(diskFolders)):
  413. if i == 0: continue
  414. folder = diskFolders[i]
  415. self.ui.cb_disk.addItem(os.path.basename(folder), folder)
  416. if MACOS and not settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool):
  417. self.setUnifiedTitleAndToolBarOnMac(True)
  418. # ---------------------------------------------
  419. # plugin checks
  420. if settings.value("Engine/DisableChecks", False, type=bool):
  421. os.environ["CARLA_DISCOVERY_NO_PROCESSING_CHECKS"] = "true"
  422. elif os.getenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS"):
  423. os.environ.pop("CARLA_DISCOVERY_NO_PROCESSING_CHECKS")
  424. # ---------------------------------------------
  425. if not Carla.isPlugin:
  426. # engine
  427. self.setEngineSettings(settings)
  428. # plugin paths
  429. LADSPA_PATH = toList(settings.value("Paths/LADSPA", Carla.DEFAULT_LADSPA_PATH))
  430. DSSI_PATH = toList(settings.value("Paths/DSSI", Carla.DEFAULT_DSSI_PATH))
  431. LV2_PATH = toList(settings.value("Paths/LV2", Carla.DEFAULT_LV2_PATH))
  432. VST_PATH = toList(settings.value("Paths/VST", Carla.DEFAULT_VST_PATH))
  433. AU_PATH = toList(settings.value("Paths/AU", Carla.DEFAULT_AU_PATH))
  434. CSOUND_PATH = toList(settings.value("Paths/CSOUND", Carla.DEFAULT_CSOUND_PATH))
  435. GIG_PATH = toList(settings.value("Paths/GIG", Carla.DEFAULT_GIG_PATH))
  436. SF2_PATH = toList(settings.value("Paths/SF2", Carla.DEFAULT_SF2_PATH))
  437. SFZ_PATH = toList(settings.value("Paths/SFZ", Carla.DEFAULT_SFZ_PATH))
  438. os.environ["LADSPA_PATH"] = splitter.join(LADSPA_PATH)
  439. os.environ["DSSI_PATH"] = splitter.join(DSSI_PATH)
  440. os.environ["LV2_PATH"] = splitter.join(LV2_PATH)
  441. os.environ["VST_PATH"] = splitter.join(VST_PATH)
  442. os.environ["AU_PATH"] = splitter.join(AU_PATH)
  443. os.environ["CSOUND_PATH"] = splitter.join(CSOUND_PATH)
  444. os.environ["GIG_PATH"] = splitter.join(GIG_PATH)
  445. os.environ["SF2_PATH"] = splitter.join(SF2_PATH)
  446. os.environ["SFZ_PATH"] = splitter.join(SFZ_PATH)
  447. # ---------------------------------------------
  448. # TODO
  449. self.fSavedSettings = {
  450. CARLA_KEY_MAIN_PROJECT_FOLDER: settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, type=str),
  451. CARLA_KEY_MAIN_REFRESH_INTERVAL: settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, type=int),
  452. CARLA_KEY_CANVAS_THEME: settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, type=str),
  453. CARLA_KEY_CANVAS_SIZE: settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, type=str),
  454. CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS: settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, type=bool),
  455. CARLA_KEY_CANVAS_USE_BEZIER_LINES: settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, type=bool),
  456. CARLA_KEY_CANVAS_EYE_CANDY: settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, type=int),
  457. CARLA_KEY_CANVAS_USE_OPENGL: settings.value(CARLA_KEY_CANVAS_USE_OPENGL, CARLA_DEFAULT_CANVAS_USE_OPENGL, type=bool),
  458. CARLA_KEY_CANVAS_ANTIALIASING: settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, type=int),
  459. CARLA_KEY_CANVAS_HQ_ANTIALIASING: settings.value(CARLA_KEY_CANVAS_HQ_ANTIALIASING, CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING, type=bool),
  460. "UseCustomMiniCanvasPaint": (settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool) and
  461. settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, "Black", type=str).lower() == "black")
  462. }
  463. # ---------------------------------------------
  464. if self.fIdleTimerFast != 0:
  465. self.killTimer(self.fIdleTimerFast)
  466. self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL])
  467. if self.fIdleTimerSlow != 0:
  468. self.killTimer(self.fIdleTimerSlow)
  469. self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*2)
  470. def saveSettings(self):
  471. settings = QSettings()
  472. settings.setValue("Geometry", self.saveGeometry())
  473. settings.setValue("SplitterState", self.ui.splitter.saveState())
  474. settings.setValue("ShowToolbar", self.ui.toolBar.isVisible())
  475. diskFolders = []
  476. for i in range(self.ui.cb_disk.count()):
  477. diskFolders.append(self.ui.cb_disk.itemData(i))
  478. settings.setValue("DiskFolders", diskFolders)
  479. self.fContainer.saveSettings(settings)
  480. # -----------------------------------------------------------------
  481. # Internal stuff (gui)
  482. def setProperWindowTitle(self):
  483. title = self.fClientName
  484. if self.fProjectFilename:
  485. title += " - %s" % os.path.basename(self.fProjectFilename)
  486. if self.fSessionManagerName:
  487. title += " (%s)" % self.fSessionManagerName
  488. self.setWindowTitle(title)
  489. # -----------------------------------------------------------------
  490. @pyqtSlot()
  491. def slot_fileNew(self):
  492. self.fContainer.removeAllPlugins()
  493. self.fProjectFilename = ""
  494. self.setProperWindowTitle()
  495. @pyqtSlot()
  496. def slot_fileOpen(self):
  497. fileFilter = self.tr("Carla Project File (*.carxp)")
  498. filenameTry = QFileDialog.getOpenFileName(self, self.tr("Open Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter)[0]
  499. if not filenameTry:
  500. return
  501. newFile = True
  502. if self.fContainer.getPluginCount() > 0:
  503. ask = QMessageBox.question(self, self.tr("Question"), self.tr("There are some plugins loaded, do you want to remove them now?"),
  504. QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
  505. newFile = ask == QMessageBox.Yes
  506. if newFile:
  507. self.fContainer.removeAllPlugins()
  508. self.fProjectFilename = filenameTry
  509. self.setProperWindowTitle()
  510. self.loadProjectNow()
  511. else:
  512. filenameOld = self.fProjectFilename
  513. self.fProjectFilename = filenameTry
  514. self.loadProjectNow()
  515. self.fProjectFilename = filenameOld
  516. @pyqtSlot()
  517. def slot_fileSave(self, saveAs=False):
  518. if self.fProjectFilename and not saveAs:
  519. return self.saveProjectNow()
  520. fileFilter = self.tr("Carla Project File (*.carxp)")
  521. filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter)[0]
  522. if not filenameTry:
  523. return
  524. if not filenameTry.endswith(".carxp"):
  525. filenameTry += ".carxp"
  526. if self.fProjectFilename != filenameTry:
  527. self.fProjectFilename = filenameTry
  528. self.setProperWindowTitle()
  529. self.saveProjectNow()
  530. @pyqtSlot()
  531. def slot_fileSaveAs(self):
  532. self.slot_fileSave(True)
  533. # -----------------------------------------------------------------
  534. @pyqtSlot()
  535. def slot_engineStart(self, doStart = True):
  536. if doStart: self.startEngine()
  537. check = Carla.host.is_engine_running()
  538. self.ui.menu_PluginMacros.setEnabled(check)
  539. self.ui.menu_Canvas.setEnabled(check)
  540. if not Carla.isPlugin:
  541. self.ui.act_file_save.setEnabled(check)
  542. self.ui.act_engine_start.setEnabled(not check)
  543. self.ui.act_engine_stop.setEnabled(check)
  544. if self.fSessionManagerName != "Non Session Manager":
  545. self.ui.act_file_open.setEnabled(check)
  546. self.ui.act_file_save_as.setEnabled(check)
  547. self.setTransportMenuEnabled(check)
  548. if check:
  549. if not Carla.isPlugin:
  550. self.refreshTransport(True)
  551. self.fContainer.engineStarted()
  552. @pyqtSlot()
  553. def slot_engineStop(self, doStop = True):
  554. if doStop: self.stopEngine()
  555. # FIXME?
  556. if self.fContainer.getPluginCount() > 0:
  557. self.ui.act_plugin_remove_all.setEnabled(False)
  558. self.fContainer.removeAllPlugins()
  559. check = Carla.host.is_engine_running()
  560. self.ui.menu_PluginMacros.setEnabled(check)
  561. self.ui.menu_Canvas.setEnabled(check)
  562. if not Carla.isPlugin:
  563. self.ui.act_file_save.setEnabled(check)
  564. self.ui.act_engine_start.setEnabled(not check)
  565. self.ui.act_engine_stop.setEnabled(check)
  566. if self.fSessionManagerName != "Non Session Manager":
  567. self.ui.act_file_open.setEnabled(check)
  568. self.ui.act_file_save_as.setEnabled(check)
  569. self.setTransportMenuEnabled(check)
  570. if not check:
  571. self.fTextTransport = ""
  572. self.fContainer.engineStopped()
  573. # -----------------------------------------------------------------
  574. @pyqtSlot()
  575. def slot_pluginAdd(self):
  576. dialog = PluginDatabaseW(self)
  577. if not dialog.exec_():
  578. return
  579. if not Carla.host.is_engine_running():
  580. QMessageBox.warning(self, self.tr("Warning"), self.tr("Cannot add new plugins while engine is stopped"))
  581. return
  582. btype = dialog.fRetPlugin['build']
  583. ptype = dialog.fRetPlugin['type']
  584. filename = dialog.fRetPlugin['filename']
  585. label = dialog.fRetPlugin['label']
  586. extraPtr = self.getExtraPtr(dialog.fRetPlugin)
  587. if not Carla.host.add_plugin(btype, ptype, filename, None, label, extraPtr):
  588. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), charPtrToString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  589. return
  590. @pyqtSlot()
  591. def slot_pluginRemoveAll(self):
  592. self.ui.act_plugin_remove_all.setEnabled(False)
  593. self.fContainer.removeAllPlugins()
  594. Carla.host.remove_all_plugins()
  595. # -----------------------------------------------------------------
  596. @pyqtSlot(bool)
  597. def slot_transportPlayPause(self, toggled):
  598. if not Carla.host.is_engine_running():
  599. return
  600. if toggled:
  601. Carla.host.transport_play()
  602. else:
  603. Carla.host.transport_pause()
  604. self.refreshTransport()
  605. @pyqtSlot()
  606. def slot_transportStop(self):
  607. if not Carla.host.is_engine_running():
  608. return
  609. Carla.host.transport_pause()
  610. Carla.host.transport_relocate(0)
  611. self.refreshTransport()
  612. @pyqtSlot()
  613. def slot_transportBackwards(self):
  614. if not Carla.host.is_engine_running():
  615. return
  616. newFrame = Carla.host.get_current_transport_frame() - 100000
  617. if newFrame < 0:
  618. newFrame = 0
  619. Carla.host.transport_relocate(newFrame)
  620. @pyqtSlot()
  621. def slot_transportForwards(self):
  622. if not Carla.host.is_engine_running():
  623. return
  624. newFrame = Carla.host.get_current_transport_frame() + 100000
  625. Carla.host.transport_relocate(newFrame)
  626. # -----------------------------------------------------------------
  627. @pyqtSlot()
  628. def slot_aboutCarla(self):
  629. CarlaAboutW(self).exec_()
  630. @pyqtSlot()
  631. def slot_aboutQt(self):
  632. QApplication.instance().aboutQt()
  633. # -----------------------------------------------------------------
  634. @pyqtSlot(int)
  635. def slot_diskFolderChanged(self, index):
  636. if index < 0:
  637. return
  638. elif index == 0:
  639. filename = HOME
  640. self.ui.b_disk_remove.setEnabled(False)
  641. else:
  642. filename = self.ui.cb_disk.itemData(index)
  643. self.ui.b_disk_remove.setEnabled(True)
  644. self.fDirModel.setRootPath(filename)
  645. self.ui.fileTreeView.setRootIndex(self.fDirModel.index(filename))
  646. @pyqtSlot()
  647. def slot_diskFolderAdd(self):
  648. newPath = QFileDialog.getExistingDirectory(self, self.tr("New Folder"), "", QFileDialog.ShowDirsOnly)
  649. if newPath:
  650. if newPath[-1] == os.sep:
  651. newPath = newPath[:-1]
  652. self.ui.cb_disk.addItem(os.path.basename(newPath), newPath)
  653. self.ui.cb_disk.setCurrentIndex(self.ui.cb_disk.count()-1)
  654. self.ui.b_disk_remove.setEnabled(True)
  655. @pyqtSlot()
  656. def slot_diskFolderRemove(self):
  657. index = self.ui.cb_disk.currentIndex()
  658. if index <= 0:
  659. return
  660. self.ui.cb_disk.removeItem(index)
  661. if self.ui.cb_disk.currentIndex() == 0:
  662. self.ui.b_disk_remove.setEnabled(False)
  663. @pyqtSlot(QModelIndex)
  664. def slot_fileTreeDoubleClicked(self, modelIndex):
  665. filename = self.fDirModel.filePath(modelIndex)
  666. if not Carla.host.load_file(filename):
  667. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"),
  668. self.tr("Failed to load file"),
  669. Carla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  670. # -----------------------------------------------------------------
  671. @pyqtSlot(int, int, int, float, str)
  672. def slot_handleDebugCallback(self, pluginId, value1, value2, value3, valueStr):
  673. print("DEBUG:", pluginId, value1, value2, value3, valueStr)
  674. #self.ui.pte_log.appendPlainText(valueStr.replace("", "DEBUG: ").replace("", "ERROR: ").replace("", "").replace("\n", ""))
  675. # -----------------------------------------------------------------
  676. @pyqtSlot(int, str)
  677. def slot_handlePluginAddedCallback(self, pluginId, pluginName):
  678. self.fContainer.addPlugin(pluginId, self.fIsProjectLoading)
  679. if self.fContainer.getPluginCount() == 1:
  680. self.ui.act_plugin_remove_all.setEnabled(True)
  681. @pyqtSlot(int)
  682. def slot_handlePluginRemovedCallback(self, pluginId):
  683. self.fContainer.removePlugin(pluginId)
  684. if self.fContainer.getPluginCount() == 0:
  685. self.ui.act_plugin_remove_all.setEnabled(False)
  686. @pyqtSlot(int, str)
  687. def slot_handlePluginRenamedCallback(self, pluginId, newName):
  688. self.fContainer.renamePlugin(pluginId, newName)
  689. @pyqtSlot(int, str)
  690. def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg):
  691. self.fContainer.disablePlugin(pluginId, errorMsg)
  692. # -----------------------------------------------------------------
  693. @pyqtSlot(str)
  694. def slot_handleEngineStartedCallback(self, processMode, transportMode, driverName):
  695. Carla.processMode = processMode
  696. Carla.transportMode = transportMode
  697. Carla.bufferSize = Carla.host.get_buffer_size()
  698. Carla.sampleRate = Carla.host.get_sample_rate()
  699. self.slot_engineStart(False)
  700. if self.fIdleTimerFast == 0:
  701. self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL])
  702. if self.fIdleTimerSlow == 0:
  703. self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*2)
  704. @pyqtSlot()
  705. def slot_handleEngineStoppedCallback(self):
  706. if self.fIdleTimerFast != 0:
  707. self.killTimer(self.fIdleTimerFast)
  708. self.fIdleTimerFast = 0
  709. if self.fIdleTimerSlow != 0:
  710. self.killTimer(self.fIdleTimerSlow)
  711. self.fIdleTimerSlow = 0
  712. self.slot_engineStop(False)
  713. Carla.bufferSize = 0
  714. Carla.sampleRate = 0.0
  715. # -----------------------------------------------------------------
  716. @pyqtSlot(int)
  717. def slot_handleProcessModeChangedCallback(self, newProcessMode):
  718. self.fEngineChanged = True
  719. @pyqtSlot(int)
  720. def slot_handleTransportModeChangedCallback(self, newTransportMode):
  721. self.fEngineChanged = True
  722. # -----------------------------------------------------------------
  723. @pyqtSlot(int)
  724. def slot_handleBufferSizeChangedCallback(self, newBufferSize):
  725. self.fEngineChanged = True
  726. @pyqtSlot(float)
  727. def slot_handleSampleRateChangedCallback(self, newSampleRate):
  728. self.fEngineChanged = True
  729. # -----------------------------------------------------------------
  730. @pyqtSlot(str)
  731. def slot_handleInfoCallback(self, info):
  732. pass
  733. @pyqtSlot(str)
  734. def slot_handleErrorCallback(self, error):
  735. pass
  736. @pyqtSlot()
  737. def slot_handleQuitCallback(self):
  738. pass
  739. # -----------------------------------------------------------------
  740. @pyqtSlot()
  741. def slot_handleSIGUSR1(self):
  742. print("Got SIGUSR1 -> Saving project now")
  743. QTimer.singleShot(0, self.slot_fileSave)
  744. @pyqtSlot()
  745. def slot_handleSIGTERM(self):
  746. print("Got SIGTERM -> Closing now")
  747. self.close()
  748. # -----------------------------------------------------------------
  749. def timerEvent(self, event):
  750. if event.timerId() == self.fIdleTimerFast:
  751. if not Carla.isPlugin:
  752. Carla.host.engine_idle()
  753. self.refreshTransport()
  754. self.fContainer.idleFast()
  755. elif event.timerId() == self.fIdleTimerSlow:
  756. if self.fEngineChanged:
  757. self.fContainer.engineChanged()
  758. self.fEngineChanged = False
  759. self.fContainer.idleSlow()
  760. QMainWindow.timerEvent(self, event)
  761. def closeEvent(self, event):
  762. if self.fIdleTimerFast != 0:
  763. self.killTimer(self.fIdleTimerFast)
  764. self.fIdleTimerFast = 0
  765. if self.fIdleTimerSlow != 0:
  766. self.killTimer(self.fIdleTimerSlow)
  767. self.fIdleTimerSlow = 0
  768. self.saveSettings()
  769. if Carla.host.is_engine_running():
  770. Carla.host.set_engine_about_to_close()
  771. self.ui.act_plugin_remove_all.setEnabled(False)
  772. self.fContainer.removeAllPlugins()
  773. self.stopEngine()
  774. QMainWindow.closeEvent(self, event)
  775. # ------------------------------------------------------------------------------------------------------------
  776. # Engine callback
  777. def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr):
  778. if action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED:
  779. Carla.processMode = value1
  780. if Carla.gui is not None:
  781. Carla.gui.ProcessModeChangedCallback.emit(value1)
  782. return
  783. if action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED:
  784. Carla.transportMode = value1
  785. if Carla.gui is not None:
  786. Carla.gui.TransportModeChangedCallback.emit(value1)
  787. return
  788. if action == ENGINE_CALLBACK_BUFFER_SIZE_CHANGED:
  789. Carla.bufferSize = value1
  790. if Carla.gui is not None:
  791. Carla.gui.BufferSizeChangedCallback.emit(value1)
  792. return
  793. if action == ENGINE_CALLBACK_SAMPLE_RATE_CHANGED:
  794. Carla.sampleRate = value1
  795. if Carla.gui is not None:
  796. Carla.gui.SampleRateChangedCallback.emit(value3)
  797. return
  798. if Carla.gui is None:
  799. print("WARNING: Got engine callback but UI is not ready : ", pluginId, value1, value2, value3, valueStr)
  800. return
  801. valueStr = charPtrToString(valueStr)
  802. if action == ENGINE_CALLBACK_DEBUG:
  803. Carla.gui.DebugCallback.emit(pluginId, value1, value2, value3, valueStr)
  804. elif action == ENGINE_CALLBACK_PLUGIN_ADDED:
  805. Carla.gui.PluginAddedCallback.emit(pluginId, valueStr)
  806. elif action == ENGINE_CALLBACK_PLUGIN_REMOVED:
  807. Carla.gui.PluginRemovedCallback.emit(pluginId)
  808. elif action == ENGINE_CALLBACK_PLUGIN_RENAMED:
  809. Carla.gui.PluginRenamedCallback.emit(pluginId, valueStr)
  810. elif action == ENGINE_CALLBACK_PLUGIN_UNAVAILABLE:
  811. Carla.gui.PluginUnavailableCallback.emit(pluginId, valueStr)
  812. elif action == ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED:
  813. Carla.gui.ParameterValueChangedCallback.emit(pluginId, value1, value3)
  814. elif action == ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED:
  815. Carla.gui.ParameterDefaultChangedCallback.emit(pluginId, value1, value3)
  816. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  817. Carla.gui.ParameterMidiCcChangedCallback.emit(pluginId, value1, value2)
  818. elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  819. Carla.gui.ParameterMidiChannelChangedCallback.emit(pluginId, value1, value2)
  820. elif action == ENGINE_CALLBACK_PROGRAM_CHANGED:
  821. Carla.gui.ProgramChangedCallback.emit(pluginId, value1)
  822. elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
  823. Carla.gui.MidiProgramChangedCallback.emit(pluginId, value1)
  824. elif action == ENGINE_CALLBACK_UI_STATE_CHANGED:
  825. Carla.gui.UiStateChangedCallback.emit(pluginId, value1)
  826. elif action == ENGINE_CALLBACK_NOTE_ON:
  827. Carla.gui.NoteOnCallback.emit(pluginId, value1, value2, int(value3))
  828. elif action == ENGINE_CALLBACK_NOTE_OFF:
  829. Carla.gui.NoteOffCallback.emit(pluginId, value1, value2)
  830. elif action == ENGINE_CALLBACK_UPDATE:
  831. Carla.gui.UpdateCallback.emit(pluginId)
  832. elif action == ENGINE_CALLBACK_RELOAD_INFO:
  833. Carla.gui.ReloadInfoCallback.emit(pluginId)
  834. elif action == ENGINE_CALLBACK_RELOAD_PARAMETERS:
  835. Carla.gui.ReloadParametersCallback.emit(pluginId)
  836. elif action == ENGINE_CALLBACK_RELOAD_PROGRAMS:
  837. Carla.gui.ReloadProgramsCallback.emit(pluginId)
  838. elif action == ENGINE_CALLBACK_RELOAD_ALL:
  839. Carla.gui.ReloadAllCallback.emit(pluginId)
  840. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED:
  841. Carla.gui.PatchbayClientAddedCallback.emit(pluginId, value1, valueStr)
  842. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED:
  843. Carla.gui.PatchbayClientRemovedCallback.emit(pluginId)
  844. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED:
  845. Carla.gui.PatchbayClientRenamedCallback.emit(pluginId, valueStr)
  846. elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED:
  847. Carla.gui.PatchbayClientIconChangedCallback.emit(pluginId, value1)
  848. elif action == ENGINE_CALLBACK_PATCHBAY_PORT_ADDED:
  849. Carla.gui.PatchbayPortAddedCallback.emit(pluginId, value1, value2, valueStr)
  850. elif action == ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED:
  851. Carla.gui.PatchbayPortRemovedCallback.emit(pluginId, value1)
  852. elif action == ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED:
  853. Carla.gui.PatchbayPortRenamedCallback.emit(pluginId, value1, valueStr)
  854. elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
  855. Carla.gui.PatchbayConnectionAddedCallback.emit(pluginId, value1, value2)
  856. elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  857. Carla.gui.PatchbayConnectionRemovedCallback.emit(pluginId, value1, value2)
  858. elif action == ENGINE_CALLBACK_ENGINE_STARTED:
  859. Carla.gui.EngineStartedCallback.emit(value1, value2, valueStr)
  860. elif action == ENGINE_CALLBACK_ENGINE_STOPPED:
  861. Carla.gui.EngineStoppedCallback.emit()
  862. elif action == ENGINE_CALLBACK_INFO:
  863. Carla.gui.InfoCallback.emit(valueStr)
  864. elif action == ENGINE_CALLBACK_ERROR:
  865. Carla.gui.ErrorCallback.emit(valueStr)
  866. elif action == ENGINE_CALLBACK_QUIT:
  867. Carla.gui.QuitCallback.emit()