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.

2002 lines
81KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin host
  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 GPL.txt file
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from time import sleep
  20. from PyQt4.QtCore import Qt, QModelIndex, QPointF, QSize
  21. from PyQt4.QtGui import QApplication, QDialogButtonBox, QFileSystemModel, QLabel, QMainWindow, QResizeEvent
  22. from PyQt4.QtGui import QImage, QPrinter, QPrintDialog
  23. # ------------------------------------------------------------------------------------------------------------
  24. # Imports (Custom Stuff)
  25. import patchcanvas
  26. import ui_carla
  27. import ui_carla_settings
  28. from carla_shared import *
  29. # ------------------------------------------------------------------------------------------------------------
  30. # Try Import OpenGL
  31. try:
  32. from PyQt4.QtOpenGL import QGLWidget
  33. hasGL = True
  34. except:
  35. hasGL = False
  36. # ------------------------------------------------------------------------------------------------------------
  37. # Static Variables
  38. DEFAULT_CANVAS_WIDTH = 3100
  39. DEFAULT_CANVAS_HEIGHT = 2400
  40. # Tab indexes
  41. TAB_INDEX_MAIN = 0
  42. TAB_INDEX_CANVAS = 1
  43. TAB_INDEX_CARLA_ENGINE = 2
  44. TAB_INDEX_CARLA_PATHS = 3
  45. TAB_INDEX_NONE = 4
  46. # Single and Multiple client mode is only for JACK,
  47. # but we still want to match QComboBox index to defines,
  48. # so add +2 pos padding if driverName != "JACK".
  49. PROCESS_MODE_NON_JACK_PADDING = 2
  50. # Carla defaults
  51. CARLA_DEFAULT_PROCESS_HIGH_PRECISION = False
  52. CARLA_DEFAULT_MAX_PARAMETERS = 200
  53. CARLA_DEFAULT_FORCE_STEREO = False
  54. CARLA_DEFAULT_USE_DSSI_VST_CHUNKS = False
  55. CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES = False
  56. CARLA_DEFAULT_PREFER_UI_BRIDGES = True
  57. CARLA_DEFAULT_OSC_UI_TIMEOUT = 4000
  58. CARLA_DEFAULT_DISABLE_CHECKS = False
  59. # PatchCanvas defines
  60. CANVAS_ANTIALIASING_SMALL = 1
  61. CANVAS_EYECANDY_SMALL = 1
  62. # ------------------------------------------------------------------------------------------------------------
  63. # Settings Dialog
  64. class CarlaSettingsW(QDialog):
  65. def __init__(self, parent):
  66. QDialog.__init__(self, parent)
  67. self.ui = ui_carla_settings.Ui_CarlaSettingsW()
  68. self.ui.setupUi(self)
  69. # -------------------------------------------------------------
  70. # Set-up GUI
  71. driverCount = Carla.host.get_engine_driver_count()
  72. for i in range(driverCount):
  73. driverName = cString(Carla.host.get_engine_driver_name(i))
  74. self.ui.cb_engine_audio_driver.addItem(driverName)
  75. # -------------------------------------------------------------
  76. # Load settings
  77. self.loadSettings()
  78. if not hasGL:
  79. self.ui.cb_canvas_use_opengl.setChecked(False)
  80. self.ui.cb_canvas_use_opengl.setEnabled(False)
  81. if WINDOWS:
  82. self.ui.ch_engine_dssi_chunks.setChecked(False)
  83. self.ui.ch_engine_dssi_chunks.setEnabled(False)
  84. # -------------------------------------------------------------
  85. # Set-up connections
  86. self.connect(self, SIGNAL("accepted()"), SLOT("slot_saveSettings()"))
  87. self.connect(self.ui.buttonBox.button(QDialogButtonBox.Reset), SIGNAL("clicked()"), SLOT("slot_resetSettings()"))
  88. self.connect(self.ui.b_main_def_folder_open, SIGNAL("clicked()"), SLOT("slot_getAndSetProjectPath()"))
  89. self.connect(self.ui.cb_engine_audio_driver, SIGNAL("currentIndexChanged(int)"), SLOT("slot_engineAudioDriverChanged()"))
  90. self.connect(self.ui.b_paths_add, SIGNAL("clicked()"), SLOT("slot_addPluginPath()"))
  91. self.connect(self.ui.b_paths_remove, SIGNAL("clicked()"), SLOT("slot_removePluginPath()"))
  92. self.connect(self.ui.b_paths_change, SIGNAL("clicked()"), SLOT("slot_changePluginPath()"))
  93. self.connect(self.ui.tw_paths, SIGNAL("currentChanged(int)"), SLOT("slot_pluginPathTabChanged(int)"))
  94. self.connect(self.ui.lw_ladspa, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  95. self.connect(self.ui.lw_dssi, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  96. self.connect(self.ui.lw_lv2, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  97. self.connect(self.ui.lw_vst, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  98. self.connect(self.ui.lw_sf2, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  99. # -------------------------------------------------------------
  100. # Post-connect setup
  101. self.ui.lw_ladspa.setCurrentRow(0)
  102. self.ui.lw_dssi.setCurrentRow(0)
  103. self.ui.lw_lv2.setCurrentRow(0)
  104. self.ui.lw_vst.setCurrentRow(0)
  105. self.ui.lw_gig.setCurrentRow(0)
  106. self.ui.lw_sf2.setCurrentRow(0)
  107. self.ui.lw_sfz.setCurrentRow(0)
  108. self.ui.lw_page.setCurrentCell(0, 0)
  109. def loadSettings(self):
  110. settings = QSettings()
  111. # ---------------------------------------
  112. self.ui.le_main_def_folder.setText(settings.value("Main/DefaultProjectFolder", HOME, type=str))
  113. self.ui.sb_gui_refresh.setValue(settings.value("Main/RefreshInterval", 50, type=int))
  114. # ---------------------------------------
  115. self.ui.cb_canvas_hide_groups.setChecked(settings.value("Canvas/AutoHideGroups", False, type=bool))
  116. self.ui.cb_canvas_bezier_lines.setChecked(settings.value("Canvas/UseBezierLines", True, type=bool))
  117. self.ui.cb_canvas_eyecandy.setCheckState(settings.value("Canvas/EyeCandy", CANVAS_EYECANDY_SMALL, type=int))
  118. self.ui.cb_canvas_use_opengl.setChecked(settings.value("Canvas/UseOpenGL", False, type=bool))
  119. self.ui.cb_canvas_render_aa.setCheckState(settings.value("Canvas/Antialiasing", CANVAS_ANTIALIASING_SMALL, type=int))
  120. self.ui.cb_canvas_render_hq_aa.setChecked(settings.value("Canvas/HighQualityAntialiasing", False, type=bool))
  121. themeName = settings.value("Canvas/Theme", patchcanvas.getDefaultThemeName(), type=str)
  122. for i in range(patchcanvas.Theme.THEME_MAX):
  123. thisThemeName = patchcanvas.getThemeName(i)
  124. self.ui.cb_canvas_theme.addItem(thisThemeName)
  125. if thisThemeName == themeName:
  126. self.ui.cb_canvas_theme.setCurrentIndex(i)
  127. # --------------------------------------------
  128. if WINDOWS:
  129. defaultDriver = "DirectSound"
  130. elif MACOS:
  131. defaultDriver = "CoreAudio"
  132. else:
  133. defaultDriver = "JACK"
  134. audioDriver = settings.value("Engine/AudioDriver", defaultDriver, type=str)
  135. for i in range(self.ui.cb_engine_audio_driver.count()):
  136. if self.ui.cb_engine_audio_driver.itemText(i) == audioDriver:
  137. self.ui.cb_engine_audio_driver.setCurrentIndex(i)
  138. break
  139. else:
  140. self.ui.cb_engine_audio_driver.setCurrentIndex(-1)
  141. if audioDriver == "JACK":
  142. processModeIndex = settings.value("Engine/ProcessMode", PROCESS_MODE_MULTIPLE_CLIENTS, type=int)
  143. self.ui.cb_engine_process_mode_jack.setCurrentIndex(processModeIndex)
  144. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  145. else:
  146. processModeIndex = settings.value("Engine/ProcessMode", PROCESS_MODE_CONTINUOUS_RACK, type=int)
  147. processModeIndex -= PROCESS_MODE_NON_JACK_PADDING
  148. self.ui.cb_engine_process_mode_other.setCurrentIndex(processModeIndex)
  149. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  150. self.ui.sb_engine_max_params.setValue(settings.value("Engine/MaxParameters", CARLA_DEFAULT_MAX_PARAMETERS, type=int))
  151. self.ui.ch_engine_prefer_ui_bridges.setChecked(settings.value("Engine/PreferUiBridges", CARLA_DEFAULT_PREFER_UI_BRIDGES, type=bool))
  152. self.ui.sb_engine_oscgui_timeout.setValue(settings.value("Engine/OscUiTimeout", CARLA_DEFAULT_OSC_UI_TIMEOUT, type=int))
  153. self.ui.ch_engine_disable_checks.setChecked(settings.value("Engine/DisableChecks", CARLA_DEFAULT_DISABLE_CHECKS, type=bool))
  154. self.ui.ch_engine_dssi_chunks.setChecked(settings.value("Engine/UseDssiVstChunks", CARLA_DEFAULT_USE_DSSI_VST_CHUNKS, type=bool))
  155. self.ui.ch_engine_prefer_plugin_bridges.setChecked(settings.value("Engine/PreferPluginBridges", CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES, type=bool))
  156. self.ui.ch_engine_force_stereo.setChecked(settings.value("Engine/ForceStereo", CARLA_DEFAULT_FORCE_STEREO, type=bool))
  157. # --------------------------------------------
  158. ladspas = toList(settings.value("Paths/LADSPA", Carla.LADSPA_PATH))
  159. dssis = toList(settings.value("Paths/DSSI", Carla.DSSI_PATH))
  160. lv2s = toList(settings.value("Paths/LV2", Carla.LV2_PATH))
  161. vsts = toList(settings.value("Paths/VST", Carla.VST_PATH))
  162. gigs = toList(settings.value("Paths/GIG", Carla.GIG_PATH))
  163. sf2s = toList(settings.value("Paths/SF2", Carla.SF2_PATH))
  164. sfzs = toList(settings.value("Paths/SFZ", Carla.SFZ_PATH))
  165. ladspas.sort()
  166. dssis.sort()
  167. lv2s.sort()
  168. vsts.sort()
  169. gigs.sort()
  170. sf2s.sort()
  171. sfzs.sort()
  172. for ladspa in ladspas:
  173. self.ui.lw_ladspa.addItem(ladspa)
  174. for dssi in dssis:
  175. self.ui.lw_dssi.addItem(dssi)
  176. for lv2 in lv2s:
  177. self.ui.lw_lv2.addItem(lv2)
  178. for vst in vsts:
  179. self.ui.lw_vst.addItem(vst)
  180. for gig in gigs:
  181. self.ui.lw_gig.addItem(gig)
  182. for sf2 in sf2s:
  183. self.ui.lw_sf2.addItem(sf2)
  184. for sfz in sfzs:
  185. self.ui.lw_sfz.addItem(sfz)
  186. @pyqtSlot()
  187. def slot_saveSettings(self):
  188. settings = QSettings()
  189. # ---------------------------------------
  190. settings.setValue("Main/RefreshInterval", self.ui.sb_gui_refresh.value())
  191. settings.setValue("Main/DefaultProjectFolder", self.ui.le_main_def_folder.text())
  192. # ---------------------------------------
  193. settings.setValue("Canvas/Theme", self.ui.cb_canvas_theme.currentText())
  194. settings.setValue("Canvas/AutoHideGroups", self.ui.cb_canvas_hide_groups.isChecked())
  195. settings.setValue("Canvas/UseBezierLines", self.ui.cb_canvas_bezier_lines.isChecked())
  196. settings.setValue("Canvas/UseOpenGL", self.ui.cb_canvas_use_opengl.isChecked())
  197. settings.setValue("Canvas/HighQualityAntialiasing", self.ui.cb_canvas_render_hq_aa.isChecked())
  198. # 0, 1, 2 match their enum variants
  199. settings.setValue("Canvas/EyeCandy", self.ui.cb_canvas_eyecandy.checkState())
  200. settings.setValue("Canvas/Antialiasing", self.ui.cb_canvas_render_aa.checkState())
  201. # --------------------------------------------
  202. audioDriver = self.ui.cb_engine_audio_driver.currentText()
  203. settings.setValue("Engine/AudioDriver", audioDriver)
  204. if audioDriver == "JACK":
  205. settings.setValue("Engine/ProcessMode", self.ui.cb_engine_process_mode_jack.currentIndex())
  206. else:
  207. settings.setValue("Engine/ProcessMode", self.ui.cb_engine_process_mode_other.currentIndex()+PROCESS_MODE_NON_JACK_PADDING)
  208. settings.setValue("Engine/MaxParameters", self.ui.sb_engine_max_params.value())
  209. settings.setValue("Engine/PreferUiBridges", self.ui.ch_engine_prefer_ui_bridges.isChecked())
  210. settings.setValue("Engine/OscUiTimeout", self.ui.sb_engine_oscgui_timeout.value())
  211. settings.setValue("Engine/DisableChecks", self.ui.ch_engine_disable_checks.isChecked())
  212. settings.setValue("Engine/UseDssiVstChunks", self.ui.ch_engine_dssi_chunks.isChecked())
  213. settings.setValue("Engine/PreferPluginBridges", self.ui.ch_engine_prefer_plugin_bridges.isChecked())
  214. settings.setValue("Engine/ForceStereo", self.ui.ch_engine_force_stereo.isChecked())
  215. # --------------------------------------------
  216. # FIXME - find a cleaner way to do this, *.items() ?
  217. ladspas = []
  218. dssis = []
  219. lv2s = []
  220. vsts = []
  221. gigs = []
  222. sf2s = []
  223. sfzs = []
  224. for i in range(self.ui.lw_ladspa.count()):
  225. ladspas.append(self.ui.lw_ladspa.item(i).text())
  226. for i in range(self.ui.lw_dssi.count()):
  227. dssis.append(self.ui.lw_dssi.item(i).text())
  228. for i in range(self.ui.lw_lv2.count()):
  229. lv2s.append(self.ui.lw_lv2.item(i).text())
  230. for i in range(self.ui.lw_vst.count()):
  231. vsts.append(self.ui.lw_vst.item(i).text())
  232. for i in range(self.ui.lw_gig.count()):
  233. gigs.append(self.ui.lw_gig.item(i).text())
  234. for i in range(self.ui.lw_sf2.count()):
  235. sf2s.append(self.ui.lw_sf2.item(i).text())
  236. for i in range(self.ui.lw_sfz.count()):
  237. sfzs.append(self.ui.lw_sfz.item(i).text())
  238. settings.setValue("Paths/LADSPA", ladspas)
  239. settings.setValue("Paths/DSSI", dssis)
  240. settings.setValue("Paths/LV2", lv2s)
  241. settings.setValue("Paths/VST", vsts)
  242. settings.setValue("Paths/GIG", gigs)
  243. settings.setValue("Paths/SF2", sf2s)
  244. settings.setValue("Paths/SFZ", sfzs)
  245. @pyqtSlot()
  246. def slot_resetSettings(self):
  247. if self.ui.lw_page.currentRow() == TAB_INDEX_MAIN:
  248. self.ui.le_main_def_folder.setText(HOME)
  249. self.ui.sb_gui_refresh.setValue(50)
  250. elif self.ui.lw_page.currentRow() == TAB_INDEX_CANVAS:
  251. self.ui.cb_canvas_theme.setCurrentIndex(0)
  252. self.ui.cb_canvas_hide_groups.setChecked(False)
  253. self.ui.cb_canvas_bezier_lines.setChecked(True)
  254. self.ui.cb_canvas_eyecandy.setCheckState(Qt.PartiallyChecked)
  255. self.ui.cb_canvas_use_opengl.setChecked(False)
  256. self.ui.cb_canvas_render_aa.setCheckState(Qt.PartiallyChecked)
  257. self.ui.cb_canvas_render_hq_aa.setChecked(False)
  258. elif self.ui.lw_page.currentRow() == TAB_INDEX_CARLA_ENGINE:
  259. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  260. self.ui.sb_engine_max_params.setValue(CARLA_DEFAULT_MAX_PARAMETERS)
  261. self.ui.ch_engine_prefer_ui_bridges.setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES)
  262. self.ui.sb_engine_oscgui_timeout.setValue(CARLA_DEFAULT_OSC_UI_TIMEOUT)
  263. self.ui.ch_engine_disable_checks.setChecked(CARLA_DEFAULT_DISABLE_CHECKS)
  264. self.ui.ch_engine_dssi_chunks.setChecked(CARLA_DEFAULT_USE_DSSI_VST_CHUNKS)
  265. self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES)
  266. self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO)
  267. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  268. self.ui.cb_engine_process_mode_jack.setCurrentIndex(PROCESS_MODE_MULTIPLE_CLIENTS)
  269. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  270. else:
  271. self.ui.cb_engine_process_mode_other.setCurrentIndex(PROCESS_MODE_CONTINUOUS_RACK-PROCESS_MODE_NON_JACK_PADDING)
  272. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  273. elif self.ui.lw_page.currentRow() == TAB_INDEX_CARLA_PATHS:
  274. if self.ui.tw_paths.currentIndex() == 0:
  275. Carla.LADSPA_PATH.sort()
  276. self.ui.lw_ladspa.clear()
  277. for ladspa in Carla.LADSPA_PATH:
  278. self.ui.lw_ladspa.addItem(ladspa)
  279. elif self.ui.tw_paths.currentIndex() == 1:
  280. Carla.DSSI_PATH.sort()
  281. self.ui.lw_dssi.clear()
  282. for dssi in Carla.DSSI_PATH:
  283. self.ui.lw_dssi.addItem(dssi)
  284. elif self.ui.tw_paths.currentIndex() == 2:
  285. Carla.LV2_PATH.sort()
  286. self.ui.lw_lv2.clear()
  287. for lv2 in Carla.LV2_PATH:
  288. self.ui.lw_lv2.addItem(lv2)
  289. elif self.ui.tw_paths.currentIndex() == 3:
  290. Carla.VST_PATH.sort()
  291. self.ui.lw_vst.clear()
  292. for vst in Carla.VST_PATH:
  293. self.ui.lw_vst.addItem(vst)
  294. elif self.ui.tw_paths.currentIndex() == 4:
  295. Carla.GIG_PATH.sort()
  296. self.ui.lw_gig.clear()
  297. for gig in Carla.GIG_PATH:
  298. self.ui.lw_gig.addItem(gig)
  299. elif self.ui.tw_paths.currentIndex() == 5:
  300. Carla.SF2_PATH.sort()
  301. self.ui.lw_sf2.clear()
  302. for sf2 in Carla.SF2_PATH:
  303. self.ui.lw_sf2.addItem(sf2)
  304. elif self.ui.tw_paths.currentIndex() == 6:
  305. Carla.SFZ_PATH.sort()
  306. self.ui.lw_sfz.clear()
  307. for sfz in Carla.SFZ_PATH:
  308. self.ui.lw_sfz.addItem(sfz)
  309. @pyqtSlot()
  310. def slot_getAndSetProjectPath(self):
  311. getAndSetPath(self, self.ui.le_main_def_folder.text(), self.ui.le_main_def_folder)
  312. @pyqtSlot()
  313. def slot_engineAudioDriverChanged(self):
  314. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  315. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  316. else:
  317. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  318. @pyqtSlot()
  319. def slot_addPluginPath(self):
  320. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  321. if newPath:
  322. if self.ui.tw_paths.currentIndex() == 0:
  323. self.ui.lw_ladspa.addItem(newPath)
  324. elif self.ui.tw_paths.currentIndex() == 1:
  325. self.ui.lw_dssi.addItem(newPath)
  326. elif self.ui.tw_paths.currentIndex() == 2:
  327. self.ui.lw_lv2.addItem(newPath)
  328. elif self.ui.tw_paths.currentIndex() == 3:
  329. self.ui.lw_vst.addItem(newPath)
  330. elif self.ui.tw_paths.currentIndex() == 4:
  331. self.ui.lw_gig.addItem(newPath)
  332. elif self.ui.tw_paths.currentIndex() == 5:
  333. self.ui.lw_sf2.addItem(newPath)
  334. elif self.ui.tw_paths.currentIndex() == 6:
  335. self.ui.lw_sfz.addItem(newPath)
  336. @pyqtSlot()
  337. def slot_removePluginPath(self):
  338. if self.ui.tw_paths.currentIndex() == 0:
  339. self.ui.lw_ladspa.takeItem(self.ui.lw_ladspa.currentRow())
  340. elif self.ui.tw_paths.currentIndex() == 1:
  341. self.ui.lw_dssi.takeItem(self.ui.lw_dssi.currentRow())
  342. elif self.ui.tw_paths.currentIndex() == 2:
  343. self.ui.lw_lv2.takeItem(self.ui.lw_lv2.currentRow())
  344. elif self.ui.tw_paths.currentIndex() == 3:
  345. self.ui.lw_vst.takeItem(self.ui.lw_vst.currentRow())
  346. elif self.ui.tw_paths.currentIndex() == 4:
  347. self.ui.lw_gig.takeItem(self.ui.lw_gig.currentRow())
  348. elif self.ui.tw_paths.currentIndex() == 5:
  349. self.ui.lw_sf2.takeItem(self.ui.lw_sf2.currentRow())
  350. elif self.ui.tw_paths.currentIndex() == 6:
  351. self.ui.lw_sfz.takeItem(self.ui.lw_sfz.currentRow())
  352. @pyqtSlot()
  353. def slot_changePluginPath(self):
  354. if self.ui.tw_paths.currentIndex() == 0:
  355. currentPath = self.ui.lw_ladspa.currentItem().text()
  356. elif self.ui.tw_paths.currentIndex() == 1:
  357. currentPath = self.ui.lw_dssi.currentItem().text()
  358. elif self.ui.tw_paths.currentIndex() == 2:
  359. currentPath = self.ui.lw_lv2.currentItem().text()
  360. elif self.ui.tw_paths.currentIndex() == 3:
  361. currentPath = self.ui.lw_vst.currentItem().text()
  362. elif self.ui.tw_paths.currentIndex() == 4:
  363. currentPath = self.ui.lw_gig.currentItem().text()
  364. elif self.ui.tw_paths.currentIndex() == 5:
  365. currentPath = self.ui.lw_sf2.currentItem().text()
  366. elif self.ui.tw_paths.currentIndex() == 6:
  367. currentPath = self.ui.lw_sfz.currentItem().text()
  368. else:
  369. currentPath = ""
  370. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  371. if newPath:
  372. if self.ui.tw_paths.currentIndex() == 0:
  373. self.ui.lw_ladspa.currentItem().setText(newPath)
  374. elif self.ui.tw_paths.currentIndex() == 1:
  375. self.ui.lw_dssi.currentItem().setText(newPath)
  376. elif self.ui.tw_paths.currentIndex() == 2:
  377. self.ui.lw_lv2.currentItem().setText(newPath)
  378. elif self.ui.tw_paths.currentIndex() == 3:
  379. self.ui.lw_vst.currentItem().setText(newPath)
  380. elif self.ui.tw_paths.currentIndex() == 4:
  381. self.ui.lw_gig.currentItem().setText(newPath)
  382. elif self.ui.tw_paths.currentIndex() == 5:
  383. self.ui.lw_sf2.currentItem().setText(newPath)
  384. elif self.ui.tw_paths.currentIndex() == 6:
  385. self.ui.lw_sfz.currentItem().setText(newPath)
  386. @pyqtSlot(int)
  387. def slot_pluginPathTabChanged(self, index):
  388. if index == 0:
  389. row = self.ui.lw_ladspa.currentRow()
  390. elif index == 1:
  391. row = self.ui.lw_dssi.currentRow()
  392. elif index == 2:
  393. row = self.ui.lw_lv2.currentRow()
  394. elif index == 3:
  395. row = self.ui.lw_vst.currentRow()
  396. elif index == 4:
  397. row = self.ui.lw_gig.currentRow()
  398. elif index == 5:
  399. row = self.ui.lw_sf2.currentRow()
  400. elif index == 6:
  401. row = self.ui.lw_sfz.currentRow()
  402. else:
  403. row = -1
  404. check = bool(row >= 0)
  405. self.ui.b_paths_remove.setEnabled(check)
  406. self.ui.b_paths_change.setEnabled(check)
  407. @pyqtSlot(int)
  408. def slot_pluginPathRowChanged(self, row):
  409. check = bool(row >= 0)
  410. self.ui.b_paths_remove.setEnabled(check)
  411. self.ui.b_paths_change.setEnabled(check)
  412. def done(self, r):
  413. QDialog.done(self, r)
  414. self.close()
  415. # ------------------------------------------------------------------------------------------------------------
  416. # Main Window
  417. class CarlaMainW(QMainWindow):
  418. def __init__(self, parent=None):
  419. QMainWindow.__init__(self, parent)
  420. self.ui = ui_carla.Ui_CarlaMainW()
  421. self.ui.setupUi(self)
  422. # -------------------------------------------------------------
  423. # Load Settings
  424. self.loadSettings(True)
  425. self.loadRDFs()
  426. self.setStyleSheet("""
  427. QWidget#w_plugins {
  428. background-color: qlineargradient(spread:pad,
  429. x1:0.0, y1:0.0,
  430. x2:0.2, y2:1.0,
  431. stop:0 rgb( 7, 7, 7),
  432. stop:1 rgb(28, 28, 28)
  433. );
  434. }
  435. """)
  436. # -------------------------------------------------------------
  437. # Internal stuff
  438. self.fBufferSize = 0
  439. self.fSampleRate = 0.0
  440. self.fEngineStarted = False
  441. self.fFirstEngineInit = False
  442. self.fProjectFilename = None
  443. self.fProjectLoading = False
  444. self.fPluginCount = 0
  445. self.fPluginList = []
  446. self.fIdleTimerFast = 0
  447. self.fIdleTimerSlow = 0
  448. self.fLastLoadedPluginId = -1
  449. self.fTransportWasPlaying = False
  450. self.fSessionManagerName = "LADISH" if os.getenv("LADISH_APP_NAME") else ""
  451. # -------------------------------------------------------------
  452. # Set-up GUI stuff
  453. self.fInfoLabel = QLabel(self)
  454. self.fInfoLabel.setText("")
  455. self.fInfoText = ""
  456. self.fDirModel = QFileSystemModel(self)
  457. self.fDirModel.setNameFilters(cString(Carla.host.get_supported_file_types()).split(";"))
  458. self.fDirModel.setRootPath(HOME)
  459. self.ui.fileTreeView.setModel(self.fDirModel)
  460. self.ui.fileTreeView.setRootIndex(self.fDirModel.index(HOME))
  461. self.ui.fileTreeView.setColumnHidden(1, True)
  462. self.ui.fileTreeView.setColumnHidden(2, True)
  463. self.ui.fileTreeView.setColumnHidden(3, True)
  464. self.ui.fileTreeView.setHeaderHidden(True)
  465. self.ui.act_engine_start.setEnabled(False)
  466. self.ui.act_engine_stop.setEnabled(False)
  467. self.ui.act_plugin_remove_all.setEnabled(False)
  468. # FIXME: Qt4 needs this so it properly create & resize the canvas
  469. self.ui.tabMain.setCurrentIndex(1)
  470. self.ui.tabMain.setCurrentIndex(0)
  471. # -------------------------------------------------------------
  472. # Set-up Canvas
  473. self.scene = patchcanvas.PatchScene(self, self.ui.graphicsView)
  474. self.ui.graphicsView.setScene(self.scene)
  475. self.ui.graphicsView.setRenderHint(QPainter.Antialiasing, bool(self.fSavedSettings["Canvas/Antialiasing"] == patchcanvas.ANTIALIASING_FULL))
  476. if self.fSavedSettings["Canvas/UseOpenGL"] and hasGL:
  477. self.ui.graphicsView.setViewport(QGLWidget(self.ui.graphicsView))
  478. self.ui.graphicsView.setRenderHint(QPainter.HighQualityAntialiasing, self.fSavedSettings["Canvas/HighQualityAntialiasing"])
  479. pOptions = patchcanvas.options_t()
  480. pOptions.theme_name = self.fSavedSettings["Canvas/Theme"]
  481. pOptions.auto_hide_groups = self.fSavedSettings["Canvas/AutoHideGroups"]
  482. pOptions.use_bezier_lines = self.fSavedSettings["Canvas/UseBezierLines"]
  483. pOptions.antialiasing = self.fSavedSettings["Canvas/Antialiasing"]
  484. pOptions.eyecandy = self.fSavedSettings["Canvas/EyeCandy"]
  485. pFeatures = patchcanvas.features_t()
  486. pFeatures.group_info = False
  487. pFeatures.group_rename = False
  488. pFeatures.port_info = False
  489. pFeatures.port_rename = False
  490. pFeatures.handle_group_pos = True
  491. patchcanvas.setOptions(pOptions)
  492. patchcanvas.setFeatures(pFeatures)
  493. patchcanvas.init("Carla", self.scene, canvasCallback, False)
  494. patchcanvas.setCanvasSize(0, 0, DEFAULT_CANVAS_WIDTH, DEFAULT_CANVAS_HEIGHT)
  495. patchcanvas.setInitialPos(DEFAULT_CANVAS_WIDTH / 2, DEFAULT_CANVAS_HEIGHT / 2)
  496. self.ui.graphicsView.setSceneRect(0, 0, DEFAULT_CANVAS_WIDTH, DEFAULT_CANVAS_HEIGHT)
  497. # -------------------------------------------------------------
  498. # Set-up Canvas Preview
  499. self.ui.miniCanvasPreview.setRealParent(self)
  500. self.ui.miniCanvasPreview.setViewTheme(patchcanvas.canvas.theme.canvas_bg, patchcanvas.canvas.theme.rubberband_brush, patchcanvas.canvas.theme.rubberband_pen.color())
  501. self.ui.miniCanvasPreview.init(self.scene, DEFAULT_CANVAS_WIDTH, DEFAULT_CANVAS_HEIGHT)
  502. QTimer.singleShot(100, self, SLOT("slot_miniCanvasInit()"))
  503. #self.m_fakeEdit = PluginEdit(self, -1)
  504. #self.m_curEdit = self.m_fakeEdit
  505. #self.w_edit.layout().addWidget(self.m_curEdit)
  506. #self.w_edit.layout().addStretch()
  507. # -------------------------------------------------------------
  508. # Connect actions to functions
  509. self.connect(self.ui.act_file_new, SIGNAL("triggered()"), SLOT("slot_fileNew()"))
  510. self.connect(self.ui.act_file_open, SIGNAL("triggered()"), SLOT("slot_fileOpen()"))
  511. self.connect(self.ui.act_file_save, SIGNAL("triggered()"), SLOT("slot_fileSave()"))
  512. self.connect(self.ui.act_file_save_as, SIGNAL("triggered()"), SLOT("slot_fileSaveAs()"))
  513. self.connect(self.ui.act_engine_start, SIGNAL("triggered()"), SLOT("slot_engineStart()"))
  514. self.connect(self.ui.act_engine_stop, SIGNAL("triggered()"), SLOT("slot_engineStop()"))
  515. self.connect(self.ui.act_plugin_add, SIGNAL("triggered()"), SLOT("slot_pluginAdd()"))
  516. self.connect(self.ui.act_plugin_remove_all, SIGNAL("triggered()"), SLOT("slot_pluginRemoveAll()"))
  517. self.connect(self.ui.act_transport_play, SIGNAL("triggered(bool)"), SLOT("slot_transportPlayPause(bool)"))
  518. self.connect(self.ui.act_transport_stop, SIGNAL("triggered()"), SLOT("slot_transportStop()"))
  519. self.connect(self.ui.act_transport_backwards, SIGNAL("triggered()"), SLOT("slot_transportBackwards()"))
  520. self.connect(self.ui.act_transport_forwards, SIGNAL("triggered()"), SLOT("slot_transportForwards()"))
  521. self.ui.act_canvas_arrange.setEnabled(False) # TODO, later
  522. self.connect(self.ui.act_canvas_arrange, SIGNAL("triggered()"), SLOT("slot_canvasArrange()"))
  523. self.connect(self.ui.act_canvas_refresh, SIGNAL("triggered()"), SLOT("slot_canvasRefresh()"))
  524. self.connect(self.ui.act_canvas_zoom_fit, SIGNAL("triggered()"), SLOT("slot_canvasZoomFit()"))
  525. self.connect(self.ui.act_canvas_zoom_in, SIGNAL("triggered()"), SLOT("slot_canvasZoomIn()"))
  526. self.connect(self.ui.act_canvas_zoom_out, SIGNAL("triggered()"), SLOT("slot_canvasZoomOut()"))
  527. self.connect(self.ui.act_canvas_zoom_100, SIGNAL("triggered()"), SLOT("slot_canvasZoomReset()"))
  528. self.connect(self.ui.act_canvas_print, SIGNAL("triggered()"), SLOT("slot_canvasPrint()"))
  529. self.connect(self.ui.act_canvas_save_image, SIGNAL("triggered()"), SLOT("slot_canvasSaveImage()"))
  530. self.connect(self.ui.act_settings_show_toolbar, SIGNAL("triggered(bool)"), SLOT("slot_toolbarShown()"))
  531. self.connect(self.ui.act_settings_configure, SIGNAL("triggered()"), SLOT("slot_configureCarla()"))
  532. self.connect(self.ui.act_help_about, SIGNAL("triggered()"), SLOT("slot_aboutCarla()"))
  533. self.connect(self.ui.act_help_about_qt, SIGNAL("triggered()"), app, SLOT("aboutQt()"))
  534. self.connect(self.ui.graphicsView.horizontalScrollBar(), SIGNAL("valueChanged(int)"), SLOT("slot_horizontalScrollBarChanged(int)"))
  535. self.connect(self.ui.graphicsView.verticalScrollBar(), SIGNAL("valueChanged(int)"), SLOT("slot_verticalScrollBarChanged(int)"))
  536. self.connect(self.ui.splitter, SIGNAL("splitterMoved(int, int)"), SLOT("slot_splitterMoved()"))
  537. self.connect(self.ui.fileTreeView, SIGNAL("doubleClicked(QModelIndex)"), SLOT("slot_fileTreeDoubleClicked(QModelIndex)"))
  538. self.connect(self.ui.miniCanvasPreview, SIGNAL("miniCanvasMoved(double, double)"), SLOT("slot_miniCanvasMoved(double, double)"))
  539. self.connect(self.scene, SIGNAL("sceneGroupMoved(int, int, QPointF)"), SLOT("slot_canvasItemMoved(int, int, QPointF)"))
  540. self.connect(self.scene, SIGNAL("scaleChanged(double)"), SLOT("slot_canvasScaleChanged(double)"))
  541. self.connect(self, SIGNAL("SIGUSR1()"), SLOT("slot_handleSIGUSR1()"))
  542. self.connect(self, SIGNAL("SIGTERM()"), SLOT("slot_handleSIGTERM()"))
  543. self.connect(self, SIGNAL("DebugCallback(int, int, int, double, QString)"), SLOT("slot_handleDebugCallback(int, int, int, double, QString)"))
  544. self.connect(self, SIGNAL("PluginAddedCallback(int)"), SLOT("slot_handlePluginAddedCallback(int)"))
  545. self.connect(self, SIGNAL("PluginRemovedCallback(int)"), SLOT("slot_handlePluginRemovedCallback(int)"))
  546. self.connect(self, SIGNAL("PluginRenamedCallback(int, QString)"), SLOT("slot_handlePluginRenamedCallback(int, QString)"))
  547. self.connect(self, SIGNAL("ParameterValueChangedCallback(int, int, double)"), SLOT("slot_handleParameterValueChangedCallback(int, int, double)"))
  548. self.connect(self, SIGNAL("ParameterDefaultChangedCallback(int, int, double)"), SLOT("slot_handleParameterDefaultChangedCallback(int, int, double)"))
  549. self.connect(self, SIGNAL("ParameterMidiChannelChangedCallback(int, int, int)"), SLOT("slot_handleParameterMidiChannelChangedCallback(int, int, int)"))
  550. self.connect(self, SIGNAL("ParameterMidiCcChangedCallback(int, int, int)"), SLOT("slot_handleParameterMidiCcChangedCallback(int, int, int)"))
  551. self.connect(self, SIGNAL("ProgramChangedCallback(int, int)"), SLOT("slot_handleProgramChangedCallback(int, int)"))
  552. self.connect(self, SIGNAL("MidiProgramChangedCallback(int, int)"), SLOT("slot_handleMidiProgramChangedCallback(int, int)"))
  553. self.connect(self, SIGNAL("NoteOnCallback(int, int, int, int)"), SLOT("slot_handleNoteOnCallback(int, int, int, int)"))
  554. self.connect(self, SIGNAL("NoteOffCallback(int, int, int)"), SLOT("slot_handleNoteOffCallback(int, int, int)"))
  555. self.connect(self, SIGNAL("ShowGuiCallback(int, int)"), SLOT("slot_handleShowGuiCallback(int, int)"))
  556. self.connect(self, SIGNAL("UpdateCallback(int)"), SLOT("slot_handleUpdateCallback(int)"))
  557. self.connect(self, SIGNAL("ReloadInfoCallback(int)"), SLOT("slot_handleReloadInfoCallback(int)"))
  558. self.connect(self, SIGNAL("ReloadParametersCallback(int)"), SLOT("slot_handleReloadParametersCallback(int)"))
  559. self.connect(self, SIGNAL("ReloadProgramsCallback(int)"), SLOT("slot_handleReloadProgramsCallback(int)"))
  560. self.connect(self, SIGNAL("ReloadAllCallback(int)"), SLOT("slot_handleReloadAllCallback(int)"))
  561. self.connect(self, SIGNAL("PatchbayClientAddedCallback(int, QString)"), SLOT("slot_handlePatchbayClientAddedCallback(int, QString)"))
  562. self.connect(self, SIGNAL("PatchbayClientRemovedCallback(int)"), SLOT("slot_handlePatchbayClientRemovedCallback(int)"))
  563. self.connect(self, SIGNAL("PatchbayClientRenamedCallback(int, QString)"), SLOT("slot_handlePatchbayClientRenamedCallback(int, QString)"))
  564. self.connect(self, SIGNAL("PatchbayPortAddedCallback(int, int, int, QString)"), SLOT("slot_handlePatchbayPortAddedCallback(int, int, int, QString)"))
  565. self.connect(self, SIGNAL("PatchbayPortRemovedCallback(int)"), SLOT("slot_handlePatchbayPortRemovedCallback(int)"))
  566. self.connect(self, SIGNAL("PatchbayPortRenamedCallback(int, QString)"), SLOT("slot_handlePatchbayPortRenamedCallback(int, QString)"))
  567. self.connect(self, SIGNAL("PatchbayConnectionAddedCallback(int, int, int)"), SLOT("slot_handlePatchbayConnectionAddedCallback(int, int, int)"))
  568. self.connect(self, SIGNAL("PatchbayConnectionRemovedCallback(int)"), SLOT("slot_handlePatchbayConnectionRemovedCallback(int)"))
  569. self.connect(self, SIGNAL("BufferSizeChangedCallback(int)"), SLOT("slot_handleBufferSizeChangedCallback(int)"))
  570. self.connect(self, SIGNAL("SampleRateChangedCallback(double)"), SLOT("slot_handleSampleRateChangedCallback(double)"))
  571. self.connect(self, SIGNAL("NSM_AnnounceCallback(QString)"), SLOT("slot_handleNSM_AnnounceCallback(QString)"))
  572. self.connect(self, SIGNAL("NSM_OpenCallback(QString)"), SLOT("slot_handleNSM_OpenCallback(QString)"))
  573. self.connect(self, SIGNAL("NSM_SaveCallback()"), SLOT("slot_handleNSM_SaveCallback()"))
  574. self.connect(self, SIGNAL("ErrorCallback(QString)"), SLOT("slot_handleErrorCallback(QString)"))
  575. self.connect(self, SIGNAL("QuitCallback()"), SLOT("slot_handleQuitCallback()"))
  576. self.setProperWindowTitle()
  577. NSM_URL = os.getenv("NSM_URL")
  578. if NSM_URL:
  579. Carla.host.nsm_announce(NSM_URL, os.getpid())
  580. else:
  581. QTimer.singleShot(0, self, SLOT("slot_engineStart()"))
  582. @pyqtSlot(str)
  583. def slot_handleNSM_AnnounceCallback(self, smName):
  584. self.fSessionManagerName = smName
  585. self.ui.act_file_new.setEnabled(False)
  586. self.ui.act_file_open.setEnabled(False)
  587. self.ui.act_file_save_as.setEnabled(False)
  588. @pyqtSlot(str)
  589. def slot_handleNSM_OpenCallback(self, data):
  590. projectPath, clientId = data.rsplit(":", 1)
  591. # restart engine
  592. if self.fEngineStarted:
  593. self.stopEngine()
  594. self.startEngine(clientId)
  595. if self.fEngineStarted:
  596. self.loadProject(projectPath)
  597. Carla.host.nsm_reply_open()
  598. @pyqtSlot()
  599. def slot_handleNSM_SaveCallback(self):
  600. self.saveProject(self.fProjectFilename)
  601. Carla.host.nsm_reply_save()
  602. @pyqtSlot()
  603. def slot_toolbarShown(self):
  604. self.updateInfoLabelPos()
  605. @pyqtSlot()
  606. def slot_splitterMoved(self):
  607. self.updateInfoLabelSize()
  608. @pyqtSlot()
  609. def slot_canvasArrange(self):
  610. patchcanvas.arrange()
  611. @pyqtSlot()
  612. def slot_canvasRefresh(self):
  613. patchcanvas.clear()
  614. Carla.host.patchbay_refresh()
  615. @pyqtSlot()
  616. def slot_canvasZoomFit(self):
  617. self.scene.zoom_fit()
  618. @pyqtSlot()
  619. def slot_canvasZoomIn(self):
  620. self.scene.zoom_in()
  621. @pyqtSlot()
  622. def slot_canvasZoomOut(self):
  623. self.scene.zoom_out()
  624. @pyqtSlot()
  625. def slot_canvasZoomReset(self):
  626. self.scene.zoom_reset()
  627. @pyqtSlot()
  628. def slot_canvasPrint(self):
  629. self.scene.clearSelection()
  630. self.fExportPrinter = QPrinter()
  631. dialog = QPrintDialog(self.fExportPrinter, self)
  632. if dialog.exec_():
  633. painter = QPainter(self.fExportPrinter)
  634. painter.setRenderHint(QPainter.Antialiasing)
  635. painter.setRenderHint(QPainter.TextAntialiasing)
  636. self.scene.render(painter)
  637. @pyqtSlot()
  638. def slot_canvasSaveImage(self):
  639. newPath = QFileDialog.getSaveFileName(self, self.tr("Save Image"), filter=self.tr("PNG Image (*.png);;JPEG Image (*.jpg)"))
  640. if newPath:
  641. self.scene.clearSelection()
  642. # FIXME - must be a better way...
  643. if newPath.endswith((".jpg", ".jpG", ".jPG", ".JPG", ".JPg", ".Jpg")):
  644. imgFormat = "JPG"
  645. elif newPath.endswith((".png", ".pnG", ".pNG", ".PNG", ".PNg", ".Png")):
  646. imgFormat = "PNG"
  647. else:
  648. # File-dialog may not auto-add the extension
  649. imgFormat = "PNG"
  650. newPath += ".png"
  651. self.fExportImage = QImage(self.scene.sceneRect().width(), self.scene.sceneRect().height(), QImage.Format_RGB32)
  652. painter = QPainter(self.fExportImage)
  653. painter.setRenderHint(QPainter.Antialiasing) # TODO - set true, cleanup this
  654. painter.setRenderHint(QPainter.TextAntialiasing)
  655. self.scene.render(painter)
  656. self.fExportImage.save(newPath, imgFormat, 100)
  657. def showLastError(self, isProject):
  658. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"),
  659. self.tr("Failed to load %s" % (self.tr("project") if isProject else self.tr("plugin"))),
  660. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  661. @pyqtSlot(QModelIndex)
  662. def slot_fileTreeDoubleClicked(self, modelIndex):
  663. filename = self.fDirModel.filePath(modelIndex)
  664. print(filename)
  665. if not os.path.exists(filename):
  666. return
  667. if not os.path.isfile(filename):
  668. return
  669. basename = os.path.basename(filename)
  670. extension = filename.rsplit(".", 1)[-1].lower()
  671. if extension == "carxp":
  672. if not Carla.host.load_project(filename):
  673. self.showLastError(True)
  674. elif extension == "gig":
  675. if not Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_GIG, filename, None, basename, None):
  676. self.showLastError(False)
  677. elif extension == "sf2":
  678. if not Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_SF2, filename, None, basename, None):
  679. self.showLastError(False)
  680. elif extension == "sfz":
  681. if not Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_SFZ, filename, None, basename, None):
  682. self.showLastError(False)
  683. elif extension in ("aac", "flac", "oga", "ogg", "mp3", "wav"):
  684. # check if last plugin is audiofile
  685. if self.fPluginCount > 0:
  686. pluginId = self.fPluginCount-1
  687. pwidget = self.fPluginList[pluginId]
  688. if pwidget is not None and pwidget.fPluginInfo["label"] == "audiofile":
  689. Carla.host.set_custom_data(pluginId, CUSTOM_DATA_STRING, "file00", filename)
  690. return
  691. self.fLastLoadedPluginId = -2
  692. if Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, None, None, "audiofile", None):
  693. while (self.fLastLoadedPluginId == -2): sleep(0.2)
  694. idx = self.fLastLoadedPluginId
  695. self.fLastLoadedPluginId = -1
  696. Carla.host.set_custom_data(idx, CUSTOM_DATA_STRING, "file00", filename)
  697. else:
  698. self.fLastLoadedPluginId = -1
  699. self.showLastError(False)
  700. elif extension in ("mid", "midi"):
  701. # check if last plugin is midifile
  702. if self.fPluginCount > 0:
  703. pluginId = self.fPluginCount-1
  704. pwidget = self.fPluginList[pluginId]
  705. if pwidget is not None and pwidget.fPluginInfo["label"] == "midifile":
  706. Carla.host.set_custom_data(pluginId, CUSTOM_DATA_STRING, "file", filename)
  707. return
  708. self.fLastLoadedPluginId = -2
  709. if Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, None, None, "midifile", None):
  710. while (self.fLastLoadedPluginId == -2): sleep(0.2)
  711. idx = self.fLastLoadedPluginId
  712. self.fLastLoadedPluginId = -1
  713. Carla.host.set_custom_data(idx, CUSTOM_DATA_STRING, "file", filename)
  714. else:
  715. self.fLastLoadedPluginId = -1
  716. self.showLastError(False)
  717. @pyqtSlot(float)
  718. def slot_canvasScaleChanged(self, scale):
  719. self.ui.miniCanvasPreview.setViewScale(scale)
  720. @pyqtSlot(int, int, QPointF)
  721. def slot_canvasItemMoved(self, group_id, split_mode, pos):
  722. self.ui.miniCanvasPreview.update()
  723. @pyqtSlot(int)
  724. def slot_horizontalScrollBarChanged(self, value):
  725. maximum = self.ui.graphicsView.horizontalScrollBar().maximum()
  726. if maximum == 0:
  727. xp = 0
  728. else:
  729. xp = float(value) / maximum
  730. self.ui.miniCanvasPreview.setViewPosX(xp)
  731. @pyqtSlot(int)
  732. def slot_verticalScrollBarChanged(self, value):
  733. maximum = self.ui.graphicsView.verticalScrollBar().maximum()
  734. if maximum == 0:
  735. yp = 0
  736. else:
  737. yp = float(value) / maximum
  738. self.ui.miniCanvasPreview.setViewPosY(yp)
  739. @pyqtSlot()
  740. def slot_miniCanvasInit(self):
  741. settings = QSettings()
  742. self.ui.graphicsView.horizontalScrollBar().setValue(settings.value("HorizontalScrollBarValue", DEFAULT_CANVAS_WIDTH / 3, type=int))
  743. self.ui.graphicsView.verticalScrollBar().setValue(settings.value("VerticalScrollBarValue", DEFAULT_CANVAS_HEIGHT * 3 / 8, type=int))
  744. tabBar = self.ui.tabMain.tabBar()
  745. x = tabBar.width()+20
  746. y = tabBar.mapFromParent(self.ui.centralwidget.pos()).y()+tabBar.height()/4
  747. self.fInfoLabel.move(x, y)
  748. self.fInfoLabel.resize(self.ui.tabMain.width()-x, tabBar.height())
  749. @pyqtSlot(float, float)
  750. def slot_miniCanvasMoved(self, xp, yp):
  751. self.ui.graphicsView.horizontalScrollBar().setValue(xp * DEFAULT_CANVAS_WIDTH)
  752. self.ui.graphicsView.verticalScrollBar().setValue(yp * DEFAULT_CANVAS_HEIGHT)
  753. @pyqtSlot()
  754. def slot_miniCanvasCheckAll(self):
  755. self.slot_miniCanvasCheckSize()
  756. self.slot_horizontalScrollBarChanged(self.ui.graphicsView.horizontalScrollBar().value())
  757. self.slot_verticalScrollBarChanged(self.ui.graphicsView.verticalScrollBar().value())
  758. @pyqtSlot()
  759. def slot_miniCanvasCheckSize(self):
  760. self.ui.miniCanvasPreview.setViewSize(float(self.ui.graphicsView.width()) / DEFAULT_CANVAS_WIDTH, float(self.ui.graphicsView.height()) / DEFAULT_CANVAS_HEIGHT)
  761. def startEngine(self, clientName = "Carla"):
  762. # ---------------------------------------------
  763. # Engine settings
  764. settings = QSettings()
  765. if LINUX:
  766. defaultMode = PROCESS_MODE_MULTIPLE_CLIENTS
  767. else:
  768. defaultMode = PROCESS_MODE_CONTINUOUS_RACK
  769. Carla.processMode = settings.value("Engine/ProcessMode", defaultMode, type=int)
  770. Carla.maxParameters = settings.value("Engine/MaxParameters", MAX_DEFAULT_PARAMETERS, type=int)
  771. transportMode = settings.value("Engine/TransportMode", TRANSPORT_MODE_JACK, type=int)
  772. forceStereo = settings.value("Engine/ForceStereo", False, type=bool)
  773. preferPluginBridges = settings.value("Engine/PreferPluginBridges", False, type=bool)
  774. preferUiBridges = settings.value("Engine/PreferUiBridges", True, type=bool)
  775. useDssiVstChunks = settings.value("Engine/UseDssiVstChunks", False, type=bool)
  776. oscUiTimeout = settings.value("Engine/OscUiTimeout", 40, type=int)
  777. preferredBufferSize = settings.value("Engine/PreferredBufferSize", 512, type=int)
  778. preferredSampleRate = settings.value("Engine/PreferredSampleRate", 44100, type=int)
  779. if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK:
  780. forceStereo = True
  781. elif Carla.processMode == PROCESS_MODE_MULTIPLE_CLIENTS and os.getenv("LADISH_APP_NAME"):
  782. print("LADISH detected but using multiple clients (not allowed), forcing single client now")
  783. Carla.processMode = PROCESS_MODE_SINGLE_CLIENT
  784. Carla.host.set_engine_option(OPTION_PROCESS_MODE, Carla.processMode, "")
  785. Carla.host.set_engine_option(OPTION_MAX_PARAMETERS, Carla.maxParameters, "")
  786. Carla.host.set_engine_option(OPTION_FORCE_STEREO, forceStereo, "")
  787. Carla.host.set_engine_option(OPTION_PREFER_PLUGIN_BRIDGES, preferPluginBridges, "")
  788. Carla.host.set_engine_option(OPTION_PREFER_UI_BRIDGES, preferUiBridges, "")
  789. Carla.host.set_engine_option(OPTION_USE_DSSI_VST_CHUNKS, useDssiVstChunks, "")
  790. Carla.host.set_engine_option(OPTION_OSC_UI_TIMEOUT, oscUiTimeout, "")
  791. Carla.host.set_engine_option(OPTION_PREFERRED_BUFFER_SIZE, preferredBufferSize, "")
  792. Carla.host.set_engine_option(OPTION_PREFERRED_SAMPLE_RATE, preferredSampleRate, "")
  793. # ---------------------------------------------
  794. # Start
  795. if WINDOWS:
  796. defaultDriver = "DirectSound"
  797. elif MACOS:
  798. defaultDriver = "CoreAudio"
  799. else:
  800. defaultDriver = "JACK"
  801. audioDriver = settings.value("Engine/AudioDriver", defaultDriver, type=str)
  802. if not Carla.host.engine_init(audioDriver, clientName):
  803. if self.fFirstEngineInit:
  804. self.fFirstEngineInit = False
  805. return
  806. audioError = cString(Carla.host.get_last_error())
  807. if audioError:
  808. QMessageBox.critical(self, self.tr("Error"), self.tr("Could not connect to Audio backend '%s', possible reasons:\n%s" % (audioDriver, audioError)))
  809. else:
  810. QMessageBox.critical(self, self.tr("Error"), self.tr("Could not connect to Audio backend '%s'" % audioDriver))
  811. return
  812. self.fBufferSize = Carla.host.get_buffer_size()
  813. self.fSampleRate = Carla.host.get_sample_rate()
  814. self.fEngineStarted = True
  815. self.fFirstEngineInit = False
  816. self.fPluginCount = 0
  817. self.fPluginList = []
  818. if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK:
  819. maxCount = MAX_RACK_PLUGINS
  820. elif Carla.processMode == PROCESS_MODE_PATCHBAY:
  821. maxCount = MAX_PATCHBAY_PLUGINS
  822. else:
  823. maxCount = MAX_DEFAULT_PLUGINS
  824. if transportMode == TRANSPORT_MODE_JACK and audioDriver != "JACK":
  825. transportMode = TRANSPORT_MODE_INTERNAL
  826. for x in range(maxCount):
  827. self.fPluginList.append(None)
  828. Carla.host.set_engine_option(OPTION_TRANSPORT_MODE, transportMode, "")
  829. # Peaks and TimeInfo
  830. self.fIdleTimerFast = self.startTimer(self.fSavedSettings["Main/RefreshInterval"])
  831. # LEDs and edit dialog parameters
  832. self.fIdleTimerSlow = self.startTimer(self.fSavedSettings["Main/RefreshInterval"]*2)
  833. def stopEngine(self):
  834. if self.fPluginCount > 0:
  835. 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"
  836. "Do you want to do this now?"),
  837. QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
  838. if ask != QMessageBox.Yes:
  839. return
  840. self.removeAllPlugins()
  841. if Carla.host.is_engine_running() and not Carla.host.engine_close():
  842. print(cString(Carla.host.get_last_error()))
  843. return
  844. self.fBufferSize = 0
  845. self.fSampleRate = 0.0
  846. self.fEngineStarted = False
  847. self.fPluginCount = 0
  848. self.fPluginList = []
  849. self.killTimer(self.fIdleTimerFast)
  850. self.killTimer(self.fIdleTimerSlow)
  851. patchcanvas.clear()
  852. def setProperWindowTitle(self):
  853. title = "%s" % os.getenv("LADISH_APP_NAME", "Carla")
  854. if self.fProjectFilename:
  855. title += " - %s" % os.path.basename(self.fProjectFilename)
  856. if self.fSessionManagerName:
  857. title += " (%s)" % self.fSessionManagerName
  858. self.setWindowTitle(title)
  859. def loadProject(self, filename):
  860. self.fProjectFilename = filename
  861. self.setProperWindowTitle()
  862. self.fProjectLoading = True
  863. Carla.host.load_project(filename)
  864. self.fProjectLoading = False
  865. def loadProjectLater(self, filename):
  866. self.fProjectFilename = filename
  867. self.setProperWindowTitle()
  868. QTimer.singleShot(0, self, SLOT("slot_loadProjectLater()"))
  869. def saveProject(self, filename):
  870. self.fProjectFilename = filename
  871. self.setProperWindowTitle()
  872. Carla.host.save_project(filename)
  873. def addPlugin(self, btype, ptype, filename, name, label, extraStuff):
  874. if not self.fEngineStarted:
  875. QMessageBox.warning(self, self.tr("Warning"), self.tr("Cannot add new plugins while engine is stopped"))
  876. return False
  877. if not Carla.host.add_plugin(btype, ptype, filename, name, label, extraStuff):
  878. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  879. return False
  880. return True
  881. def removeAllPlugins(self):
  882. while (self.ui.w_plugins.layout().takeAt(0)):
  883. pass
  884. self.ui.act_plugin_remove_all.setEnabled(False)
  885. for i in range(self.fPluginCount):
  886. pwidget = self.fPluginList[i]
  887. if pwidget is None:
  888. break
  889. self.fPluginList[i] = None
  890. pwidget.ui.edit_dialog.close()
  891. pwidget.close()
  892. pwidget.deleteLater()
  893. del pwidget
  894. self.fPluginCount = 0
  895. Carla.host.remove_all_plugins()
  896. @pyqtSlot()
  897. def slot_fileNew(self):
  898. self.removeAllPlugins()
  899. self.fProjectFilename = None
  900. self.fProjectLoading = False
  901. self.setProperWindowTitle()
  902. @pyqtSlot()
  903. def slot_fileOpen(self):
  904. fileFilter = self.tr("Carla Project File (*.carxp)")
  905. filenameTry = QFileDialog.getOpenFileName(self, self.tr("Open Carla Project File"), self.fSavedSettings["Main/DefaultProjectFolder"], filter=fileFilter)
  906. if filenameTry:
  907. # FIXME - show dialog to user
  908. self.removeAllPlugins()
  909. self.loadProject(filenameTry)
  910. @pyqtSlot()
  911. def slot_fileSave(self, saveAs=False):
  912. if self.fProjectFilename and not saveAs:
  913. return self.saveProject(self.fProjectFilename)
  914. fileFilter = self.tr("Carla Project File (*.carxp)")
  915. filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Carla Project File"), self.fSavedSettings["Main/DefaultProjectFolder"], filter=fileFilter)
  916. if filenameTry:
  917. if not filenameTry.endswith(".carxp"):
  918. filenameTry += ".carxp"
  919. self.saveProject(filenameTry)
  920. @pyqtSlot()
  921. def slot_fileSaveAs(self):
  922. self.slot_fileSave(True)
  923. @pyqtSlot()
  924. def slot_loadProjectLater(self):
  925. self.fProjectLoading = True
  926. Carla.host.load_project(self.fProjectFilename)
  927. self.fProjectLoading = False
  928. @pyqtSlot()
  929. def slot_engineStart(self):
  930. self.startEngine()
  931. check = Carla.host.is_engine_running()
  932. self.ui.act_file_open.setEnabled(check)
  933. self.ui.act_engine_start.setEnabled(not check)
  934. self.ui.act_engine_stop.setEnabled(check)
  935. self.ui.act_engine_configure.setEnabled(not check)
  936. if check:
  937. self.fInfoText = "Engine running | SampleRate: %g | BufferSize: %i" % (self.fSampleRate, self.fBufferSize)
  938. self.refreshTransport(True)
  939. self.menuTransport(check)
  940. @pyqtSlot()
  941. def slot_engineStop(self):
  942. self.stopEngine()
  943. check = Carla.host.is_engine_running()
  944. self.ui.act_file_open.setEnabled(check)
  945. self.ui.act_engine_start.setEnabled(not check)
  946. self.ui.act_engine_stop.setEnabled(check)
  947. if not check:
  948. self.fInfoText = ""
  949. self.fInfoLabel.setText("Engine stopped")
  950. self.menuTransport(check)
  951. @pyqtSlot()
  952. def slot_pluginAdd(self):
  953. dialog = PluginDatabaseW(self)
  954. if dialog.exec_():
  955. btype = dialog.fRetPlugin['build']
  956. ptype = dialog.fRetPlugin['type']
  957. filename = dialog.fRetPlugin['binary']
  958. label = dialog.fRetPlugin['label']
  959. extraStuff = self.getExtraStuff(dialog.fRetPlugin)
  960. self.addPlugin(btype, ptype, filename, None, label, extraStuff)
  961. @pyqtSlot()
  962. def slot_pluginRemoveAll(self):
  963. self.removeAllPlugins()
  964. def menuTransport(self, enabled):
  965. self.ui.act_transport_play.setEnabled(enabled)
  966. self.ui.act_transport_stop.setEnabled(enabled)
  967. self.ui.act_transport_backwards.setEnabled(enabled)
  968. self.ui.act_transport_forwards.setEnabled(enabled)
  969. self.ui.menu_Transport.setEnabled(enabled)
  970. def refreshTransport(self, forced = False):
  971. if not self.fEngineStarted:
  972. return
  973. if self.fSampleRate == 0.0:
  974. return
  975. timeInfo = Carla.host.get_transport_info()
  976. playing = timeInfo['playing']
  977. time = timeInfo['frame'] / self.fSampleRate
  978. secs = time % 60
  979. mins = (time / 60) % 60
  980. hrs = (time / 3600) % 60
  981. textTransport = "Transport %s, at %02i:%02i:%02i" % ("playing" if playing else "stopped", hrs, mins, secs)
  982. self.fInfoLabel.setText("%s | %s" % (self.fInfoText, textTransport))
  983. if playing != self.fTransportWasPlaying or forced:
  984. self.fTransportWasPlaying = playing
  985. if playing:
  986. icon = getIcon("media-playback-pause")
  987. self.ui.act_transport_play.setChecked(True)
  988. self.ui.act_transport_play.setIcon(icon)
  989. self.ui.act_transport_play.setText(self.tr("&Pause"))
  990. else:
  991. icon = getIcon("media-playback-start")
  992. self.ui.act_transport_play.setChecked(False)
  993. self.ui.act_transport_play.setIcon(icon)
  994. self.ui.act_transport_play.setText(self.tr("&Play"))
  995. @pyqtSlot(bool)
  996. def slot_transportPlayPause(self, toggled):
  997. if not self.fEngineStarted:
  998. return
  999. if toggled:
  1000. Carla.host.transport_play()
  1001. else:
  1002. Carla.host.transport_pause()
  1003. self.refreshTransport()
  1004. @pyqtSlot()
  1005. def slot_transportStop(self):
  1006. if not self.fEngineStarted:
  1007. return
  1008. Carla.host.transport_pause()
  1009. Carla.host.transport_relocate(0)
  1010. self.refreshTransport()
  1011. @pyqtSlot()
  1012. def slot_transportBackwards(self):
  1013. if not self.fEngineStarted:
  1014. return
  1015. newFrame = Carla.host.get_current_transport_frame() - 100000
  1016. if newFrame < 0:
  1017. newFrame = 0
  1018. Carla.host.transport_relocate(newFrame)
  1019. @pyqtSlot()
  1020. def slot_transportForwards(self):
  1021. if not self.fEngineStarted:
  1022. return
  1023. newFrame = Carla.host.get_current_transport_frame() + 100000
  1024. Carla.host.transport_relocate(newFrame)
  1025. @pyqtSlot()
  1026. def slot_aboutCarla(self):
  1027. CarlaAboutW(self).exec_()
  1028. @pyqtSlot()
  1029. def slot_configureCarla(self):
  1030. dialog = CarlaSettingsW(self)
  1031. if dialog.exec_():
  1032. self.loadSettings(False)
  1033. patchcanvas.clear()
  1034. pOptions = patchcanvas.options_t()
  1035. pOptions.theme_name = self.fSavedSettings["Canvas/Theme"]
  1036. pOptions.auto_hide_groups = self.fSavedSettings["Canvas/AutoHideGroups"]
  1037. pOptions.use_bezier_lines = self.fSavedSettings["Canvas/UseBezierLines"]
  1038. pOptions.antialiasing = self.fSavedSettings["Canvas/Antialiasing"]
  1039. pOptions.eyecandy = self.fSavedSettings["Canvas/EyeCandy"]
  1040. pFeatures = patchcanvas.features_t()
  1041. pFeatures.group_info = False
  1042. pFeatures.group_rename = False
  1043. pFeatures.port_info = False
  1044. pFeatures.port_rename = False
  1045. pFeatures.handle_group_pos = True
  1046. patchcanvas.setOptions(pOptions)
  1047. patchcanvas.setFeatures(pFeatures)
  1048. patchcanvas.init("Carla", self.scene, canvasCallback, False)
  1049. if self.fEngineStarted:
  1050. Carla.host.patchbay_refresh()
  1051. for pwidget in self.fPluginList:
  1052. if pwidget is None:
  1053. return
  1054. pwidget.setRefreshRate(self.fSavedSettings["Main/RefreshInterval"])
  1055. @pyqtSlot()
  1056. def slot_handleSIGUSR1(self):
  1057. print("Got SIGUSR1 -> Saving project now")
  1058. QTimer.singleShot(0, self, SLOT("slot_fileSave()"))
  1059. @pyqtSlot()
  1060. def slot_handleSIGTERM(self):
  1061. print("Got SIGTERM -> Closing now")
  1062. self.close()
  1063. @pyqtSlot(int, int, int, float, str)
  1064. def slot_handleDebugCallback(self, pluginId, value1, value2, value3, valueStr):
  1065. print("DEBUG :: %i, %i, %i, %f, \"%s\")" % (pluginId, value1, value2, value3, valueStr))
  1066. @pyqtSlot(int)
  1067. def slot_handlePluginAddedCallback(self, pluginId):
  1068. pwidget = PluginWidget(self, pluginId)
  1069. pwidget.setRefreshRate(self.fSavedSettings["Main/RefreshInterval"])
  1070. self.ui.w_plugins.layout().addWidget(pwidget)
  1071. self.fPluginCount += 1
  1072. self.fPluginList[pluginId] = pwidget
  1073. if not self.fProjectLoading:
  1074. pwidget.setActive(True, True, True)
  1075. if self.fPluginCount == 1:
  1076. self.ui.act_plugin_remove_all.setEnabled(True)
  1077. if self.fLastLoadedPluginId == -2:
  1078. self.fLastLoadedPluginId = pluginId
  1079. @pyqtSlot(int)
  1080. def slot_handlePluginRemovedCallback(self, pluginId):
  1081. if pluginId >= self.fPluginCount:
  1082. return
  1083. pwidget = self.fPluginList[pluginId]
  1084. if pwidget is None:
  1085. return
  1086. self.fPluginList[pluginId] = None
  1087. self.fPluginCount -= 1
  1088. self.ui.w_plugins.layout().removeWidget(pwidget)
  1089. pwidget.ui.edit_dialog.close()
  1090. pwidget.close()
  1091. pwidget.deleteLater()
  1092. del pwidget
  1093. # push all plugins 1 slot back
  1094. for i in range(pluginId, self.fPluginCount):
  1095. self.fPluginList[i] = self.fPluginList[i+1]
  1096. self.fPluginList[i].setId(i)
  1097. if self.fPluginCount == 0:
  1098. self.ui.act_plugin_remove_all.setEnabled(False)
  1099. @pyqtSlot(int, str)
  1100. def slot_handlePluginRenamedCallback(self, pluginId, newName):
  1101. if pluginId >= self.fPluginCount:
  1102. return
  1103. pwidget = self.fPluginList[pluginId]
  1104. if pwidget is None:
  1105. return
  1106. pwidget.ui.label_name.setText(newName)
  1107. @pyqtSlot(int, int, float)
  1108. def slot_handleParameterValueChangedCallback(self, pluginId, parameterId, value):
  1109. if pluginId >= self.fPluginCount:
  1110. return
  1111. pwidget = self.fPluginList[pluginId]
  1112. if pwidget is None:
  1113. return
  1114. pwidget.setParameterValue(parameterId, value)
  1115. @pyqtSlot(int, int, float)
  1116. def slot_handleParameterDefaultChangedCallback(self, pluginId, parameterId, value):
  1117. if pluginId >= self.fPluginCount:
  1118. return
  1119. pwidget = self.fPluginList[pluginId]
  1120. if pwidget is None:
  1121. return
  1122. pwidget.setParameterDefault(parameterId, value)
  1123. @pyqtSlot(int, int, int)
  1124. def slot_handleParameterMidiChannelChangedCallback(self, pluginId, parameterId, channel):
  1125. if pluginId >= self.fPluginCount:
  1126. return
  1127. pwidget = self.fPluginList[pluginId]
  1128. if pwidget is None:
  1129. return
  1130. pwidget.setParameterMidiChannel(parameterId, channel)
  1131. @pyqtSlot(int, int, int)
  1132. def slot_handleParameterMidiCcChangedCallback(self, pluginId, parameterId, cc):
  1133. if pluginId >= self.fPluginCount:
  1134. return
  1135. pwidget = self.fPluginList[pluginId]
  1136. if pwidget is None:
  1137. return
  1138. pwidget.setParameterMidiControl(parameterId, cc)
  1139. @pyqtSlot(int, int)
  1140. def slot_handleProgramChangedCallback(self, pluginId, programId):
  1141. if pluginId >= self.fPluginCount:
  1142. return
  1143. pwidget = self.fPluginList[pluginId]
  1144. if pwidget is None:
  1145. return
  1146. pwidget.setProgram(programId)
  1147. @pyqtSlot(int, int)
  1148. def slot_handleMidiProgramChangedCallback(self, pluginId, midiProgramId):
  1149. if pluginId >= self.fPluginCount:
  1150. return
  1151. pwidget = self.fPluginList[pluginId]
  1152. if pwidget is None:
  1153. return
  1154. pwidget.setMidiProgram(midiProgramId)
  1155. @pyqtSlot(int, int, int, int)
  1156. def slot_handleNoteOnCallback(self, pluginId, channel, note, velo):
  1157. if pluginId >= self.fPluginCount:
  1158. return
  1159. pwidget = self.fPluginList[pluginId]
  1160. if pwidget is None:
  1161. return
  1162. pwidget.sendNoteOn(channel, note)
  1163. @pyqtSlot(int, int, int)
  1164. def slot_handleNoteOffCallback(self, pluginId, channel, note):
  1165. if pluginId >= self.fPluginCount:
  1166. return
  1167. pwidget = self.fPluginList[pluginId]
  1168. if pwidget is None:
  1169. return
  1170. pwidget.sendNoteOff(channel, note)
  1171. @pyqtSlot(int, int)
  1172. def slot_handleShowGuiCallback(self, pluginId, show):
  1173. if pluginId >= self.fPluginCount:
  1174. return
  1175. pwidget = self.fPluginList[pluginId]
  1176. if pwidget is None:
  1177. return
  1178. if show == 0:
  1179. pwidget.ui.b_gui.setChecked(False)
  1180. pwidget.ui.b_gui.setEnabled(True)
  1181. elif show == 1:
  1182. pwidget.ui.b_gui.setChecked(True)
  1183. pwidget.ui.b_gui.setEnabled(True)
  1184. elif show == -1:
  1185. pwidget.ui.b_gui.setChecked(False)
  1186. pwidget.ui.b_gui.setEnabled(False)
  1187. @pyqtSlot(int)
  1188. def slot_handleUpdateCallback(self, pluginId):
  1189. if pluginId >= self.fPluginCount:
  1190. return
  1191. pwidget = self.fPluginList[pluginId]
  1192. if pwidget is None:
  1193. return
  1194. pwidget.ui.edit_dialog.updateInfo()
  1195. @pyqtSlot(int)
  1196. def slot_handleReloadInfoCallback(self, pluginId):
  1197. if pluginId >= self.fPluginCount:
  1198. return
  1199. pwidget = self.fPluginList[pluginId]
  1200. if pwidget is None:
  1201. return
  1202. pwidget.ui.edit_dialog.reloadInfo()
  1203. @pyqtSlot(int)
  1204. def slot_handleReloadParametersCallback(self, pluginId):
  1205. if pluginId >= self.fPluginCount:
  1206. return
  1207. pwidget = self.fPluginList[pluginId]
  1208. if pwidget is None:
  1209. return
  1210. pwidget.ui.edit_dialog.reloadParameters()
  1211. @pyqtSlot(int)
  1212. def slot_handleReloadProgramsCallback(self, pluginId):
  1213. if pluginId >= self.fPluginCount:
  1214. return
  1215. pwidget = self.fPluginList[pluginId]
  1216. if pwidget is None:
  1217. return
  1218. pwidget.ui.edit_dialog.reloadPrograms()
  1219. @pyqtSlot(int)
  1220. def slot_handleReloadAllCallback(self, pluginId):
  1221. if pluginId >= self.fPluginCount:
  1222. return
  1223. pwidget = self.fPluginList[pluginId]
  1224. if pwidget is None:
  1225. return
  1226. pwidget.ui.edit_dialog.reloadAll()
  1227. @pyqtSlot(int, str)
  1228. def slot_handlePatchbayClientAddedCallback(self, clientId, clientName):
  1229. patchcanvas.addGroup(clientId, clientName)
  1230. @pyqtSlot(int)
  1231. def slot_handlePatchbayClientRemovedCallback(self, clientId):
  1232. patchcanvas.removeGroup(clientId)
  1233. @pyqtSlot(int, str)
  1234. def slot_handlePatchbayClientRenamedCallback(self, clientId, newClientName):
  1235. patchcanvas.renameGroup(clientId, newClientName)
  1236. @pyqtSlot(int, int, int, str)
  1237. def slot_handlePatchbayPortAddedCallback(self, clientId, portId, portFlags, portName):
  1238. if (portFlags & PATCHBAY_PORT_IS_INPUT):
  1239. portMode = patchcanvas.PORT_MODE_INPUT
  1240. elif (portFlags & PATCHBAY_PORT_IS_OUTPUT):
  1241. portMode = patchcanvas.PORT_MODE_OUTPUT
  1242. else:
  1243. portMode = patchcanvas.PORT_MODE_NULL
  1244. if (portFlags & PATCHBAY_PORT_IS_AUDIO):
  1245. portType = patchcanvas.PORT_TYPE_AUDIO_JACK
  1246. elif (portFlags & PATCHBAY_PORT_IS_MIDI):
  1247. portType = patchcanvas.PORT_TYPE_MIDI_JACK
  1248. else:
  1249. portType = patchcanvas.PORT_TYPE_NULL
  1250. patchcanvas.addPort(clientId, portId, portName, portMode, portType)
  1251. @pyqtSlot(int)
  1252. def slot_handlePatchbayPortRemovedCallback(self, portId):
  1253. patchcanvas.removePort(portId)
  1254. @pyqtSlot(int, str)
  1255. def slot_handlePatchbayPortRenamedCallback(self, portId, newPortName):
  1256. patchcanvas.renamePort(portId, newPortName)
  1257. @pyqtSlot(int, int, int)
  1258. def slot_handlePatchbayConnectionAddedCallback(self, connectionId, portOutId, portInId):
  1259. patchcanvas.connectPorts(connectionId, portOutId, portInId)
  1260. @pyqtSlot(int)
  1261. def slot_handlePatchbayConnectionRemovedCallback(self, connectionId):
  1262. patchcanvas.disconnectPorts(connectionId)
  1263. @pyqtSlot(int)
  1264. def slot_handleBufferSizeChangedCallback(self, newBufferSize):
  1265. self.fBufferSize = newBufferSize
  1266. self.fInfoText = "Engine running | SampleRate: %g | BufferSize: %i" % (self.fSampleRate, self.fBufferSize)
  1267. @pyqtSlot(float)
  1268. def slot_handleSampleRateChangedCallback(self, newSampleRate):
  1269. self.fSampleRate = newSampleRate
  1270. self.fInfoText = "Engine running | SampleRate: %g | BufferSize: %i" % (self.fSampleRate, self.fBufferSize)
  1271. @pyqtSlot(str)
  1272. def slot_handleErrorCallback(self, error):
  1273. QMessageBox.critical(self, self.tr("Error"), error)
  1274. @pyqtSlot()
  1275. def slot_handleQuitCallback(self):
  1276. CustomMessageBox(self, QMessageBox.Warning, self.tr("Warning"),
  1277. self.tr("Engine has been stopped or crashed.\nPlease restart Carla"),
  1278. self.tr("You may want to save your session now..."), QMessageBox.Ok, QMessageBox.Ok)
  1279. def getExtraStuff(self, plugin):
  1280. ptype = plugin['type']
  1281. if ptype == PLUGIN_LADSPA:
  1282. uniqueId = plugin['uniqueId']
  1283. for rdfItem in self.fLadspaRdfList:
  1284. if rdfItem.UniqueID == uniqueId:
  1285. return pointer(rdfItem)
  1286. elif ptype == PLUGIN_DSSI:
  1287. if (plugin['hints'] & PLUGIN_HAS_GUI):
  1288. gui = findDSSIGUI(plugin['binary'], plugin['name'], plugin['label'])
  1289. if gui:
  1290. return gui.encode("utf-8")
  1291. elif ptype == PLUGIN_SF2:
  1292. if plugin['name'].endswith(" (16 outputs)"):
  1293. # return a dummy non-null pointer
  1294. INTPOINTER = POINTER(c_int)
  1295. ptr = c_int(0x1)
  1296. addr = addressof(ptr)
  1297. return cast(addr, INTPOINTER)
  1298. return c_nullptr
  1299. def loadRDFs(self):
  1300. # Save RDF info for later
  1301. self.fLadspaRdfList = []
  1302. if not haveLRDF:
  1303. return
  1304. settingsDir = os.path.join(HOME, ".config", "falkTX")
  1305. frLadspaFile = os.path.join(settingsDir, "ladspa_rdf.db")
  1306. if os.path.exists(frLadspaFile):
  1307. frLadspa = open(frLadspaFile, 'r')
  1308. try:
  1309. self.fLadspaRdfList = ladspa_rdf.get_c_ladspa_rdfs(json.load(frLadspa))
  1310. except:
  1311. pass
  1312. frLadspa.close()
  1313. def saveSettings(self):
  1314. settings = QSettings()
  1315. settings.setValue("Geometry", self.saveGeometry())
  1316. settings.setValue("SplitterState", self.ui.splitter.saveState())
  1317. settings.setValue("ShowToolbar", self.ui.toolBar.isVisible())
  1318. settings.setValue("HorizontalScrollBarValue", self.ui.graphicsView.horizontalScrollBar().value())
  1319. settings.setValue("VerticalScrollBarValue", self.ui.graphicsView.verticalScrollBar().value())
  1320. def loadSettings(self, geometry):
  1321. settings = QSettings()
  1322. if geometry:
  1323. self.restoreGeometry(settings.value("Geometry", ""))
  1324. showToolbar = settings.value("ShowToolbar", True, type=bool)
  1325. self.ui.act_settings_show_toolbar.setChecked(showToolbar)
  1326. self.ui.toolBar.setVisible(showToolbar)
  1327. if settings.contains("SplitterState"):
  1328. self.ui.splitter.restoreState(settings.value("SplitterState", ""))
  1329. else:
  1330. self.ui.splitter.setSizes([99999, 210])
  1331. self.fSavedSettings = {
  1332. "Main/DefaultProjectFolder": settings.value("Main/DefaultProjectFolder", HOME, type=str),
  1333. "Main/RefreshInterval": settings.value("Main/RefreshInterval", 50, type=int),
  1334. "Canvas/Theme": settings.value("Canvas/Theme", patchcanvas.getDefaultThemeName(), type=str),
  1335. "Canvas/AutoHideGroups": settings.value("Canvas/AutoHideGroups", False, type=bool),
  1336. "Canvas/UseBezierLines": settings.value("Canvas/UseBezierLines", True, type=bool),
  1337. "Canvas/EyeCandy": settings.value("Canvas/EyeCandy", patchcanvas.EYECANDY_SMALL, type=int),
  1338. "Canvas/UseOpenGL": settings.value("Canvas/UseOpenGL", False, type=bool),
  1339. "Canvas/Antialiasing": settings.value("Canvas/Antialiasing", patchcanvas.ANTIALIASING_SMALL, type=int),
  1340. "Canvas/HighQualityAntialiasing": settings.value("Canvas/HighQualityAntialiasing", False, type=bool)
  1341. }
  1342. # ---------------------------------------------
  1343. # plugin checks
  1344. if settings.value("Engine/DisableChecks", False, type=bool):
  1345. os.environ["CARLA_DISCOVERY_NO_PROCESSING_CHECKS"] = "true"
  1346. elif os.getenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS"):
  1347. os.environ.pop("CARLA_DISCOVERY_NO_PROCESSING_CHECKS")
  1348. # ---------------------------------------------
  1349. # plugin paths
  1350. Carla.LADSPA_PATH = toList(settings.value("Paths/LADSPA", Carla.LADSPA_PATH))
  1351. Carla.DSSI_PATH = toList(settings.value("Paths/DSSI", Carla.DSSI_PATH))
  1352. Carla.LV2_PATH = toList(settings.value("Paths/LV2", Carla.LV2_PATH))
  1353. Carla.VST_PATH = toList(settings.value("Paths/VST", Carla.VST_PATH))
  1354. Carla.GIG_PATH = toList(settings.value("Paths/GIG", Carla.GIG_PATH))
  1355. Carla.SF2_PATH = toList(settings.value("Paths/SF2", Carla.SF2_PATH))
  1356. Carla.SFZ_PATH = toList(settings.value("Paths/SFZ", Carla.SFZ_PATH))
  1357. os.environ["LADSPA_PATH"] = splitter.join(Carla.LADSPA_PATH)
  1358. os.environ["DSSI_PATH"] = splitter.join(Carla.DSSI_PATH)
  1359. os.environ["LV2_PATH"] = splitter.join(Carla.LV2_PATH)
  1360. os.environ["VST_PATH"] = splitter.join(Carla.VST_PATH)
  1361. os.environ["GIG_PATH"] = splitter.join(Carla.GIG_PATH)
  1362. os.environ["SF2_PATH"] = splitter.join(Carla.SF2_PATH)
  1363. os.environ["SFZ_PATH"] = splitter.join(Carla.SFZ_PATH)
  1364. def updateInfoLabelPos(self):
  1365. tabBar = self.ui.tabMain.tabBar()
  1366. y = tabBar.mapFromParent(self.ui.centralwidget.pos()).y()+tabBar.height()/4
  1367. if not self.ui.toolBar.isVisible():
  1368. y -= self.ui.toolBar.height()
  1369. self.fInfoLabel.move(self.fInfoLabel.x(), y)
  1370. def updateInfoLabelSize(self):
  1371. tabBar = self.ui.tabMain.tabBar()
  1372. self.fInfoLabel.resize(self.ui.tabMain.width()-tabBar.width()-20, self.fInfoLabel.height())
  1373. def resizeEvent(self, event):
  1374. if self.ui.tabMain.currentIndex() == 0:
  1375. # Force update of 2nd tab
  1376. width = self.ui.tab_plugins.width()-4
  1377. height = self.ui.tab_plugins.height()-4
  1378. self.ui.miniCanvasPreview.setViewSize(float(width) / DEFAULT_CANVAS_WIDTH, float(height) / DEFAULT_CANVAS_HEIGHT)
  1379. else:
  1380. QTimer.singleShot(0, self, SLOT("slot_miniCanvasCheckSize()"))
  1381. self.updateInfoLabelSize()
  1382. QMainWindow.resizeEvent(self, event)
  1383. def timerEvent(self, event):
  1384. if event.timerId() == self.fIdleTimerFast:
  1385. Carla.host.engine_idle()
  1386. for pwidget in self.fPluginList:
  1387. if pwidget is None:
  1388. break
  1389. pwidget.idleFast()
  1390. self.refreshTransport()
  1391. elif event.timerId() == self.fIdleTimerSlow:
  1392. for pwidget in self.fPluginList:
  1393. if pwidget is None:
  1394. break
  1395. pwidget.idleSlow()
  1396. QMainWindow.timerEvent(self, event)
  1397. def closeEvent(self, event):
  1398. #if self.nsm_server:
  1399. #self.nsm_server.stop()
  1400. self.saveSettings()
  1401. if Carla.host.is_engine_running():
  1402. Carla.host.set_engine_about_to_close()
  1403. self.removeAllPlugins()
  1404. self.stopEngine()
  1405. QMainWindow.closeEvent(self, event)
  1406. # ------------------------------------------------------------------------------------------------
  1407. def canvasCallback(action, value1, value2, valueStr):
  1408. if action == patchcanvas.ACTION_GROUP_INFO:
  1409. pass
  1410. elif action == patchcanvas.ACTION_GROUP_RENAME:
  1411. pass
  1412. elif action == patchcanvas.ACTION_GROUP_SPLIT:
  1413. groupId = value1
  1414. patchcanvas.splitGroup(groupId)
  1415. elif action == patchcanvas.ACTION_GROUP_JOIN:
  1416. groupId = value1
  1417. patchcanvas.joinGroup(groupId)
  1418. elif action == patchcanvas.ACTION_PORT_INFO:
  1419. pass
  1420. elif action == patchcanvas.ACTION_PORT_RENAME:
  1421. pass
  1422. elif action == patchcanvas.ACTION_PORTS_CONNECT:
  1423. portIdA = value1
  1424. portIdB = value2
  1425. Carla.host.patchbay_connect(portIdA, portIdB)
  1426. elif action == patchcanvas.ACTION_PORTS_DISCONNECT:
  1427. connectionId = value1
  1428. Carla.host.patchbay_disconnect(connectionId)
  1429. def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr):
  1430. if pluginId < 0 or not Carla.gui:
  1431. return
  1432. if action == CALLBACK_DEBUG:
  1433. Carla.gui.emit(SIGNAL("DebugCallback(int, int, int, double, QString)"), pluginId, value1, value2, value3, cString(valueStr))
  1434. elif action == CALLBACK_PLUGIN_ADDED:
  1435. Carla.gui.emit(SIGNAL("PluginAddedCallback(int)"), pluginId)
  1436. elif action == CALLBACK_PLUGIN_REMOVED:
  1437. Carla.gui.emit(SIGNAL("PluginRemovedCallback(int)"), pluginId)
  1438. elif action == CALLBACK_PLUGIN_RENAMED:
  1439. Carla.gui.emit(SIGNAL("PluginRenamedCallback(int, QString)"), pluginId, valueStr)
  1440. elif action == CALLBACK_PARAMETER_VALUE_CHANGED:
  1441. Carla.gui.emit(SIGNAL("ParameterValueChangedCallback(int, int, double)"), pluginId, value1, value3)
  1442. elif action == CALLBACK_PARAMETER_DEFAULT_CHANGED:
  1443. Carla.gui.emit(SIGNAL("ParameterDefaultChangedCallback(int, int, double)"), pluginId, value1, value3)
  1444. elif action == CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED:
  1445. Carla.gui.emit(SIGNAL("ParameterMidiChannelChangedCallback(int, int, int)"), pluginId, value1, value2)
  1446. elif action == CALLBACK_PARAMETER_MIDI_CC_CHANGED:
  1447. Carla.gui.emit(SIGNAL("ParameterMidiCcChangedCallback(int, int, int)"), pluginId, value1, value2)
  1448. elif action == CALLBACK_PROGRAM_CHANGED:
  1449. Carla.gui.emit(SIGNAL("ProgramChangedCallback(int, int)"), pluginId, value1)
  1450. elif action == CALLBACK_MIDI_PROGRAM_CHANGED:
  1451. Carla.gui.emit(SIGNAL("MidiProgramChangedCallback(int, int)"), pluginId, value1)
  1452. elif action == CALLBACK_NOTE_ON:
  1453. Carla.gui.emit(SIGNAL("NoteOnCallback(int, int, int, int)"), pluginId, value1, value2, value3)
  1454. elif action == CALLBACK_NOTE_OFF:
  1455. Carla.gui.emit(SIGNAL("NoteOffCallback(int, int, int)"), pluginId, value1, value2)
  1456. elif action == CALLBACK_SHOW_GUI:
  1457. Carla.gui.emit(SIGNAL("ShowGuiCallback(int, int)"), pluginId, value1)
  1458. elif action == CALLBACK_UPDATE:
  1459. Carla.gui.emit(SIGNAL("UpdateCallback(int)"), pluginId)
  1460. elif action == CALLBACK_RELOAD_INFO:
  1461. Carla.gui.emit(SIGNAL("ReloadInfoCallback(int)"), pluginId)
  1462. elif action == CALLBACK_RELOAD_PARAMETERS:
  1463. Carla.gui.emit(SIGNAL("ReloadParametersCallback(int)"), pluginId)
  1464. elif action == CALLBACK_RELOAD_PROGRAMS:
  1465. Carla.gui.emit(SIGNAL("ReloadProgramsCallback(int)"), pluginId)
  1466. elif action == CALLBACK_RELOAD_ALL:
  1467. Carla.gui.emit(SIGNAL("ReloadAllCallback(int)"), pluginId)
  1468. elif action == CALLBACK_PATCHBAY_CLIENT_ADDED:
  1469. Carla.gui.emit(SIGNAL("PatchbayClientAddedCallback(int, QString)"), value1, cString(valueStr))
  1470. elif action == CALLBACK_PATCHBAY_CLIENT_REMOVED:
  1471. Carla.gui.emit(SIGNAL("PatchbayClientRemovedCallback(int)"), value1)
  1472. elif action == CALLBACK_PATCHBAY_CLIENT_RENAMED:
  1473. Carla.gui.emit(SIGNAL("PatchbayClientRenamedCallback(int, QString)"), value1, cString(valueStr))
  1474. elif action == CALLBACK_PATCHBAY_PORT_ADDED:
  1475. Carla.gui.emit(SIGNAL("PatchbayPortAddedCallback(int, int, int, QString)"), value1, value2, int(value3), cString(valueStr))
  1476. elif action == CALLBACK_PATCHBAY_PORT_REMOVED:
  1477. Carla.gui.emit(SIGNAL("PatchbayPortRemovedCallback(int)"), value1)
  1478. elif action == CALLBACK_PATCHBAY_PORT_RENAMED:
  1479. Carla.gui.emit(SIGNAL("PatchbayPortRenamedCallback(int, QString)"), value1, cString(valueStr))
  1480. elif action == CALLBACK_PATCHBAY_CONNECTION_ADDED:
  1481. Carla.gui.emit(SIGNAL("PatchbayConnectionAddedCallback(int, int, int)"), value1, value2, value3)
  1482. elif action == CALLBACK_PATCHBAY_CONNECTION_REMOVED:
  1483. Carla.gui.emit(SIGNAL("PatchbayConnectionRemovedCallback(int)"), value1)
  1484. elif action == CALLBACK_BUFFER_SIZE_CHANGED:
  1485. Carla.gui.emit(SIGNAL("BufferSizeChangedCallback(int)"), value1)
  1486. elif action == CALLBACK_SAMPLE_RATE_CHANGED:
  1487. Carla.gui.emit(SIGNAL("SampleRateChangedCallback(double)"), value3)
  1488. elif action == CALLBACK_NSM_ANNOUNCE:
  1489. Carla.gui.emit(SIGNAL("NSM_AnnounceCallback(QString)"), cString(valueStr))
  1490. elif action == CALLBACK_NSM_OPEN:
  1491. Carla.gui.emit(SIGNAL("NSM_OpenCallback(QString)"), cString(valueStr))
  1492. elif action == CALLBACK_NSM_SAVE:
  1493. Carla.gui.emit(SIGNAL("NSM_SaveCallback()"))
  1494. elif action == CALLBACK_ERROR:
  1495. Carla.gui.emit(SIGNAL("ErrorCallback(QString)"), cString(valueStr))
  1496. elif action == CALLBACK_QUIT:
  1497. Carla.gui.emit(SIGNAL("QuitCallback()"))
  1498. #--------------- main ------------------
  1499. if __name__ == '__main__':
  1500. # App initialization
  1501. app = QApplication(sys.argv)
  1502. app.setApplicationName("Carla")
  1503. app.setApplicationVersion(VERSION)
  1504. app.setOrganizationName("falkTX")
  1505. app.setWindowIcon(QIcon(":/scalable/carla.svg"))
  1506. libPrefix = None
  1507. projectFilename = None
  1508. for i in range(len(app.arguments())):
  1509. if i == 0: continue
  1510. argument = app.arguments()[i]
  1511. if argument.startswith("--with-libprefix="):
  1512. libPrefix = argument.replace("--with-libprefix=", "")
  1513. elif os.path.exists(argument):
  1514. projectFilename = argument
  1515. if libPrefix is not None:
  1516. libName = os.path.join(libPrefix, "lib", "carla", carla_libname)
  1517. else:
  1518. libName = carla_library_path
  1519. # Init backend
  1520. Carla.host = Host(libName)
  1521. Carla.host.set_engine_callback(engineCallback)
  1522. Carla.host.set_engine_option(OPTION_PROCESS_NAME, 0, "carla")
  1523. # Set bridge paths
  1524. if carla_bridge_native:
  1525. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_NATIVE, 0, carla_bridge_native)
  1526. if carla_bridge_posix32:
  1527. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_POSIX32, 0, carla_bridge_posix32)
  1528. if carla_bridge_posix64:
  1529. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_POSIX64, 0, carla_bridge_posix64)
  1530. if carla_bridge_win32:
  1531. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_WIN32, 0, carla_bridge_win32)
  1532. if carla_bridge_win64:
  1533. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_WIN64, 0, carla_bridge_win64)
  1534. if WINDOWS:
  1535. if carla_bridge_lv2_windows:
  1536. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_LV2_WINDOWS, 0, carla_bridge_lv2_windows)
  1537. if carla_bridge_vst_hwnd:
  1538. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_VST_HWND, 0, carla_bridge_vst_hwnd)
  1539. elif MACOS:
  1540. if carla_bridge_lv2_cocoa:
  1541. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_LV2_COCOA, 0, carla_bridge_lv2_cocoa)
  1542. if carla_bridge_vst_cocoa:
  1543. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_VST_COCOA, 0, carla_bridge_vst_cocoa)
  1544. else:
  1545. if carla_bridge_lv2_gtk2:
  1546. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_LV2_GTK2, 0, carla_bridge_lv2_gtk2)
  1547. if carla_bridge_lv2_gtk3:
  1548. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_LV2_GTK3, 0, carla_bridge_lv2_gtk3)
  1549. if carla_bridge_lv2_qt4:
  1550. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_LV2_QT4, 0, carla_bridge_lv2_qt4)
  1551. if carla_bridge_lv2_qt5:
  1552. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_LV2_QT5, 0, carla_bridge_lv2_qt5)
  1553. if carla_bridge_lv2_x11:
  1554. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_LV2_X11, 0, carla_bridge_lv2_x11)
  1555. if carla_bridge_vst_x11:
  1556. Carla.host.set_engine_option(OPTION_PATH_BRIDGE_VST_X11, 0, carla_bridge_vst_x11)
  1557. # Create GUI and start engine
  1558. Carla.gui = CarlaMainW()
  1559. # Set-up custom signal handling
  1560. setUpSignals()
  1561. # Show GUI
  1562. Carla.gui.show()
  1563. # Load project file if set
  1564. if projectFilename and not os.getenv("NSM_URL"):
  1565. Carla.gui.loadProjectLater(projectFilename)
  1566. # App-Loop
  1567. ret = app.exec_()
  1568. # Exit properly
  1569. sys.exit(ret)