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.

2029 lines
82KB

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