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.

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