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.

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