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.

1121 lines
53KB

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