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.

1211 lines
46KB

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