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.

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