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.

1232 lines
58KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla settings code
  4. # Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from PyQt5.QtCore import pyqtSlot, QByteArray, QDir, QSettings
  20. from PyQt5.QtGui import QColor, QCursor, QPainter, QPainterPath
  21. from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  22. # ------------------------------------------------------------------------------------------------------------
  23. # Imports (Custom)
  24. import ui_carla_settings
  25. import ui_carla_settings_driver
  26. from carla_shared import *
  27. from patchcanvas.theme import *
  28. # ------------------------------------------------------------------------------------------------------------
  29. # ...
  30. BUFFER_SIZE_LIST = (16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192)
  31. SAMPLE_RATE_LIST = (22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000)
  32. # ------------------------------------------------------------------------------------------------------------
  33. # Driver Settings
  34. class DriverSettingsW(QDialog):
  35. AUTOMATIC_OPTION = "(Auto)"
  36. def __init__(self, parent, host, driverIndex, driverName):
  37. QDialog.__init__(self, parent)
  38. self.host = host
  39. self.ui = ui_carla_settings_driver.Ui_DriverSettingsW()
  40. self.ui.setupUi(self)
  41. if False:
  42. # kdevelop likes this :)
  43. host = CarlaHostNull()
  44. self.host = host
  45. # ----------------------------------------------------------------------------------------------------
  46. # Internal stuff
  47. self.fDriverIndex = driverIndex
  48. self.fDriverName = driverName
  49. self.fDeviceNames = host.get_engine_driver_device_names(driverIndex)
  50. self.fBufferSizes = BUFFER_SIZE_LIST
  51. self.fSampleRates = SAMPLE_RATE_LIST
  52. # ----------------------------------------------------------------------------------------------------
  53. # Set-up GUI
  54. for name in self.fDeviceNames:
  55. self.ui.cb_device.addItem(name)
  56. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  57. # ----------------------------------------------------------------------------------------------------
  58. # Load settings
  59. self.loadSettings()
  60. # ----------------------------------------------------------------------------------------------------
  61. # Set-up connections
  62. self.accepted.connect(self.slot_saveSettings)
  63. self.ui.b_panel.clicked.connect(self.slot_showDevicePanel)
  64. self.ui.cb_device.currentIndexChanged.connect(self.slot_updateDeviceInfo)
  65. # ----------------------------------------------------------------------------------------------------
  66. def loadSettings(self):
  67. settings = QSettings("falkTX", "Carla2")
  68. audioDevice = settings.value("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), "", type=str)
  69. audioBufferSize = settings.value("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int)
  70. audioSampleRate = settings.value("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int)
  71. audioTripleBuffer = settings.value("%s%s/TripleBuffer" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_TRIPLE_BUFFER, type=bool)
  72. if audioDevice and audioDevice in self.fDeviceNames:
  73. self.ui.cb_device.setCurrentIndex(self.fDeviceNames.index(audioDevice))
  74. else:
  75. self.ui.cb_device.setCurrentIndex(-1)
  76. # fill combo-boxes first
  77. self.slot_updateDeviceInfo()
  78. if audioBufferSize and audioBufferSize in self.fBufferSizes:
  79. self.ui.cb_buffersize.setCurrentIndex(self.fBufferSizes.index(audioBufferSize))
  80. elif self.fBufferSizes == BUFFER_SIZE_LIST:
  81. self.ui.cb_buffersize.setCurrentIndex(BUFFER_SIZE_LIST.index(CARLA_DEFAULT_AUDIO_BUFFER_SIZE))
  82. else:
  83. self.ui.cb_buffersize.setCurrentIndex(len(self.fBufferSizes)/2)
  84. if audioSampleRate and audioSampleRate in self.fSampleRates:
  85. self.ui.cb_samplerate.setCurrentIndex(self.fSampleRates.index(audioSampleRate))
  86. elif self.fSampleRates == SAMPLE_RATE_LIST:
  87. self.ui.cb_samplerate.setCurrentIndex(SAMPLE_RATE_LIST.index(CARLA_DEFAULT_AUDIO_SAMPLE_RATE))
  88. else:
  89. self.ui.cb_samplerate.setCurrentIndex(len(self.fSampleRates)/2)
  90. self.ui.cb_triple_buffer.setChecked(audioTripleBuffer and self.ui.cb_triple_buffer.isEnabled())
  91. # --------------------------------------------------------------------------------------------------------
  92. @pyqtSlot()
  93. def slot_saveSettings(self):
  94. settings = QSettings("falkTX", "Carla2")
  95. bufferSize = self.ui.cb_buffersize.currentText()
  96. sampleRate = self.ui.cb_samplerate.currentText()
  97. if bufferSize == self.AUTOMATIC_OPTION:
  98. bufferSize = "0"
  99. if sampleRate == self.AUTOMATIC_OPTION:
  100. sampleRate = "0"
  101. settings.setValue("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), self.ui.cb_device.currentText())
  102. settings.setValue("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), bufferSize)
  103. settings.setValue("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), sampleRate)
  104. settings.setValue("%s%s/TripleBuffer" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), self.ui.cb_triple_buffer.isChecked())
  105. # --------------------------------------------------------------------------------------------------------
  106. @pyqtSlot()
  107. def slot_showDevicePanel(self):
  108. self.host.show_engine_driver_device_control_panel(self.fDriverIndex, self.ui.cb_device.currentText())
  109. @pyqtSlot()
  110. def slot_updateDeviceInfo(self):
  111. deviceName = self.ui.cb_device.currentText()
  112. oldBufferSize = self.ui.cb_buffersize.currentText()
  113. oldSampleRate = self.ui.cb_samplerate.currentText()
  114. self.ui.cb_buffersize.clear()
  115. self.ui.cb_samplerate.clear()
  116. driverDeviceInfo = self.host.get_engine_driver_device_info(self.fDriverIndex, deviceName)
  117. driverDeviceHints = driverDeviceInfo['hints']
  118. self.fBufferSizes = driverDeviceInfo['bufferSizes']
  119. self.fSampleRates = driverDeviceInfo['sampleRates']
  120. if driverDeviceHints & ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER:
  121. self.ui.cb_triple_buffer.setEnabled(True)
  122. else:
  123. self.ui.cb_triple_buffer.setEnabled(False)
  124. if driverDeviceHints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL:
  125. self.ui.b_panel.setEnabled(True)
  126. else:
  127. self.ui.b_panel.setEnabled(False)
  128. if len(self.fBufferSizes) > 0:
  129. for bsize in self.fBufferSizes:
  130. sbsize = str(bsize)
  131. self.ui.cb_buffersize.addItem(sbsize)
  132. if oldBufferSize == sbsize:
  133. self.ui.cb_buffersize.setCurrentIndex(self.ui.cb_buffersize.count()-1)
  134. else:
  135. self.ui.cb_buffersize.addItem(self.AUTOMATIC_OPTION)
  136. self.ui.cb_buffersize.setCurrentIndex(0)
  137. if len(self.fSampleRates) > 0:
  138. for srate in self.fSampleRates:
  139. ssrate = str(int(srate))
  140. self.ui.cb_samplerate.addItem(ssrate)
  141. if oldSampleRate == ssrate:
  142. self.ui.cb_samplerate.setCurrentIndex(self.ui.cb_samplerate.count()-1)
  143. else:
  144. self.ui.cb_samplerate.addItem(self.AUTOMATIC_OPTION)
  145. self.ui.cb_samplerate.setCurrentIndex(0)
  146. # --------------------------------------------------------------------------------------------------------
  147. def done(self, r):
  148. QDialog.done(self, r)
  149. self.close()
  150. # ------------------------------------------------------------------------------------------------------------
  151. # Runtime Driver Settings
  152. class RuntimeDriverSettingsW(QDialog):
  153. def __init__(self, parent, host):
  154. QDialog.__init__(self, parent)
  155. self.host = host
  156. self.ui = ui_carla_settings_driver.Ui_DriverSettingsW()
  157. self.ui.setupUi(self)
  158. if False:
  159. # kdevelop likes this :)
  160. host = CarlaHostNull()
  161. self.host = host
  162. driverDeviceInfo = host.get_runtime_engine_driver_device_info()
  163. # ----------------------------------------------------------------------------------------------------
  164. # Set-up GUI
  165. self.ui.cb_device.setEnabled(False)
  166. self.ui.cb_device.clear()
  167. self.ui.cb_buffersize.clear()
  168. self.ui.cb_samplerate.clear()
  169. self.ui.cb_triple_buffer.hide()
  170. self.ui.ico_restart.hide()
  171. self.ui.label_restart.hide()
  172. self.adjustSize()
  173. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  174. #self.setFixedSize(self.size())
  175. # ----------------------------------------------------------------------------------------------------
  176. # Load runtime settings
  177. self.ui.cb_device.addItem(driverDeviceInfo['name'])
  178. self.ui.cb_device.setCurrentIndex(0)
  179. if len(driverDeviceInfo['bufferSizes']) > 0:
  180. for bsize in driverDeviceInfo['bufferSizes']:
  181. sbsize = str(bsize)
  182. self.ui.cb_buffersize.addItem(sbsize)
  183. if driverDeviceInfo['bufferSize'] == bsize:
  184. self.ui.cb_buffersize.setCurrentIndex(self.ui.cb_buffersize.count()-1)
  185. else:
  186. self.ui.cb_buffersize.addItem(DriverSettingsW.AUTOMATIC_OPTION)
  187. self.ui.cb_buffersize.setCurrentIndex(0)
  188. if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE) == 0x0:
  189. self.ui.cb_buffersize.setEnabled(False)
  190. if len(driverDeviceInfo['sampleRates']) > 0:
  191. for srate in driverDeviceInfo['sampleRates']:
  192. ssrate = str(int(srate))
  193. self.ui.cb_samplerate.addItem(ssrate)
  194. if driverDeviceInfo['sampleRate'] == srate:
  195. self.ui.cb_samplerate.setCurrentIndex(self.ui.cb_samplerate.count()-1)
  196. else:
  197. self.ui.cb_samplerate.addItem(DriverSettingsW.AUTOMATIC_OPTION)
  198. self.ui.cb_samplerate.setCurrentIndex(0)
  199. if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE) == 0x0:
  200. self.ui.cb_samplerate.setEnabled(False)
  201. if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL) == 0x0:
  202. self.ui.b_panel.setEnabled(False)
  203. # ----------------------------------------------------------------------------------------------------
  204. # Set-up connections
  205. self.ui.b_panel.clicked.connect(self.slot_showDevicePanel)
  206. # --------------------------------------------------------------------------------------------------------
  207. def getValues(self):
  208. bufferSize = self.ui.cb_buffersize.currentText()
  209. sampleRate = self.ui.cb_samplerate.currentText()
  210. if bufferSize == DriverSettingsW.AUTOMATIC_OPTION:
  211. bufferSize = "0"
  212. if sampleRate == DriverSettingsW.AUTOMATIC_OPTION:
  213. sampleRate = "0"
  214. return (int(bufferSize), int(sampleRate))
  215. # --------------------------------------------------------------------------------------------------------
  216. @pyqtSlot()
  217. def slot_showDevicePanel(self):
  218. self.host.show_engine_device_control_panel()
  219. # --------------------------------------------------------------------------------------------------------
  220. def done(self, r):
  221. QDialog.done(self, r)
  222. self.close()
  223. # ------------------------------------------------------------------------------------------------------------
  224. # Settings Dialog
  225. class CarlaSettingsW(QDialog):
  226. # Tab indexes
  227. TAB_INDEX_MAIN = 0
  228. TAB_INDEX_CANVAS = 1
  229. TAB_INDEX_ENGINE = 2
  230. TAB_INDEX_OSC = 3
  231. TAB_INDEX_PATHS = 4
  232. TAB_INDEX_WINE = 5
  233. TAB_INDEX_EXPERIMENTAL = 6
  234. TAB_INDEX_NONE = 7
  235. # Path indexes
  236. PATH_INDEX_LADSPA = 0
  237. PATH_INDEX_DSSI = 1
  238. PATH_INDEX_LV2 = 2
  239. PATH_INDEX_VST2 = 3
  240. PATH_INDEX_VST3 = 4
  241. PATH_INDEX_SF2 = 5
  242. PATH_INDEX_SFZ = 6
  243. # Single and Multiple client mode is only for JACK,
  244. # but we still want to match QComboBox index to backend defines,
  245. # so add +2 pos padding if driverName != "JACK".
  246. PROCESS_MODE_NON_JACK_PADDING = 2
  247. # --------------------------------------------------------------------------------------------------------
  248. def __init__(self, parent, host, hasCanvas, hasCanvasGL):
  249. QDialog.__init__(self, parent)
  250. self.host = host
  251. self.ui = ui_carla_settings.Ui_CarlaSettingsW()
  252. self.ui.setupUi(self)
  253. if False:
  254. # kdevelop likes this :)
  255. host = CarlaHostNull()
  256. self.host = host
  257. # ----------------------------------------------------------------------------------------------------
  258. # Set-up GUI
  259. self.ui.lw_page.setFixedWidth(48 + 6*3 + self.ui.lw_page.fontMetrics().width(" Experimental "))
  260. for i in range(host.get_engine_driver_count()):
  261. self.ui.cb_engine_audio_driver.addItem(host.get_engine_driver_name(i))
  262. for i in range(Theme.THEME_MAX):
  263. self.ui.cb_canvas_theme.addItem(getThemeName(i))
  264. if MACOS:
  265. self.ui.group_main_theme.setEnabled(False)
  266. self.ui.group_main_theme.setVisible(False)
  267. if WINDOWS or host.isControl:
  268. self.ui.ch_main_show_logs.setEnabled(False)
  269. self.ui.ch_main_show_logs.setVisible(False)
  270. if host.isControl:
  271. self.ui.lw_page.hideRow(self.TAB_INDEX_ENGINE)
  272. self.ui.lw_page.hideRow(self.TAB_INDEX_PATHS)
  273. self.ui.ch_exp_export_lv2.hide()
  274. self.ui.group_experimental_engine.hide()
  275. elif not hasCanvas:
  276. self.ui.lw_page.hideRow(self.TAB_INDEX_CANVAS)
  277. elif not hasCanvasGL:
  278. self.ui.cb_canvas_use_opengl.setEnabled(False)
  279. self.ui.cb_canvas_render_hq_aa.setEnabled(False)
  280. if host.isPlugin:
  281. self.ui.cb_engine_audio_driver.setEnabled(False)
  282. if host.audioDriverForced is not None:
  283. self.ui.cb_engine_audio_driver.setEnabled(False)
  284. self.ui.tb_engine_driver_config.setEnabled(False)
  285. if host.processModeForced:
  286. self.ui.cb_engine_process_mode_jack.setEnabled(False)
  287. self.ui.cb_engine_process_mode_other.setEnabled(False)
  288. if self.host.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  289. self.ui.ch_engine_force_stereo.setEnabled(False)
  290. if host.isControl or host.isPlugin:
  291. self.ui.ch_main_confirm_exit.hide()
  292. self.ui.ch_exp_load_lib_global.hide()
  293. self.ui.lw_page.hideRow(self.TAB_INDEX_OSC)
  294. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  295. if not LINUX:
  296. self.ui.ch_exp_wine_bridges.setVisible(False)
  297. self.ui.ch_exp_jack_apps.setVisible(False)
  298. self.ui.ch_exp_prevent_bad_behaviour.setVisible(False)
  299. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  300. if not MACOS:
  301. self.ui.label_engine_ui_bridges_mac_note.setVisible(False)
  302. # FIXME, not implemented yet
  303. self.ui.ch_engine_uis_always_on_top.hide()
  304. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  305. # ----------------------------------------------------------------------------------------------------
  306. # Load settings
  307. self.loadSettings()
  308. # ----------------------------------------------------------------------------------------------------
  309. # Set-up connections
  310. self.accepted.connect(self.slot_saveSettings)
  311. self.ui.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self.slot_resetSettings)
  312. self.ui.b_main_proj_folder_open.clicked.connect(self.slot_getAndSetProjectPath)
  313. self.ui.cb_engine_audio_driver.currentIndexChanged.connect(self.slot_engineAudioDriverChanged)
  314. self.ui.tb_engine_driver_config.clicked.connect(self.slot_showAudioDriverSettings)
  315. self.ui.b_paths_add.clicked.connect(self.slot_addPluginPath)
  316. self.ui.b_paths_remove.clicked.connect(self.slot_removePluginPath)
  317. self.ui.b_paths_change.clicked.connect(self.slot_changePluginPath)
  318. self.ui.cb_paths.currentIndexChanged.connect(self.slot_pluginPathTabChanged)
  319. self.ui.lw_ladspa.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  320. self.ui.lw_dssi.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  321. self.ui.lw_lv2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  322. self.ui.lw_vst.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  323. self.ui.lw_vst3.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  324. self.ui.lw_sf2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  325. self.ui.lw_sfz.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  326. self.ui.ch_main_experimental.toggled.connect(self.slot_enableExperimental)
  327. self.ui.ch_exp_wine_bridges.toggled.connect(self.slot_enableWineBridges)
  328. self.ui.cb_exp_plugin_bridges.toggled.connect(self.slot_pluginBridgesToggled)
  329. self.ui.cb_canvas_eyecandy.toggled.connect(self.slot_canvasEyeCandyToggled)
  330. self.ui.cb_canvas_fancy_eyecandy.toggled.connect(self.slot_canvasFancyEyeCandyToggled)
  331. self.ui.cb_canvas_use_opengl.toggled.connect(self.slot_canvasOpenGLToggled)
  332. # ----------------------------------------------------------------------------------------------------
  333. # Post-connect setup
  334. self.ui.lw_ladspa.setCurrentRow(0)
  335. self.ui.lw_dssi.setCurrentRow(0)
  336. self.ui.lw_lv2.setCurrentRow(0)
  337. self.ui.lw_vst.setCurrentRow(0)
  338. self.ui.lw_vst3.setCurrentRow(0)
  339. self.ui.lw_sf2.setCurrentRow(0)
  340. self.ui.lw_sfz.setCurrentRow(0)
  341. self.ui.lw_page.setCurrentCell(0, 0)
  342. self.adjustSize()
  343. # --------------------------------------------------------------------------------------------------------
  344. def loadSettings(self):
  345. settings = QSettings()
  346. # ----------------------------------------------------------------------------------------------------
  347. # Main
  348. self.ui.ch_main_show_logs.setChecked(self.host.showLogs)
  349. self.ui.ch_engine_uis_always_on_top.setChecked(self.host.uisAlwaysOnTop)
  350. self.ui.le_main_proj_folder.setText(settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, type=str))
  351. self.ui.ch_main_theme_pro.setChecked(settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_USE_PRO_THEME, type=bool) and self.ui.group_main_theme.isEnabled())
  352. self.ui.cb_main_theme_color.setCurrentIndex(self.ui.cb_main_theme_color.findText(settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, type=str)))
  353. self.ui.sb_main_refresh_interval.setValue(settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, type=int))
  354. self.ui.ch_main_confirm_exit.setChecked(settings.value(CARLA_KEY_MAIN_CONFIRM_EXIT, CARLA_DEFAULT_MAIN_CONFIRM_EXIT, type=bool))
  355. # ----------------------------------------------------------------------------------------------------
  356. # Canvas
  357. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, type=str)))
  358. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, type=str)))
  359. self.ui.cb_canvas_bezier_lines.setChecked(settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, type=bool))
  360. self.ui.cb_canvas_hide_groups.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, type=bool))
  361. self.ui.cb_canvas_auto_select.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS, type=bool))
  362. self.ui.cb_canvas_eyecandy.setChecked(settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, type=bool))
  363. self.ui.cb_canvas_fancy_eyecandy.setChecked(settings.value(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY, type=bool))
  364. self.ui.cb_canvas_use_opengl.setChecked(settings.value(CARLA_KEY_CANVAS_USE_OPENGL, CARLA_DEFAULT_CANVAS_USE_OPENGL, type=bool) and self.ui.cb_canvas_use_opengl.isEnabled())
  365. self.ui.cb_canvas_render_aa.setCheckState(settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, type=int))
  366. self.ui.cb_canvas_render_hq_aa.setChecked(settings.value(CARLA_KEY_CANVAS_HQ_ANTIALIASING, CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING, type=bool) and self.ui.cb_canvas_render_hq_aa.isEnabled())
  367. self.ui.cb_canvas_full_repaints.setChecked(settings.value(CARLA_KEY_CANVAS_FULL_REPAINTS, CARLA_DEFAULT_CANVAS_FULL_REPAINTS, type=bool))
  368. self.ui.cb_canvas_inline_displays.setChecked(settings.value(CARLA_KEY_CANVAS_INLINE_DISPLAYS, CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS, type=bool))
  369. # ----------------------------------------------------------------------------------------------------
  370. settings = QSettings("falkTX", "Carla2")
  371. # ----------------------------------------------------------------------------------------------------
  372. # Main
  373. self.ui.ch_main_experimental.setChecked(self.host.experimental)
  374. if not self.host.experimental:
  375. self.ui.lw_page.hideRow(self.TAB_INDEX_EXPERIMENTAL)
  376. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  377. elif not self.host.showWineBridges:
  378. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  379. # ----------------------------------------------------------------------------------------------------
  380. # Engine
  381. if self.host.isPlugin:
  382. audioDriver = "Plugin"
  383. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  384. elif self.host.audioDriverForced:
  385. audioDriver = self.host.audioDriverForced
  386. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  387. else:
  388. audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str)
  389. for i in range(self.ui.cb_engine_audio_driver.count()):
  390. if self.ui.cb_engine_audio_driver.itemText(i) == audioDriver:
  391. self.ui.cb_engine_audio_driver.setCurrentIndex(i)
  392. break
  393. else:
  394. self.ui.cb_engine_audio_driver.setCurrentIndex(-1)
  395. if audioDriver == "JACK":
  396. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  397. else:
  398. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  399. self.ui.tb_engine_driver_config.setEnabled(self.host.audioDriverForced is None and not self.host.isPlugin)
  400. self.ui.cb_engine_process_mode_jack.setCurrentIndex(self.host.nextProcessMode)
  401. if self.host.nextProcessMode >= self.PROCESS_MODE_NON_JACK_PADDING:
  402. self.ui.cb_engine_process_mode_other.setCurrentIndex(self.host.nextProcessMode-self.PROCESS_MODE_NON_JACK_PADDING)
  403. else:
  404. self.ui.cb_engine_process_mode_other.setCurrentIndex(0)
  405. self.ui.sb_engine_max_params.setValue(self.host.maxParameters)
  406. self.ui.ch_engine_manage_uis.setChecked(self.host.manageUIs)
  407. self.ui.ch_engine_prefer_ui_bridges.setChecked(self.host.preferUIBridges)
  408. self.ui.sb_engine_ui_bridges_timeout.setValue(self.host.uiBridgesTimeout)
  409. self.ui.ch_engine_force_stereo.setChecked(self.host.forceStereo or not self.ui.ch_engine_force_stereo.isEnabled())
  410. self.ui.ch_engine_prefer_plugin_bridges.setChecked(self.host.preferPluginBridges)
  411. self.ui.ch_exp_export_lv2.setChecked(self.host.exportLV2)
  412. self.ui.cb_exp_plugin_bridges.setChecked(self.host.showPluginBridges)
  413. self.ui.ch_exp_wine_bridges.setChecked(self.host.showWineBridges)
  414. # ----------------------------------------------------------------------------------------------------
  415. # OSC
  416. self.ui.ch_osc_enable.setChecked(settings.value(CARLA_KEY_OSC_ENABLED,
  417. CARLA_DEFAULT_OSC_ENABLED,
  418. type=bool))
  419. self.ui.group_osc_tcp_port.setChecked(settings.value(CARLA_KEY_OSC_TCP_PORT_ENABLED,
  420. CARLA_DEFAULT_OSC_TCP_PORT_ENABLED,
  421. type=bool))
  422. self.ui.group_osc_udp_port.setChecked(settings.value(CARLA_KEY_OSC_UDP_PORT_ENABLED,
  423. CARLA_DEFAULT_OSC_UDP_PORT_ENABLED,
  424. type=bool))
  425. self.ui.sb_osc_tcp_port_number.setValue(settings.value(CARLA_KEY_OSC_TCP_PORT_NUMBER,
  426. CARLA_DEFAULT_OSC_TCP_PORT_NUMBER,
  427. type=int))
  428. self.ui.sb_osc_udp_port_number.setValue(settings.value(CARLA_KEY_OSC_UDP_PORT_NUMBER,
  429. CARLA_DEFAULT_OSC_UDP_PORT_NUMBER,
  430. type=int))
  431. if settings.value(CARLA_KEY_OSC_TCP_PORT_RANDOM, CARLA_DEFAULT_OSC_TCP_PORT_RANDOM, type=bool):
  432. self.ui.rb_osc_tcp_port_specific.setChecked(False)
  433. self.ui.rb_osc_tcp_port_random.setChecked(True)
  434. else:
  435. self.ui.rb_osc_tcp_port_random.setChecked(False)
  436. self.ui.rb_osc_tcp_port_specific.setChecked(True)
  437. if settings.value(CARLA_KEY_OSC_UDP_PORT_RANDOM, CARLA_DEFAULT_OSC_UDP_PORT_RANDOM, type=bool):
  438. self.ui.rb_osc_udp_port_specific.setChecked(False)
  439. self.ui.rb_osc_udp_port_random.setChecked(True)
  440. else:
  441. self.ui.rb_osc_udp_port_random.setChecked(False)
  442. self.ui.rb_osc_udp_port_specific.setChecked(True)
  443. # ----------------------------------------------------------------------------------------------------
  444. # Paths
  445. ladspas = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH))
  446. dssis = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH))
  447. lv2s = toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))
  448. vst2s = toList(settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH))
  449. vst3s = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH))
  450. sf2s = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH))
  451. sfzs = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH))
  452. ladspas.sort()
  453. dssis.sort()
  454. lv2s.sort()
  455. vst2s.sort()
  456. vst3s.sort()
  457. sf2s.sort()
  458. sfzs.sort()
  459. for ladspa in ladspas:
  460. if not ladspa: continue
  461. self.ui.lw_ladspa.addItem(ladspa)
  462. for dssi in dssis:
  463. if not dssi: continue
  464. self.ui.lw_dssi.addItem(dssi)
  465. for lv2 in lv2s:
  466. if not lv2: continue
  467. self.ui.lw_lv2.addItem(lv2)
  468. for vst2 in vst2s:
  469. if not vst2: continue
  470. self.ui.lw_vst.addItem(vst2)
  471. for vst3 in vst3s:
  472. if not vst3: continue
  473. self.ui.lw_vst3.addItem(vst3)
  474. for sf2 in sf2s:
  475. if not sf2: continue
  476. self.ui.lw_sf2.addItem(sf2)
  477. for sfz in sfzs:
  478. if not sfz: continue
  479. self.ui.lw_sfz.addItem(sfz)
  480. # ----------------------------------------------------------------------------------------------------
  481. # Wine
  482. self.ui.le_wine_exec.setText(settings.value(CARLA_KEY_WINE_EXECUTABLE,
  483. CARLA_DEFAULT_WINE_EXECUTABLE,
  484. type=str))
  485. self.ui.cb_wine_prefix_detect.setChecked(settings.value(CARLA_KEY_WINE_AUTO_PREFIX,
  486. CARLA_DEFAULT_WINE_AUTO_PREFIX,
  487. type=bool))
  488. self.ui.le_wine_prefix_fallback.setText(settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX,
  489. CARLA_DEFAULT_WINE_FALLBACK_PREFIX,
  490. type=str))
  491. self.ui.group_wine_realtime.setChecked(settings.value(CARLA_KEY_WINE_RT_PRIO_ENABLED,
  492. CARLA_DEFAULT_WINE_RT_PRIO_ENABLED,
  493. type=bool))
  494. self.ui.sb_wine_base_prio.setValue(settings.value(CARLA_KEY_WINE_BASE_RT_PRIO,
  495. CARLA_DEFAULT_WINE_BASE_RT_PRIO,
  496. type=int))
  497. self.ui.sb_wine_server_prio.setValue(settings.value(CARLA_KEY_WINE_SERVER_RT_PRIO,
  498. CARLA_DEFAULT_WINE_SERVER_RT_PRIO,
  499. type=int))
  500. # ----------------------------------------------------------------------------------------------------
  501. # Experimental
  502. self.ui.ch_exp_jack_apps.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_JACK_APPS,
  503. CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS,
  504. type=bool))
  505. self.ui.ch_exp_export_lv2.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2,
  506. CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT,
  507. type=bool))
  508. self.ui.ch_exp_load_lib_global.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL,
  509. CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL,
  510. type=bool))
  511. self.ui.ch_exp_prevent_bad_behaviour.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  512. CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  513. type=bool))
  514. # --------------------------------------------------------------------------------------------------------
  515. @pyqtSlot()
  516. def slot_saveSettings(self):
  517. settings = QSettings()
  518. self.host.experimental = self.ui.ch_main_experimental.isChecked()
  519. if not self.host.experimental:
  520. self.resetExperimentalSettings()
  521. # ----------------------------------------------------------------------------------------------------
  522. # Main
  523. settings.setValue(CARLA_KEY_MAIN_PROJECT_FOLDER, self.ui.le_main_proj_folder.text())
  524. settings.setValue(CARLA_KEY_MAIN_CONFIRM_EXIT, self.ui.ch_main_confirm_exit.isChecked())
  525. settings.setValue(CARLA_KEY_MAIN_USE_PRO_THEME, self.ui.ch_main_theme_pro.isChecked())
  526. settings.setValue(CARLA_KEY_MAIN_PRO_THEME_COLOR, self.ui.cb_main_theme_color.currentText())
  527. settings.setValue(CARLA_KEY_MAIN_REFRESH_INTERVAL, self.ui.sb_main_refresh_interval.value())
  528. # ----------------------------------------------------------------------------------------------------
  529. # Canvas
  530. settings.setValue(CARLA_KEY_CANVAS_THEME, self.ui.cb_canvas_theme.currentText())
  531. settings.setValue(CARLA_KEY_CANVAS_SIZE, self.ui.cb_canvas_size.currentText())
  532. settings.setValue(CARLA_KEY_CANVAS_USE_BEZIER_LINES, self.ui.cb_canvas_bezier_lines.isChecked())
  533. settings.setValue(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, self.ui.cb_canvas_hide_groups.isChecked())
  534. settings.setValue(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, self.ui.cb_canvas_auto_select.isChecked())
  535. settings.setValue(CARLA_KEY_CANVAS_EYE_CANDY, self.ui.cb_canvas_eyecandy.isChecked())
  536. settings.setValue(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, self.ui.cb_canvas_fancy_eyecandy.isChecked())
  537. settings.setValue(CARLA_KEY_CANVAS_USE_OPENGL, self.ui.cb_canvas_use_opengl.isChecked())
  538. settings.setValue(CARLA_KEY_CANVAS_HQ_ANTIALIASING, self.ui.cb_canvas_render_hq_aa.isChecked())
  539. settings.setValue(CARLA_KEY_CANVAS_ANTIALIASING, self.ui.cb_canvas_render_aa.checkState()) # 0, 1, 2 match their enum variants
  540. settings.setValue(CARLA_KEY_CANVAS_FULL_REPAINTS, self.ui.cb_canvas_full_repaints.isChecked())
  541. settings.setValue(CARLA_KEY_CANVAS_INLINE_DISPLAYS, self.ui.cb_canvas_inline_displays.isChecked())
  542. # ----------------------------------------------------------------------------------------------------
  543. settings = QSettings("falkTX", "Carla2")
  544. # ----------------------------------------------------------------------------------------------------
  545. # Main
  546. settings.setValue(CARLA_KEY_MAIN_EXPERIMENTAL, self.host.experimental)
  547. # ----------------------------------------------------------------------------------------------------
  548. # Engine
  549. audioDriver = self.ui.cb_engine_audio_driver.currentText()
  550. if audioDriver and self.host.audioDriverForced is None and not self.host.isPlugin:
  551. settings.setValue(CARLA_KEY_ENGINE_AUDIO_DRIVER, audioDriver)
  552. if not self.host.processModeForced:
  553. # engine sends callback if processMode really changes
  554. if audioDriver == "JACK":
  555. self.host.nextProcessMode = self.ui.cb_engine_process_mode_jack.currentIndex()
  556. else:
  557. self.host.nextProcessMode = self.ui.cb_engine_process_mode_other.currentIndex() + self.PROCESS_MODE_NON_JACK_PADDING
  558. settings.setValue(CARLA_KEY_ENGINE_PROCESS_MODE, self.host.nextProcessMode)
  559. self.host.exportLV2 = self.ui.ch_exp_export_lv2.isChecked()
  560. self.host.forceStereo = self.ui.ch_engine_force_stereo.isChecked()
  561. self.host.maxParameters = self.ui.sb_engine_max_params.value()
  562. self.host.manageUIs = self.ui.ch_engine_manage_uis.isChecked()
  563. self.host.preferPluginBridges = self.ui.ch_engine_prefer_plugin_bridges.isChecked()
  564. self.host.preferUIBridges = self.ui.ch_engine_prefer_ui_bridges.isChecked()
  565. self.host.showLogs = self.ui.ch_main_show_logs.isChecked()
  566. self.host.showPluginBridges = self.ui.cb_exp_plugin_bridges.isChecked()
  567. self.host.showWineBridges = self.ui.ch_exp_wine_bridges.isChecked()
  568. self.host.uiBridgesTimeout = self.ui.sb_engine_ui_bridges_timeout.value()
  569. self.host.uisAlwaysOnTop = self.ui.ch_engine_uis_always_on_top.isChecked()
  570. if self.ui.ch_engine_force_stereo.isEnabled():
  571. settings.setValue(CARLA_KEY_ENGINE_FORCE_STEREO, self.host.forceStereo)
  572. settings.setValue(CARLA_KEY_MAIN_SHOW_LOGS, self.host.showLogs)
  573. settings.setValue(CARLA_KEY_ENGINE_MAX_PARAMETERS, self.host.maxParameters)
  574. settings.setValue(CARLA_KEY_ENGINE_MANAGE_UIS, self.host.manageUIs)
  575. settings.setValue(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, self.host.preferPluginBridges)
  576. settings.setValue(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, self.host.preferUIBridges)
  577. settings.setValue(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, self.host.uiBridgesTimeout)
  578. settings.setValue(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, self.host.uisAlwaysOnTop)
  579. settings.setValue(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2, self.host.exportLV2)
  580. settings.setValue(CARLA_KEY_EXPERIMENTAL_PLUGIN_BRIDGES, self.host.showPluginBridges)
  581. settings.setValue(CARLA_KEY_EXPERIMENTAL_WINE_BRIDGES, self.host.showWineBridges)
  582. # ----------------------------------------------------------------------------------------------------
  583. # OSC
  584. settings.setValue(CARLA_KEY_OSC_ENABLED, self.ui.ch_osc_enable.isChecked())
  585. settings.setValue(CARLA_KEY_OSC_TCP_PORT_ENABLED, self.ui.group_osc_tcp_port.isChecked())
  586. settings.setValue(CARLA_KEY_OSC_UDP_PORT_ENABLED, self.ui.group_osc_udp_port.isChecked())
  587. settings.setValue(CARLA_KEY_OSC_TCP_PORT_RANDOM, self.ui.rb_osc_tcp_port_random.isChecked())
  588. settings.setValue(CARLA_KEY_OSC_UDP_PORT_RANDOM, self.ui.rb_osc_udp_port_random.isChecked())
  589. settings.setValue(CARLA_KEY_OSC_TCP_PORT_NUMBER, self.ui.sb_osc_tcp_port_number.value())
  590. settings.setValue(CARLA_KEY_OSC_UDP_PORT_NUMBER, self.ui.sb_osc_udp_port_number.value())
  591. # ----------------------------------------------------------------------------------------------------
  592. # Paths
  593. ladspas = []
  594. dssis = []
  595. lv2s = []
  596. vst2s = []
  597. vst3s = []
  598. sf2s = []
  599. sfzs = []
  600. for i in range(self.ui.lw_ladspa.count()):
  601. ladspas.append(self.ui.lw_ladspa.item(i).text())
  602. for i in range(self.ui.lw_dssi.count()):
  603. dssis.append(self.ui.lw_dssi.item(i).text())
  604. for i in range(self.ui.lw_lv2.count()):
  605. lv2s.append(self.ui.lw_lv2.item(i).text())
  606. for i in range(self.ui.lw_vst.count()):
  607. vst2s.append(self.ui.lw_vst.item(i).text())
  608. for i in range(self.ui.lw_vst3.count()):
  609. vst3s.append(self.ui.lw_vst3.item(i).text())
  610. for i in range(self.ui.lw_sf2.count()):
  611. sf2s.append(self.ui.lw_sf2.item(i).text())
  612. for i in range(self.ui.lw_sfz.count()):
  613. sfzs.append(self.ui.lw_sfz.item(i).text())
  614. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(ladspas))
  615. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(dssis))
  616. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(lv2s))
  617. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST2, splitter.join(vst2s))
  618. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(vst3s))
  619. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(sf2s))
  620. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(sfzs))
  621. settings.setValue(CARLA_KEY_PATHS_LADSPA, ladspas)
  622. settings.setValue(CARLA_KEY_PATHS_DSSI, dssis)
  623. settings.setValue(CARLA_KEY_PATHS_LV2, lv2s)
  624. settings.setValue(CARLA_KEY_PATHS_VST2, vst2s)
  625. settings.setValue(CARLA_KEY_PATHS_VST3, vst3s)
  626. settings.setValue(CARLA_KEY_PATHS_SF2, sf2s)
  627. settings.setValue(CARLA_KEY_PATHS_SFZ, sfzs)
  628. # ----------------------------------------------------------------------------------------------------
  629. # Wine
  630. settings.setValue(CARLA_KEY_WINE_EXECUTABLE, self.ui.le_wine_exec.text())
  631. settings.setValue(CARLA_KEY_WINE_AUTO_PREFIX, self.ui.cb_wine_prefix_detect.isChecked())
  632. settings.setValue(CARLA_KEY_WINE_FALLBACK_PREFIX, self.ui.le_wine_prefix_fallback.text())
  633. settings.setValue(CARLA_KEY_WINE_RT_PRIO_ENABLED, self.ui.group_wine_realtime.isChecked())
  634. settings.setValue(CARLA_KEY_WINE_BASE_RT_PRIO, self.ui.sb_wine_base_prio.value())
  635. settings.setValue(CARLA_KEY_WINE_SERVER_RT_PRIO, self.ui.sb_wine_server_prio.value())
  636. # ----------------------------------------------------------------------------------------------------
  637. # Experimental
  638. settings.setValue(CARLA_KEY_EXPERIMENTAL_JACK_APPS, self.ui.ch_exp_jack_apps.isChecked())
  639. settings.setValue(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, self.ui.ch_exp_load_lib_global.isChecked())
  640. settings.setValue(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, self.ui.ch_exp_prevent_bad_behaviour.isChecked())
  641. # --------------------------------------------------------------------------------------------------------
  642. @pyqtSlot()
  643. def slot_resetSettings(self):
  644. currentRow = self.ui.lw_page.currentRow()
  645. # ----------------------------------------------------------------------------------------------------
  646. # Main
  647. if currentRow == self.TAB_INDEX_MAIN:
  648. self.ui.le_main_proj_folder.setText(CARLA_DEFAULT_MAIN_PROJECT_FOLDER)
  649. self.ui.ch_main_theme_pro.setChecked(CARLA_DEFAULT_MAIN_USE_PRO_THEME and self.ui.group_main_theme.isEnabled())
  650. self.ui.cb_main_theme_color.setCurrentIndex(self.ui.cb_main_theme_color.findText(CARLA_DEFAULT_MAIN_PRO_THEME_COLOR))
  651. self.ui.sb_main_refresh_interval.setValue(CARLA_DEFAULT_MAIN_REFRESH_INTERVAL)
  652. self.ui.ch_main_confirm_exit.setChecked(CARLA_DEFAULT_MAIN_CONFIRM_EXIT)
  653. self.ui.ch_main_show_logs.setChecked(CARLA_DEFAULT_MAIN_SHOW_LOGS)
  654. # ----------------------------------------------------------------------------------------------------
  655. # Canvas
  656. elif currentRow == self.TAB_INDEX_CANVAS:
  657. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(CARLA_DEFAULT_CANVAS_THEME))
  658. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(CARLA_DEFAULT_CANVAS_SIZE))
  659. self.ui.cb_canvas_bezier_lines.setChecked(CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES)
  660. self.ui.cb_canvas_hide_groups.setChecked(CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS)
  661. self.ui.cb_canvas_auto_select.setChecked(CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS)
  662. self.ui.cb_canvas_eyecandy.setChecked(CARLA_DEFAULT_CANVAS_EYE_CANDY)
  663. self.ui.cb_canvas_render_aa.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_ANTIALIASING
  664. self.ui.cb_canvas_full_repaints.setChecked(CARLA_DEFAULT_CANVAS_FULL_REPAINTS)
  665. # ----------------------------------------------------------------------------------------------------
  666. # Engine
  667. elif currentRow == self.TAB_INDEX_ENGINE:
  668. if not self.host.isPlugin:
  669. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  670. if not self.host.processModeForced:
  671. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  672. self.ui.cb_engine_process_mode_jack.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE)
  673. self.ui.sw_engine_process_mode.setCurrentIndex(0) # show all modes
  674. else:
  675. self.ui.cb_engine_process_mode_other.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE-self.PROCESS_MODE_NON_JACK_PADDING)
  676. self.ui.sw_engine_process_mode.setCurrentIndex(1) # hide single+multi client modes
  677. self.ui.sb_engine_max_params.setValue(CARLA_DEFAULT_MAX_PARAMETERS)
  678. self.ui.ch_engine_uis_always_on_top.setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP)
  679. self.ui.ch_engine_prefer_ui_bridges.setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES)
  680. self.ui.sb_engine_ui_bridges_timeout.setValue(CARLA_DEFAULT_UI_BRIDGES_TIMEOUT)
  681. self.ui.ch_engine_manage_uis.setChecked(CARLA_DEFAULT_MANAGE_UIS)
  682. # ----------------------------------------------------------------------------------------------------
  683. # OSC
  684. elif currentRow == self.TAB_INDEX_OSC:
  685. self.ui.ch_osc_enable.setChecked(CARLA_DEFAULT_OSC_ENABLED)
  686. self.ui.group_osc_tcp_port.setChecked(CARLA_DEFAULT_OSC_TCP_PORT_ENABLED)
  687. self.ui.group_osc_udp_port.setChecked(CARLA_DEFAULT_OSC_UDP_PORT_ENABLED)
  688. self.ui.sb_osc_tcp_port_number.setValue(CARLA_DEFAULT_OSC_TCP_PORT_NUMBER)
  689. self.ui.sb_osc_udp_port_number.setValue(CARLA_DEFAULT_OSC_UDP_PORT_NUMBER)
  690. if CARLA_DEFAULT_OSC_TCP_PORT_RANDOM:
  691. self.ui.rb_osc_tcp_port_specific.setChecked(False)
  692. self.ui.rb_osc_tcp_port_random.setChecked(True)
  693. else:
  694. self.ui.rb_osc_tcp_port_random.setChecked(False)
  695. self.ui.rb_osc_tcp_port_specific.setChecked(True)
  696. if CARLA_DEFAULT_OSC_UDP_PORT_RANDOM:
  697. self.ui.rb_osc_udp_port_specific.setChecked(False)
  698. self.ui.rb_osc_udp_port_random.setChecked(True)
  699. else:
  700. self.ui.rb_osc_udp_port_random.setChecked(False)
  701. self.ui.rb_osc_udp_port_specific.setChecked(True)
  702. # ----------------------------------------------------------------------------------------------------
  703. # Paths
  704. elif currentRow == self.TAB_INDEX_PATHS:
  705. curIndex = self.ui.tw_paths.currentIndex()
  706. if curIndex == self.PATH_INDEX_LADSPA:
  707. paths = CARLA_DEFAULT_LADSPA_PATH
  708. paths.sort()
  709. self.ui.lw_ladspa.clear()
  710. for path in paths:
  711. if not path: continue
  712. self.ui.lw_ladspa.addItem(path)
  713. elif curIndex == self.PATH_INDEX_DSSI:
  714. paths = CARLA_DEFAULT_DSSI_PATH
  715. paths.sort()
  716. self.ui.lw_dssi.clear()
  717. for path in paths:
  718. if not path: continue
  719. self.ui.lw_dssi.addItem(path)
  720. elif curIndex == self.PATH_INDEX_LV2:
  721. paths = CARLA_DEFAULT_LV2_PATH
  722. paths.sort()
  723. self.ui.lw_lv2.clear()
  724. for path in paths:
  725. if not path: continue
  726. self.ui.lw_lv2.addItem(path)
  727. elif curIndex == self.PATH_INDEX_VST2:
  728. paths = CARLA_DEFAULT_VST2_PATH
  729. paths.sort()
  730. self.ui.lw_vst.clear()
  731. for path in paths:
  732. if not path: continue
  733. self.ui.lw_vst.addItem(path)
  734. elif curIndex == self.PATH_INDEX_VST3:
  735. paths = CARLA_DEFAULT_VST3_PATH
  736. paths.sort()
  737. self.ui.lw_vst3.clear()
  738. for path in paths:
  739. if not path: continue
  740. self.ui.lw_vst3.addItem(path)
  741. elif curIndex == self.PATH_INDEX_SF2:
  742. paths = CARLA_DEFAULT_SF2_PATH
  743. paths.sort()
  744. self.ui.lw_sf2.clear()
  745. for path in paths:
  746. if not path: continue
  747. self.ui.lw_sf2.addItem(path)
  748. elif curIndex == self.PATH_INDEX_SFZ:
  749. paths = CARLA_DEFAULT_SFZ_PATH
  750. paths.sort()
  751. self.ui.lw_sfz.clear()
  752. for path in paths:
  753. if not path: continue
  754. self.ui.lw_sfz.addItem(path)
  755. # ----------------------------------------------------------------------------------------------------
  756. # Wine
  757. elif currentRow == self.TAB_INDEX_WINE:
  758. self.ui.le_wine_exec.setText(CARLA_DEFAULT_WINE_EXECUTABLE)
  759. self.ui.cb_wine_prefix_detect.setChecked(CARLA_DEFAULT_WINE_AUTO_PREFIX)
  760. self.ui.le_wine_prefix_fallback.setText(CARLA_DEFAULT_WINE_FALLBACK_PREFIX)
  761. self.ui.group_wine_realtime.setChecked(CARLA_DEFAULT_WINE_RT_PRIO_ENABLED)
  762. self.ui.sb_wine_base_prio.setValue(CARLA_DEFAULT_WINE_BASE_RT_PRIO)
  763. self.ui.sb_wine_server_prio.setValue(CARLA_DEFAULT_WINE_SERVER_RT_PRIO)
  764. # ----------------------------------------------------------------------------------------------------
  765. # Experimental
  766. elif currentRow == self.TAB_INDEX_EXPERIMENTAL:
  767. self.resetExperimentalSettings()
  768. def resetExperimentalSettings(self):
  769. # Forever experimental
  770. self.ui.cb_exp_plugin_bridges.setChecked(CARLA_DEFAULT_EXPERIMENTAL_PLUGIN_BRIDGES)
  771. self.ui.ch_exp_wine_bridges.setChecked(CARLA_DEFAULT_EXPERIMENTAL_WINE_BRIDGES)
  772. self.ui.ch_exp_jack_apps.setChecked(CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS)
  773. self.ui.ch_exp_export_lv2.setChecked(CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT)
  774. self.ui.ch_exp_load_lib_global.setChecked(CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL)
  775. self.ui.ch_exp_prevent_bad_behaviour.setChecked(CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR)
  776. # Temporary, until stable
  777. self.ui.cb_canvas_fancy_eyecandy.setChecked(CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY)
  778. self.ui.cb_canvas_use_opengl.setChecked(CARLA_DEFAULT_CANVAS_USE_OPENGL and self.ui.cb_canvas_use_opengl.isEnabled())
  779. self.ui.cb_canvas_render_hq_aa.setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and self.ui.cb_canvas_render_hq_aa.isEnabled())
  780. self.ui.cb_canvas_inline_displays.setChecked(CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS)
  781. self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO)
  782. self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES)
  783. # --------------------------------------------------------------------------------------------------------
  784. @pyqtSlot(bool)
  785. def slot_enableExperimental(self, toggled):
  786. if toggled:
  787. self.ui.lw_page.showRow(self.TAB_INDEX_EXPERIMENTAL)
  788. if self.ui.ch_exp_wine_bridges.isChecked() and not self.host.isControl:
  789. self.ui.lw_page.showRow(self.TAB_INDEX_WINE)
  790. else:
  791. self.ui.lw_page.hideRow(self.TAB_INDEX_EXPERIMENTAL)
  792. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  793. @pyqtSlot(bool)
  794. def slot_enableWineBridges(self, toggled):
  795. if toggled and not self.host.isControl:
  796. self.ui.lw_page.showRow(self.TAB_INDEX_WINE)
  797. else:
  798. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  799. @pyqtSlot(bool)
  800. def slot_pluginBridgesToggled(self, toggled):
  801. if not toggled:
  802. self.ui.ch_exp_wine_bridges.setChecked(False)
  803. self.ui.ch_engine_prefer_plugin_bridges.setChecked(False)
  804. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  805. @pyqtSlot(bool)
  806. def slot_canvasEyeCandyToggled(self, toggled):
  807. if not toggled:
  808. # disable fancy eyecandy too
  809. self.ui.cb_canvas_fancy_eyecandy.setChecked(False)
  810. @pyqtSlot(bool)
  811. def slot_canvasFancyEyeCandyToggled(self, toggled):
  812. if toggled:
  813. # make sure normal eyecandy is enabled too
  814. self.ui.cb_canvas_eyecandy.setChecked(True)
  815. @pyqtSlot(bool)
  816. def slot_canvasOpenGLToggled(self, toggled):
  817. if not toggled:
  818. # uncheck GL specific option
  819. self.ui.cb_canvas_render_hq_aa.setChecked(False)
  820. # --------------------------------------------------------------------------------------------------------
  821. @pyqtSlot()
  822. def slot_getAndSetProjectPath(self):
  823. # FIXME
  824. getAndSetPath(self, self.ui.le_main_proj_folder)
  825. # --------------------------------------------------------------------------------------------------------
  826. @pyqtSlot()
  827. def slot_engineAudioDriverChanged(self):
  828. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  829. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  830. else:
  831. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  832. @pyqtSlot()
  833. def slot_showAudioDriverSettings(self):
  834. driverIndex = self.ui.cb_engine_audio_driver.currentIndex()
  835. driverName = self.ui.cb_engine_audio_driver.currentText()
  836. DriverSettingsW(self, self.host, driverIndex, driverName).exec_()
  837. # --------------------------------------------------------------------------------------------------------
  838. @pyqtSlot()
  839. def slot_addPluginPath(self):
  840. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  841. if not newPath:
  842. return
  843. curIndex = self.ui.tw_paths.currentIndex()
  844. if curIndex == self.PATH_INDEX_LADSPA:
  845. self.ui.lw_ladspa.addItem(newPath)
  846. elif curIndex == self.PATH_INDEX_DSSI:
  847. self.ui.lw_dssi.addItem(newPath)
  848. elif curIndex == self.PATH_INDEX_LV2:
  849. self.ui.lw_lv2.addItem(newPath)
  850. elif curIndex == self.PATH_INDEX_VST2:
  851. self.ui.lw_vst.addItem(newPath)
  852. elif curIndex == self.PATH_INDEX_VST3:
  853. self.ui.lw_vst3.addItem(newPath)
  854. elif curIndex == self.PATH_INDEX_SF2:
  855. self.ui.lw_sf2.addItem(newPath)
  856. elif curIndex == self.PATH_INDEX_SFZ:
  857. self.ui.lw_sfz.addItem(newPath)
  858. @pyqtSlot()
  859. def slot_removePluginPath(self):
  860. curIndex = self.ui.tw_paths.currentIndex()
  861. if curIndex == self.PATH_INDEX_LADSPA:
  862. self.ui.lw_ladspa.takeItem(self.ui.lw_ladspa.currentRow())
  863. elif curIndex == self.PATH_INDEX_DSSI:
  864. self.ui.lw_dssi.takeItem(self.ui.lw_dssi.currentRow())
  865. elif curIndex == self.PATH_INDEX_LV2:
  866. self.ui.lw_lv2.takeItem(self.ui.lw_lv2.currentRow())
  867. elif curIndex == self.PATH_INDEX_VST2:
  868. self.ui.lw_vst.takeItem(self.ui.lw_vst.currentRow())
  869. elif curIndex == self.PATH_INDEX_VST3:
  870. self.ui.lw_vst3.takeItem(self.ui.lw_vst3.currentRow())
  871. elif curIndex == self.PATH_INDEX_SF2:
  872. self.ui.lw_sf2.takeItem(self.ui.lw_sf2.currentRow())
  873. elif curIndex == self.PATH_INDEX_SFZ:
  874. self.ui.lw_sfz.takeItem(self.ui.lw_sfz.currentRow())
  875. @pyqtSlot()
  876. def slot_changePluginPath(self):
  877. curIndex = self.ui.tw_paths.currentIndex()
  878. if curIndex == self.PATH_INDEX_LADSPA:
  879. currentPath = self.ui.lw_ladspa.currentItem().text()
  880. elif curIndex == self.PATH_INDEX_DSSI:
  881. currentPath = self.ui.lw_dssi.currentItem().text()
  882. elif curIndex == self.PATH_INDEX_LV2:
  883. currentPath = self.ui.lw_lv2.currentItem().text()
  884. elif curIndex == self.PATH_INDEX_VST2:
  885. currentPath = self.ui.lw_vst.currentItem().text()
  886. elif curIndex == self.PATH_INDEX_VST3:
  887. currentPath = self.ui.lw_vst3.currentItem().text()
  888. elif curIndex == self.PATH_INDEX_SF2:
  889. currentPath = self.ui.lw_sf2.currentItem().text()
  890. elif curIndex == self.PATH_INDEX_SFZ:
  891. currentPath = self.ui.lw_sfz.currentItem().text()
  892. else:
  893. currentPath = ""
  894. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  895. if not newPath:
  896. return
  897. if curIndex == self.PATH_INDEX_LADSPA:
  898. self.ui.lw_ladspa.currentItem().setText(newPath)
  899. elif curIndex == self.PATH_INDEX_DSSI:
  900. self.ui.lw_dssi.currentItem().setText(newPath)
  901. elif curIndex == self.PATH_INDEX_LV2:
  902. self.ui.lw_lv2.currentItem().setText(newPath)
  903. elif curIndex == self.PATH_INDEX_VST2:
  904. self.ui.lw_vst.currentItem().setText(newPath)
  905. elif curIndex == self.PATH_INDEX_VST3:
  906. self.ui.lw_vst3.currentItem().setText(newPath)
  907. elif curIndex == self.PATH_INDEX_SF2:
  908. self.ui.lw_sf2.currentItem().setText(newPath)
  909. elif curIndex == self.PATH_INDEX_SFZ:
  910. self.ui.lw_sfz.currentItem().setText(newPath)
  911. # --------------------------------------------------------------------------------------------------------
  912. @pyqtSlot(int)
  913. def slot_pluginPathTabChanged(self, index):
  914. if index == self.PATH_INDEX_LADSPA:
  915. row = self.ui.lw_ladspa.currentRow()
  916. elif index == self.PATH_INDEX_DSSI:
  917. row = self.ui.lw_dssi.currentRow()
  918. elif index == self.PATH_INDEX_LV2:
  919. row = self.ui.lw_lv2.currentRow()
  920. elif index == self.PATH_INDEX_VST2:
  921. row = self.ui.lw_vst.currentRow()
  922. elif index == self.PATH_INDEX_VST3:
  923. row = self.ui.lw_vst3.currentRow()
  924. elif index == self.PATH_INDEX_SF2:
  925. row = self.ui.lw_sf2.currentRow()
  926. elif index == self.PATH_INDEX_SFZ:
  927. row = self.ui.lw_sfz.currentRow()
  928. else:
  929. row = -1
  930. check = bool(row >= 0)
  931. self.ui.b_paths_remove.setEnabled(check)
  932. self.ui.b_paths_change.setEnabled(check)
  933. @pyqtSlot(int)
  934. def slot_pluginPathRowChanged(self, row):
  935. check = bool(row >= 0)
  936. self.ui.b_paths_remove.setEnabled(check)
  937. self.ui.b_paths_change.setEnabled(check)
  938. # --------------------------------------------------------------------------------------------------------
  939. def done(self, r):
  940. QDialog.done(self, r)
  941. self.close()
  942. # ------------------------------------------------------------------------------------------------------------
  943. # Main
  944. if __name__ == '__main__':
  945. from carla_app import CarlaApplication
  946. from carla_host import initHost, loadHostSettings
  947. initName, libPrefix = handleInitialCommandLineArguments(__file__ if "__file__" in dir() else None)
  948. app = CarlaApplication("Carla2-Settings", libPrefix)
  949. host = initHost("Carla2-Settings", libPrefix, False, False, False)
  950. loadHostSettings(host)
  951. gui = CarlaSettingsW(None, host, True, True)
  952. gui.show()
  953. app.exit_exec()
  954. # ------------------------------------------------------------------------------------------------------------