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.

1578 lines
69KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla settings code
  4. # Copyright (C) 2011-2021 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 (PyQt5)
  19. from PyQt5.QtCore import pyqtSlot, QT_VERSION, Qt
  20. from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFileDialog
  21. # ---------------------------------------------------------------------------------------------------------------------
  22. # Imports (Custom)
  23. import ui_carla_settings
  24. import ui_carla_settings_driver
  25. from carla_backend import (
  26. LINUX, MACOS, WINDOWS,
  27. ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL,
  28. ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER,
  29. ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE,
  30. ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE,
  31. ENGINE_PROCESS_MODE_CONTINUOUS_RACK,
  32. ENGINE_OPTION_FILE_PATH,
  33. ENGINE_OPTION_PLUGIN_PATH,
  34. FILE_AUDIO,
  35. FILE_MIDI,
  36. PLUGIN_LADSPA,
  37. PLUGIN_DSSI,
  38. PLUGIN_LV2,
  39. PLUGIN_VST2,
  40. PLUGIN_VST3,
  41. PLUGIN_SF2,
  42. PLUGIN_SFZ
  43. )
  44. from carla_shared import (
  45. CARLA_KEY_MAIN_PROJECT_FOLDER,
  46. CARLA_KEY_MAIN_USE_PRO_THEME,
  47. CARLA_KEY_MAIN_PRO_THEME_COLOR,
  48. CARLA_KEY_MAIN_REFRESH_INTERVAL,
  49. CARLA_KEY_MAIN_CONFIRM_EXIT,
  50. CARLA_KEY_MAIN_SHOW_LOGS,
  51. CARLA_KEY_MAIN_SYSTEM_ICONS,
  52. CARLA_KEY_MAIN_EXPERIMENTAL,
  53. CARLA_KEY_CANVAS_THEME,
  54. CARLA_KEY_CANVAS_SIZE,
  55. CARLA_KEY_CANVAS_USE_BEZIER_LINES,
  56. CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS,
  57. CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS,
  58. CARLA_KEY_CANVAS_EYE_CANDY,
  59. CARLA_KEY_CANVAS_FANCY_EYE_CANDY,
  60. CARLA_KEY_CANVAS_USE_OPENGL,
  61. CARLA_KEY_CANVAS_ANTIALIASING,
  62. CARLA_KEY_CANVAS_HQ_ANTIALIASING,
  63. CARLA_KEY_CANVAS_INLINE_DISPLAYS,
  64. CARLA_KEY_CANVAS_FULL_REPAINTS,
  65. CARLA_KEY_ENGINE_DRIVER_PREFIX,
  66. CARLA_KEY_ENGINE_AUDIO_DRIVER,
  67. CARLA_KEY_ENGINE_PROCESS_MODE,
  68. CARLA_KEY_ENGINE_FORCE_STEREO,
  69. CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES,
  70. CARLA_KEY_ENGINE_PREFER_UI_BRIDGES,
  71. CARLA_KEY_ENGINE_MANAGE_UIS,
  72. CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP,
  73. CARLA_KEY_ENGINE_MAX_PARAMETERS,
  74. CARLA_KEY_ENGINE_RESET_XRUNS,
  75. CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT,
  76. CARLA_KEY_OSC_ENABLED,
  77. CARLA_KEY_OSC_TCP_PORT_ENABLED,
  78. CARLA_KEY_OSC_TCP_PORT_NUMBER,
  79. CARLA_KEY_OSC_TCP_PORT_RANDOM,
  80. CARLA_KEY_OSC_UDP_PORT_ENABLED,
  81. CARLA_KEY_OSC_UDP_PORT_NUMBER,
  82. CARLA_KEY_OSC_UDP_PORT_RANDOM,
  83. CARLA_KEY_PATHS_AUDIO,
  84. CARLA_KEY_PATHS_MIDI,
  85. CARLA_KEY_PATHS_LADSPA,
  86. CARLA_KEY_PATHS_DSSI,
  87. CARLA_KEY_PATHS_LV2,
  88. CARLA_KEY_PATHS_VST2,
  89. CARLA_KEY_PATHS_VST3,
  90. CARLA_KEY_PATHS_SF2,
  91. CARLA_KEY_PATHS_SFZ,
  92. CARLA_KEY_WINE_EXECUTABLE,
  93. CARLA_KEY_WINE_AUTO_PREFIX,
  94. CARLA_KEY_WINE_FALLBACK_PREFIX,
  95. CARLA_KEY_WINE_RT_PRIO_ENABLED,
  96. CARLA_KEY_WINE_BASE_RT_PRIO,
  97. CARLA_KEY_WINE_SERVER_RT_PRIO,
  98. CARLA_KEY_EXPERIMENTAL_PLUGIN_BRIDGES,
  99. CARLA_KEY_EXPERIMENTAL_WINE_BRIDGES,
  100. CARLA_KEY_EXPERIMENTAL_JACK_APPS,
  101. CARLA_KEY_EXPERIMENTAL_EXPORT_LV2,
  102. CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  103. CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL,
  104. CARLA_DEFAULT_MAIN_PROJECT_FOLDER,
  105. CARLA_DEFAULT_MAIN_USE_PRO_THEME,
  106. CARLA_DEFAULT_MAIN_PRO_THEME_COLOR,
  107. CARLA_DEFAULT_MAIN_REFRESH_INTERVAL,
  108. CARLA_DEFAULT_MAIN_CONFIRM_EXIT,
  109. CARLA_DEFAULT_MAIN_SHOW_LOGS,
  110. CARLA_DEFAULT_MAIN_SYSTEM_ICONS,
  111. #CARLA_DEFAULT_MAIN_EXPERIMENTAL,
  112. CARLA_DEFAULT_CANVAS_THEME,
  113. CARLA_DEFAULT_CANVAS_SIZE,
  114. CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES,
  115. CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS,
  116. CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS,
  117. CARLA_DEFAULT_CANVAS_EYE_CANDY,
  118. CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY,
  119. CARLA_DEFAULT_CANVAS_USE_OPENGL,
  120. CARLA_DEFAULT_CANVAS_ANTIALIASING,
  121. CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING,
  122. CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS,
  123. CARLA_DEFAULT_CANVAS_FULL_REPAINTS,
  124. CARLA_DEFAULT_FORCE_STEREO,
  125. CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES,
  126. CARLA_DEFAULT_PREFER_UI_BRIDGES,
  127. CARLA_DEFAULT_MANAGE_UIS,
  128. CARLA_DEFAULT_UIS_ALWAYS_ON_TOP,
  129. CARLA_DEFAULT_MAX_PARAMETERS,
  130. CARLA_DEFAULT_RESET_XRUNS,
  131. CARLA_DEFAULT_UI_BRIDGES_TIMEOUT,
  132. CARLA_DEFAULT_AUDIO_BUFFER_SIZE,
  133. CARLA_DEFAULT_AUDIO_SAMPLE_RATE,
  134. CARLA_DEFAULT_AUDIO_TRIPLE_BUFFER,
  135. CARLA_DEFAULT_AUDIO_DRIVER,
  136. CARLA_DEFAULT_PROCESS_MODE,
  137. CARLA_DEFAULT_OSC_ENABLED,
  138. CARLA_DEFAULT_OSC_TCP_PORT_ENABLED,
  139. CARLA_DEFAULT_OSC_TCP_PORT_NUMBER,
  140. CARLA_DEFAULT_OSC_TCP_PORT_RANDOM,
  141. CARLA_DEFAULT_OSC_UDP_PORT_ENABLED,
  142. CARLA_DEFAULT_OSC_UDP_PORT_NUMBER,
  143. CARLA_DEFAULT_OSC_UDP_PORT_RANDOM,
  144. CARLA_DEFAULT_WINE_EXECUTABLE,
  145. CARLA_DEFAULT_WINE_AUTO_PREFIX,
  146. CARLA_DEFAULT_WINE_FALLBACK_PREFIX,
  147. CARLA_DEFAULT_WINE_RT_PRIO_ENABLED,
  148. CARLA_DEFAULT_WINE_BASE_RT_PRIO,
  149. CARLA_DEFAULT_WINE_SERVER_RT_PRIO,
  150. CARLA_DEFAULT_EXPERIMENTAL_PLUGIN_BRIDGES,
  151. CARLA_DEFAULT_EXPERIMENTAL_WINE_BRIDGES,
  152. CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS,
  153. CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT,
  154. CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  155. CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL,
  156. CARLA_DEFAULT_FILE_PATH_AUDIO,
  157. CARLA_DEFAULT_FILE_PATH_MIDI,
  158. CARLA_DEFAULT_LADSPA_PATH,
  159. CARLA_DEFAULT_DSSI_PATH,
  160. CARLA_DEFAULT_LV2_PATH,
  161. CARLA_DEFAULT_VST2_PATH,
  162. CARLA_DEFAULT_VST3_PATH,
  163. CARLA_DEFAULT_SF2_PATH,
  164. CARLA_DEFAULT_SFZ_PATH,
  165. getAndSetPath,
  166. getIcon,
  167. fontMetricsHorizontalAdvance,
  168. splitter,
  169. QSafeSettings
  170. )
  171. from patchcanvas.theme import Theme, getThemeName
  172. # ---------------------------------------------------------------------------------------------------------------------
  173. # ...
  174. BUFFER_SIZE_LIST = (16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192)
  175. SAMPLE_RATE_LIST = (22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000)
  176. # ---------------------------------------------------------------------------------------------------------------------
  177. # Driver Settings
  178. class DriverSettingsW(QDialog):
  179. AUTOMATIC_OPTION = "(Auto)"
  180. def __init__(self, parent, host, driverIndex, driverName):
  181. QDialog.__init__(self, parent)
  182. self.host = host
  183. self.ui = ui_carla_settings_driver.Ui_DriverSettingsW()
  184. self.ui.setupUi(self)
  185. # -------------------------------------------------------------------------------------------------------------
  186. # Internal stuff
  187. self.fDriverIndex = driverIndex
  188. self.fDriverName = driverName
  189. self.fDeviceNames = host.get_engine_driver_device_names(driverIndex)
  190. self.fBufferSizes = BUFFER_SIZE_LIST
  191. self.fSampleRates = SAMPLE_RATE_LIST
  192. # -------------------------------------------------------------------------------------------------------------
  193. # Set-up GUI
  194. for name in self.fDeviceNames:
  195. self.ui.cb_device.addItem(name)
  196. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  197. if MACOS:
  198. self.setWindowModality(Qt.WindowModal)
  199. # -------------------------------------------------------------------------------------------------------------
  200. # Load settings
  201. self.loadSettings()
  202. # -------------------------------------------------------------------------------------------------------------
  203. # Set-up connections
  204. self.accepted.connect(self.slot_saveSettings)
  205. self.ui.b_panel.clicked.connect(self.slot_showDevicePanel)
  206. self.ui.cb_device.currentIndexChanged.connect(self.slot_updateDeviceInfo)
  207. # -----------------------------------------------------------------------------------------------------------------
  208. def loadSettings(self):
  209. settings = QSafeSettings("falkTX", "Carla2")
  210. args = (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName)
  211. audioDevice = settings.value("%s%s/Device" % args, "", str)
  212. audioBufferSize = settings.value("%s%s/BufferSize" % args, CARLA_DEFAULT_AUDIO_BUFFER_SIZE, int)
  213. audioSampleRate = settings.value("%s%s/SampleRate" % args, CARLA_DEFAULT_AUDIO_SAMPLE_RATE, int)
  214. audioTripleBuffer = settings.value("%s%s/TripleBuffer" % args, CARLA_DEFAULT_AUDIO_TRIPLE_BUFFER, bool)
  215. if audioDevice and audioDevice in self.fDeviceNames:
  216. self.ui.cb_device.setCurrentIndex(self.fDeviceNames.index(audioDevice))
  217. else:
  218. self.ui.cb_device.setCurrentIndex(-1)
  219. # fill combo-boxes first
  220. self.slot_updateDeviceInfo()
  221. if audioBufferSize and audioBufferSize in self.fBufferSizes:
  222. self.ui.cb_buffersize.setCurrentIndex(self.fBufferSizes.index(audioBufferSize))
  223. elif self.fBufferSizes == BUFFER_SIZE_LIST:
  224. self.ui.cb_buffersize.setCurrentIndex(BUFFER_SIZE_LIST.index(CARLA_DEFAULT_AUDIO_BUFFER_SIZE))
  225. else:
  226. self.ui.cb_buffersize.setCurrentIndex(len(self.fBufferSizes)/2)
  227. if audioSampleRate and audioSampleRate in self.fSampleRates:
  228. self.ui.cb_samplerate.setCurrentIndex(self.fSampleRates.index(audioSampleRate))
  229. elif self.fSampleRates == SAMPLE_RATE_LIST:
  230. self.ui.cb_samplerate.setCurrentIndex(SAMPLE_RATE_LIST.index(CARLA_DEFAULT_AUDIO_SAMPLE_RATE))
  231. else:
  232. self.ui.cb_samplerate.setCurrentIndex(len(self.fSampleRates)/2)
  233. self.ui.cb_triple_buffer.setChecked(audioTripleBuffer and self.ui.cb_triple_buffer.isEnabled())
  234. # -----------------------------------------------------------------------------------------------------------------
  235. @pyqtSlot()
  236. def slot_saveSettings(self):
  237. settings = QSafeSettings("falkTX", "Carla2")
  238. bufferSize = self.ui.cb_buffersize.currentText()
  239. sampleRate = self.ui.cb_samplerate.currentText()
  240. if bufferSize == self.AUTOMATIC_OPTION:
  241. bufferSize = "0"
  242. if sampleRate == self.AUTOMATIC_OPTION:
  243. sampleRate = "0"
  244. args = (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName)
  245. settings.setValue("%s%s/Device" % args, self.ui.cb_device.currentText())
  246. settings.setValue("%s%s/BufferSize" % args, bufferSize)
  247. settings.setValue("%s%s/SampleRate" % args, sampleRate)
  248. settings.setValue("%s%s/TripleBuffer" % args, self.ui.cb_triple_buffer.isChecked())
  249. # -----------------------------------------------------------------------------------------------------------------
  250. @pyqtSlot()
  251. def slot_showDevicePanel(self):
  252. self.host.show_engine_driver_device_control_panel(self.fDriverIndex, self.ui.cb_device.currentText())
  253. @pyqtSlot()
  254. def slot_updateDeviceInfo(self):
  255. deviceName = self.ui.cb_device.currentText()
  256. oldBufferSize = self.ui.cb_buffersize.currentText()
  257. oldSampleRate = self.ui.cb_samplerate.currentText()
  258. self.ui.cb_buffersize.clear()
  259. self.ui.cb_samplerate.clear()
  260. driverDeviceInfo = self.host.get_engine_driver_device_info(self.fDriverIndex, deviceName)
  261. driverDeviceHints = driverDeviceInfo['hints']
  262. self.fBufferSizes = driverDeviceInfo['bufferSizes']
  263. self.fSampleRates = driverDeviceInfo['sampleRates']
  264. if driverDeviceHints & ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER:
  265. self.ui.cb_triple_buffer.setEnabled(True)
  266. else:
  267. self.ui.cb_triple_buffer.setEnabled(False)
  268. if driverDeviceHints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL:
  269. self.ui.b_panel.setEnabled(True)
  270. else:
  271. self.ui.b_panel.setEnabled(False)
  272. if self.fBufferSizes:
  273. for bsize in self.fBufferSizes:
  274. sbsize = str(bsize)
  275. self.ui.cb_buffersize.addItem(sbsize)
  276. if oldBufferSize == sbsize:
  277. self.ui.cb_buffersize.setCurrentIndex(self.ui.cb_buffersize.count()-1)
  278. else:
  279. self.ui.cb_buffersize.addItem(self.AUTOMATIC_OPTION)
  280. self.ui.cb_buffersize.setCurrentIndex(0)
  281. if self.fSampleRates:
  282. for srate in self.fSampleRates:
  283. ssrate = str(int(srate))
  284. self.ui.cb_samplerate.addItem(ssrate)
  285. if oldSampleRate == ssrate:
  286. self.ui.cb_samplerate.setCurrentIndex(self.ui.cb_samplerate.count()-1)
  287. else:
  288. self.ui.cb_samplerate.addItem(self.AUTOMATIC_OPTION)
  289. self.ui.cb_samplerate.setCurrentIndex(0)
  290. # ---------------------------------------------------------------------------------------------------------------------
  291. # Runtime Driver Settings
  292. class RuntimeDriverSettingsW(QDialog):
  293. def __init__(self, parent, host):
  294. QDialog.__init__(self, parent)
  295. self.host = host
  296. self.ui = ui_carla_settings_driver.Ui_DriverSettingsW()
  297. self.ui.setupUi(self)
  298. driverDeviceInfo = host.get_runtime_engine_driver_device_info()
  299. # -------------------------------------------------------------------------------------------------------------
  300. # Set-up GUI
  301. self.ui.cb_device.clear()
  302. self.ui.cb_buffersize.clear()
  303. self.ui.cb_samplerate.clear()
  304. self.ui.cb_triple_buffer.hide()
  305. self.ui.ico_restart.hide()
  306. self.ui.label_restart.hide()
  307. self.ui.layout_triple_buffer.takeAt(2)
  308. self.ui.layout_triple_buffer.takeAt(1)
  309. self.ui.layout_triple_buffer.takeAt(0)
  310. self.ui.verticalLayout.removeItem(self.ui.layout_triple_buffer)
  311. self.ui.layout_restart.takeAt(3)
  312. self.ui.layout_restart.takeAt(2)
  313. self.ui.layout_restart.takeAt(1)
  314. self.ui.layout_restart.takeAt(0)
  315. self.ui.verticalLayout.removeItem(self.ui.layout_restart)
  316. self.adjustSize()
  317. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  318. if MACOS:
  319. self.setWindowModality(Qt.WindowModal)
  320. # -------------------------------------------------------------------------------------------------------------
  321. # Load runtime settings
  322. if host.is_engine_running():
  323. self.ui.cb_device.addItem(driverDeviceInfo['name'])
  324. self.ui.cb_device.setCurrentIndex(0)
  325. self.ui.cb_device.setEnabled(False)
  326. else:
  327. self.ui.cb_device.addItem(driverDeviceInfo['name'])
  328. self.ui.cb_device.setCurrentIndex(0)
  329. if driverDeviceInfo['bufferSizes']:
  330. for bsize in driverDeviceInfo['bufferSizes']:
  331. sbsize = str(bsize)
  332. self.ui.cb_buffersize.addItem(sbsize)
  333. if driverDeviceInfo['bufferSize'] == bsize:
  334. self.ui.cb_buffersize.setCurrentIndex(self.ui.cb_buffersize.count()-1)
  335. else:
  336. self.ui.cb_buffersize.addItem(DriverSettingsW.AUTOMATIC_OPTION)
  337. self.ui.cb_buffersize.setCurrentIndex(0)
  338. if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE) == 0x0:
  339. self.ui.cb_buffersize.setEnabled(False)
  340. if driverDeviceInfo['sampleRates']:
  341. for srate in driverDeviceInfo['sampleRates']:
  342. ssrate = str(int(srate))
  343. self.ui.cb_samplerate.addItem(ssrate)
  344. if driverDeviceInfo['sampleRate'] == srate:
  345. self.ui.cb_samplerate.setCurrentIndex(self.ui.cb_samplerate.count()-1)
  346. else:
  347. self.ui.cb_samplerate.addItem(DriverSettingsW.AUTOMATIC_OPTION)
  348. self.ui.cb_samplerate.setCurrentIndex(0)
  349. if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE) == 0x0:
  350. self.ui.cb_samplerate.setEnabled(False)
  351. if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL) == 0x0:
  352. self.ui.b_panel.setEnabled(False)
  353. # -------------------------------------------------------------------------------------------------------------
  354. # Set-up connections
  355. self.ui.b_panel.clicked.connect(self.slot_showDevicePanel)
  356. # -----------------------------------------------------------------------------------------------------------------
  357. def getValues(self):
  358. audioDevice = self.ui.cb_buffersize.currentText()
  359. bufferSize = self.ui.cb_buffersize.currentText()
  360. sampleRate = self.ui.cb_samplerate.currentText()
  361. if bufferSize == DriverSettingsW.AUTOMATIC_OPTION:
  362. bufferSize = "0"
  363. if sampleRate == DriverSettingsW.AUTOMATIC_OPTION:
  364. sampleRate = "0"
  365. return (audioDevice, int(bufferSize), int(sampleRate))
  366. # -----------------------------------------------------------------------------------------------------------------
  367. @pyqtSlot()
  368. def slot_showDevicePanel(self):
  369. self.host.show_engine_device_control_panel()
  370. # ---------------------------------------------------------------------------------------------------------------------
  371. # Settings Dialog
  372. class CarlaSettingsW(QDialog):
  373. # Tab indexes
  374. TAB_INDEX_MAIN = 0
  375. TAB_INDEX_CANVAS = 1
  376. TAB_INDEX_ENGINE = 2
  377. TAB_INDEX_OSC = 3
  378. TAB_INDEX_FILEPATHS = 4
  379. TAB_INDEX_PLUGINPATHS = 5
  380. TAB_INDEX_WINE = 6
  381. TAB_INDEX_EXPERIMENTAL = 7
  382. TAB_INDEX_NONE = 8
  383. # File Path indexes
  384. FILEPATH_INDEX_AUDIO = 0
  385. FILEPATH_INDEX_MIDI = 1
  386. # Plugin Path indexes
  387. PLUGINPATH_INDEX_LADSPA = 0
  388. PLUGINPATH_INDEX_DSSI = 1
  389. PLUGINPATH_INDEX_LV2 = 2
  390. PLUGINPATH_INDEX_VST2 = 3
  391. PLUGINPATH_INDEX_VST3 = 4
  392. PLUGINPATH_INDEX_SF2 = 5
  393. PLUGINPATH_INDEX_SFZ = 6
  394. # Single and Multiple client mode is only for JACK,
  395. # but we still want to match QComboBox index to backend defines,
  396. # so add +2 pos padding if driverName != "JACK".
  397. PROCESS_MODE_NON_JACK_PADDING = 2
  398. # -----------------------------------------------------------------------------------------------------------------
  399. def __init__(self, parent, host, hasCanvas, hasCanvasGL):
  400. QDialog.__init__(self, parent)
  401. self.host = host
  402. self.ui = ui_carla_settings.Ui_CarlaSettingsW()
  403. self.ui.setupUi(self)
  404. # -------------------------------------------------------------------------------------------------------------
  405. # Set-up GUI
  406. self.ui.lw_page.setFixedWidth(48 + 6*3 +
  407. fontMetricsHorizontalAdvance(self.ui.lw_page.fontMetrics(), " Experimental "))
  408. for i in range(host.get_engine_driver_count()):
  409. self.ui.cb_engine_audio_driver.addItem(host.get_engine_driver_name(i))
  410. for i in range(Theme.THEME_MAX):
  411. self.ui.cb_canvas_theme.addItem(getThemeName(i))
  412. if MACOS:
  413. self.ui.group_main_theme.setEnabled(False)
  414. self.ui.group_main_theme.setVisible(False)
  415. if WINDOWS or host.isControl:
  416. self.ui.ch_main_show_logs.setEnabled(False)
  417. self.ui.ch_main_show_logs.setVisible(False)
  418. if host.isControl:
  419. self.ui.lw_page.hideRow(self.TAB_INDEX_ENGINE)
  420. self.ui.lw_page.hideRow(self.TAB_INDEX_FILEPATHS)
  421. self.ui.lw_page.hideRow(self.TAB_INDEX_PLUGINPATHS)
  422. self.ui.ch_exp_export_lv2.hide()
  423. self.ui.group_experimental_engine.hide()
  424. self.ui.cb_canvas_inline_displays.hide()
  425. elif not hasCanvas:
  426. self.ui.lw_page.hideRow(self.TAB_INDEX_CANVAS)
  427. elif not hasCanvasGL:
  428. self.ui.cb_canvas_use_opengl.setEnabled(False)
  429. self.ui.cb_canvas_render_hq_aa.setEnabled(False)
  430. if host.isPlugin:
  431. self.ui.cb_engine_audio_driver.setEnabled(False)
  432. if host.audioDriverForced is not None:
  433. self.ui.cb_engine_audio_driver.setEnabled(False)
  434. self.ui.tb_engine_driver_config.setEnabled(False)
  435. if host.processModeForced:
  436. self.ui.cb_engine_process_mode_jack.setEnabled(False)
  437. self.ui.cb_engine_process_mode_other.setEnabled(False)
  438. if self.host.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
  439. self.ui.ch_engine_force_stereo.setEnabled(False)
  440. if host.isControl or host.isPlugin:
  441. self.ui.ch_main_confirm_exit.hide()
  442. self.ui.ch_exp_load_lib_global.hide()
  443. self.ui.lw_page.hideRow(self.TAB_INDEX_OSC)
  444. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  445. if not LINUX:
  446. self.ui.ch_exp_wine_bridges.setVisible(False)
  447. self.ui.ch_exp_jack_apps.setVisible(False)
  448. self.ui.ch_exp_prevent_bad_behaviour.setVisible(False)
  449. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  450. if not MACOS:
  451. self.ui.label_engine_ui_bridges_mac_note.setVisible(False)
  452. # FIXME, not implemented yet
  453. self.ui.ch_engine_uis_always_on_top.hide()
  454. # FIXME broken in some Qt5 versions
  455. self.ui.cb_canvas_eyecandy.setEnabled(QT_VERSION >= 0x50c00)
  456. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  457. if MACOS:
  458. self.setWindowModality(Qt.WindowModal)
  459. # -------------------------------------------------------------------------------------------------------------
  460. # Load settings
  461. self.loadSettings()
  462. # -------------------------------------------------------------------------------------------------------------
  463. # Set-up Icons
  464. if self.ui.ch_main_system_icons.isChecked():
  465. self.ui.b_main_proj_folder_open.setIcon(getIcon('document-open', 16, 'svgz'))
  466. self.ui.b_filepaths_add.setIcon(getIcon('list-add', 16, 'svgz'))
  467. self.ui.b_filepaths_change.setIcon(getIcon('edit-rename', 16, 'svgz'))
  468. self.ui.b_filepaths_remove.setIcon(getIcon('list-remove', 16, 'svgz'))
  469. self.ui.b_paths_add.setIcon(getIcon('list-add', 16, 'svgz'))
  470. self.ui.b_paths_change.setIcon(getIcon('edit-rename', 16, 'svgz'))
  471. self.ui.b_paths_remove.setIcon(getIcon('list-remove', 16, 'svgz'))
  472. # -------------------------------------------------------------------------------------------------------------
  473. # Set-up connections
  474. self.accepted.connect(self.slot_saveSettings)
  475. self.ui.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self.slot_resetSettings)
  476. self.ui.b_main_proj_folder_open.clicked.connect(self.slot_getAndSetProjectPath)
  477. self.ui.cb_engine_audio_driver.currentIndexChanged.connect(self.slot_engineAudioDriverChanged)
  478. self.ui.tb_engine_driver_config.clicked.connect(self.slot_showAudioDriverSettings)
  479. self.ui.b_paths_add.clicked.connect(self.slot_addPluginPath)
  480. self.ui.b_paths_remove.clicked.connect(self.slot_removePluginPath)
  481. self.ui.b_paths_change.clicked.connect(self.slot_changePluginPath)
  482. self.ui.cb_paths.currentIndexChanged.connect(self.slot_pluginPathTabChanged)
  483. self.ui.lw_ladspa.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  484. self.ui.lw_dssi.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  485. self.ui.lw_lv2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  486. self.ui.lw_vst.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  487. self.ui.lw_vst3.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  488. self.ui.lw_sf2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  489. self.ui.lw_sfz.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  490. self.ui.b_filepaths_add.clicked.connect(self.slot_addFilePath)
  491. self.ui.b_filepaths_remove.clicked.connect(self.slot_removeFilePath)
  492. self.ui.b_filepaths_change.clicked.connect(self.slot_changeFilePath)
  493. self.ui.cb_filepaths.currentIndexChanged.connect(self.slot_filePathTabChanged)
  494. self.ui.lw_files_audio.currentRowChanged.connect(self.slot_filePathRowChanged)
  495. self.ui.lw_files_midi.currentRowChanged.connect(self.slot_filePathRowChanged)
  496. self.ui.ch_main_experimental.toggled.connect(self.slot_enableExperimental)
  497. self.ui.ch_exp_wine_bridges.toggled.connect(self.slot_enableWineBridges)
  498. self.ui.cb_exp_plugin_bridges.toggled.connect(self.slot_pluginBridgesToggled)
  499. self.ui.cb_canvas_eyecandy.toggled.connect(self.slot_canvasEyeCandyToggled)
  500. #self.ui.cb_canvas_fancy_eyecandy.toggled.connect(self.slot_canvasFancyEyeCandyToggled)
  501. self.ui.cb_canvas_use_opengl.toggled.connect(self.slot_canvasOpenGLToggled)
  502. # -------------------------------------------------------------------------------------------------------------
  503. # Post-connect setup
  504. self.ui.lw_ladspa.setCurrentRow(0)
  505. self.ui.lw_dssi.setCurrentRow(0)
  506. self.ui.lw_lv2.setCurrentRow(0)
  507. self.ui.lw_vst.setCurrentRow(0)
  508. self.ui.lw_vst3.setCurrentRow(0)
  509. self.ui.lw_sf2.setCurrentRow(0)
  510. self.ui.lw_sfz.setCurrentRow(0)
  511. self.ui.lw_files_audio.setCurrentRow(0)
  512. self.ui.lw_files_midi.setCurrentRow(0)
  513. self.ui.lw_page.setCurrentCell(0, 0)
  514. self.slot_filePathTabChanged(0)
  515. self.slot_pluginPathTabChanged(0)
  516. self.adjustSize()
  517. # -----------------------------------------------------------------------------------------------------------------
  518. def loadSettings(self):
  519. settings = QSafeSettings()
  520. # -------------------------------------------------------------------------------------------------------------
  521. # Main
  522. self.ui.ch_main_show_logs.setChecked(self.host.showLogs)
  523. self.ui.ch_engine_uis_always_on_top.setChecked(self.host.uisAlwaysOnTop)
  524. self.ui.le_main_proj_folder.setText(
  525. settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, str))
  526. self.ui.ch_main_theme_pro.setChecked(self.ui.group_main_theme.isEnabled() and
  527. settings.value(CARLA_KEY_MAIN_USE_PRO_THEME,
  528. CARLA_DEFAULT_MAIN_USE_PRO_THEME, bool))
  529. self.ui.cb_main_theme_color.setCurrentIndex(
  530. self.ui.cb_main_theme_color.findText(settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR,
  531. CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, str)))
  532. self.ui.sb_main_refresh_interval.setValue(
  533. settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, int))
  534. self.ui.ch_main_confirm_exit.setChecked(
  535. settings.value(CARLA_KEY_MAIN_CONFIRM_EXIT, CARLA_DEFAULT_MAIN_CONFIRM_EXIT, bool))
  536. self.ui.ch_main_system_icons.setChecked(
  537. settings.value(CARLA_KEY_MAIN_SYSTEM_ICONS, CARLA_DEFAULT_MAIN_SYSTEM_ICONS, bool))
  538. # -------------------------------------------------------------------------------------------------------------
  539. # Canvas
  540. self.ui.cb_canvas_theme.setCurrentIndex(
  541. self.ui.cb_canvas_theme.findText(settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, str)))
  542. self.ui.cb_canvas_size.setCurrentIndex(
  543. self.ui.cb_canvas_size.findText(settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, str)))
  544. self.ui.cb_canvas_bezier_lines.setChecked(
  545. settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, bool))
  546. self.ui.cb_canvas_hide_groups.setChecked(
  547. settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, bool))
  548. self.ui.cb_canvas_auto_select.setChecked(
  549. settings.value(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS, bool))
  550. if self.ui.cb_canvas_eyecandy.isEnabled():
  551. self.ui.cb_canvas_eyecandy.setChecked(
  552. settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, bool))
  553. self.ui.cb_canvas_fancy_eyecandy.setChecked(
  554. settings.value(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY, bool))
  555. self.ui.cb_canvas_use_opengl.setChecked(self.ui.cb_canvas_use_opengl.isEnabled() and
  556. settings.value(CARLA_KEY_CANVAS_USE_OPENGL,
  557. CARLA_DEFAULT_CANVAS_USE_OPENGL, bool))
  558. self.ui.cb_canvas_render_aa.setCheckState(
  559. settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, int))
  560. self.ui.cb_canvas_render_hq_aa.setChecked(self.ui.cb_canvas_render_hq_aa.isEnabled() and
  561. settings.value(CARLA_KEY_CANVAS_HQ_ANTIALIASING,
  562. CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING, bool))
  563. self.ui.cb_canvas_full_repaints.setChecked(
  564. settings.value(CARLA_KEY_CANVAS_FULL_REPAINTS, CARLA_DEFAULT_CANVAS_FULL_REPAINTS, bool))
  565. self.ui.cb_canvas_inline_displays.setChecked(
  566. settings.value(CARLA_KEY_CANVAS_INLINE_DISPLAYS, CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS, bool))
  567. # -------------------------------------------------------------------------------------------------------------
  568. settings = QSafeSettings("falkTX", "Carla2")
  569. # -------------------------------------------------------------------------------------------------------------
  570. # Main
  571. self.ui.ch_main_experimental.setChecked(self.host.experimental)
  572. if not self.host.experimental:
  573. self.ui.lw_page.hideRow(self.TAB_INDEX_EXPERIMENTAL)
  574. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  575. elif not self.host.showWineBridges:
  576. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  577. # -------------------------------------------------------------------------------------------------------------
  578. # Engine
  579. if self.host.isPlugin:
  580. audioDriver = "Plugin"
  581. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  582. elif self.host.audioDriverForced:
  583. audioDriver = self.host.audioDriverForced
  584. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  585. else:
  586. audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, str)
  587. for i in range(self.ui.cb_engine_audio_driver.count()):
  588. if self.ui.cb_engine_audio_driver.itemText(i) == audioDriver:
  589. self.ui.cb_engine_audio_driver.setCurrentIndex(i)
  590. break
  591. else:
  592. self.ui.cb_engine_audio_driver.setCurrentIndex(-1)
  593. if audioDriver == "JACK":
  594. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  595. else:
  596. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  597. self.ui.tb_engine_driver_config.setEnabled(self.host.audioDriverForced is None and not self.host.isPlugin)
  598. self.ui.cb_engine_process_mode_jack.setCurrentIndex(self.host.nextProcessMode)
  599. if self.host.nextProcessMode >= self.PROCESS_MODE_NON_JACK_PADDING:
  600. self.ui.cb_engine_process_mode_other.setCurrentIndex(self.host.nextProcessMode -
  601. self.PROCESS_MODE_NON_JACK_PADDING)
  602. else:
  603. self.ui.cb_engine_process_mode_other.setCurrentIndex(0)
  604. self.ui.sb_engine_max_params.setValue(self.host.maxParameters)
  605. self.ui.cb_engine_reset_xruns.setChecked(self.host.resetXruns)
  606. self.ui.ch_engine_manage_uis.setChecked(self.host.manageUIs)
  607. self.ui.ch_engine_prefer_ui_bridges.setChecked(self.host.preferUIBridges)
  608. self.ui.sb_engine_ui_bridges_timeout.setValue(self.host.uiBridgesTimeout)
  609. self.ui.ch_engine_force_stereo.setChecked(self.host.forceStereo or
  610. not self.ui.ch_engine_force_stereo.isEnabled())
  611. self.ui.ch_engine_prefer_plugin_bridges.setChecked(self.host.preferPluginBridges)
  612. self.ui.ch_exp_export_lv2.setChecked(self.host.exportLV2)
  613. self.ui.cb_exp_plugin_bridges.setChecked(self.host.showPluginBridges)
  614. self.ui.ch_exp_wine_bridges.setChecked(self.host.showWineBridges)
  615. # -------------------------------------------------------------------------------------------------------------
  616. # OSC
  617. self.ui.ch_osc_enable.setChecked(
  618. settings.value(CARLA_KEY_OSC_ENABLED, CARLA_DEFAULT_OSC_ENABLED, bool))
  619. self.ui.group_osc_tcp_port.setChecked(
  620. settings.value(CARLA_KEY_OSC_TCP_PORT_ENABLED, CARLA_DEFAULT_OSC_TCP_PORT_ENABLED, bool))
  621. self.ui.group_osc_udp_port.setChecked(
  622. settings.value(CARLA_KEY_OSC_UDP_PORT_ENABLED, CARLA_DEFAULT_OSC_UDP_PORT_ENABLED, bool))
  623. self.ui.sb_osc_tcp_port_number.setValue(
  624. settings.value(CARLA_KEY_OSC_TCP_PORT_NUMBER, CARLA_DEFAULT_OSC_TCP_PORT_NUMBER, int))
  625. self.ui.sb_osc_udp_port_number.setValue(
  626. settings.value(CARLA_KEY_OSC_UDP_PORT_NUMBER, CARLA_DEFAULT_OSC_UDP_PORT_NUMBER, int))
  627. if settings.value(CARLA_KEY_OSC_TCP_PORT_RANDOM, CARLA_DEFAULT_OSC_TCP_PORT_RANDOM, bool):
  628. self.ui.rb_osc_tcp_port_specific.setChecked(False)
  629. self.ui.rb_osc_tcp_port_random.setChecked(True)
  630. else:
  631. self.ui.rb_osc_tcp_port_random.setChecked(False)
  632. self.ui.rb_osc_tcp_port_specific.setChecked(True)
  633. if settings.value(CARLA_KEY_OSC_UDP_PORT_RANDOM, CARLA_DEFAULT_OSC_UDP_PORT_RANDOM, bool):
  634. self.ui.rb_osc_udp_port_specific.setChecked(False)
  635. self.ui.rb_osc_udp_port_random.setChecked(True)
  636. else:
  637. self.ui.rb_osc_udp_port_random.setChecked(False)
  638. self.ui.rb_osc_udp_port_specific.setChecked(True)
  639. # -------------------------------------------------------------------------------------------------------------
  640. # File Paths
  641. audioPaths = settings.value(CARLA_KEY_PATHS_AUDIO, CARLA_DEFAULT_FILE_PATH_AUDIO, list)
  642. midiPaths = settings.value(CARLA_KEY_PATHS_MIDI, CARLA_DEFAULT_FILE_PATH_MIDI, list)
  643. audioPaths.sort()
  644. midiPaths.sort()
  645. for audioPath in audioPaths:
  646. if not audioPath:
  647. continue
  648. self.ui.lw_files_audio.addItem(audioPath)
  649. for midiPath in midiPaths:
  650. if not midiPath:
  651. continue
  652. self.ui.lw_files_midi.addItem(midiPath)
  653. # -------------------------------------------------------------------------------------------------------------
  654. # Plugin Paths
  655. ladspas = settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH, list)
  656. dssis = settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH, list)
  657. lv2s = settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list)
  658. vst2s = settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH, list)
  659. vst3s = settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH, list)
  660. sf2s = settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH, list)
  661. sfzs = settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH, list)
  662. ladspas.sort()
  663. dssis.sort()
  664. lv2s.sort()
  665. vst2s.sort()
  666. vst3s.sort()
  667. sf2s.sort()
  668. sfzs.sort()
  669. for ladspa in ladspas:
  670. if not ladspa:
  671. continue
  672. self.ui.lw_ladspa.addItem(ladspa)
  673. for dssi in dssis:
  674. if not dssi:
  675. continue
  676. self.ui.lw_dssi.addItem(dssi)
  677. for lv2 in lv2s:
  678. if not lv2:
  679. continue
  680. self.ui.lw_lv2.addItem(lv2)
  681. for vst2 in vst2s:
  682. if not vst2:
  683. continue
  684. self.ui.lw_vst.addItem(vst2)
  685. for vst3 in vst3s:
  686. if not vst3:
  687. continue
  688. self.ui.lw_vst3.addItem(vst3)
  689. for sf2 in sf2s:
  690. if not sf2:
  691. continue
  692. self.ui.lw_sf2.addItem(sf2)
  693. for sfz in sfzs:
  694. if not sfz:
  695. continue
  696. self.ui.lw_sfz.addItem(sfz)
  697. # -------------------------------------------------------------------------------------------------------------
  698. # Wine
  699. self.ui.le_wine_exec.setText(
  700. settings.value(CARLA_KEY_WINE_EXECUTABLE, CARLA_DEFAULT_WINE_EXECUTABLE, str))
  701. self.ui.cb_wine_prefix_detect.setChecked(
  702. settings.value(CARLA_KEY_WINE_AUTO_PREFIX, CARLA_DEFAULT_WINE_AUTO_PREFIX, bool))
  703. self.ui.le_wine_prefix_fallback.setText(
  704. settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX, CARLA_DEFAULT_WINE_FALLBACK_PREFIX, str))
  705. self.ui.group_wine_realtime.setChecked(
  706. settings.value(CARLA_KEY_WINE_RT_PRIO_ENABLED, CARLA_DEFAULT_WINE_RT_PRIO_ENABLED, bool))
  707. self.ui.sb_wine_base_prio.setValue(
  708. settings.value(CARLA_KEY_WINE_BASE_RT_PRIO, CARLA_DEFAULT_WINE_BASE_RT_PRIO, int))
  709. self.ui.sb_wine_server_prio.setValue(
  710. settings.value(CARLA_KEY_WINE_SERVER_RT_PRIO, CARLA_DEFAULT_WINE_SERVER_RT_PRIO, int))
  711. # -------------------------------------------------------------------------------------------------------------
  712. # Experimental
  713. self.ui.ch_exp_jack_apps.setChecked(
  714. settings.value(CARLA_KEY_EXPERIMENTAL_JACK_APPS, CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS, bool))
  715. self.ui.ch_exp_export_lv2.setChecked(
  716. settings.value(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2, CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT, bool))
  717. self.ui.ch_exp_load_lib_global.setChecked(
  718. settings.value(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL, bool))
  719. self.ui.ch_exp_prevent_bad_behaviour.setChecked(
  720. settings.value(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  721. CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, bool))
  722. # -----------------------------------------------------------------------------------------------------------------
  723. @pyqtSlot()
  724. def slot_saveSettings(self):
  725. settings = QSafeSettings()
  726. self.host.experimental = self.ui.ch_main_experimental.isChecked()
  727. if not self.host.experimental:
  728. self.resetExperimentalSettings()
  729. # -------------------------------------------------------------------------------------------------------------
  730. # Main
  731. settings.setValue(CARLA_KEY_MAIN_PROJECT_FOLDER, self.ui.le_main_proj_folder.text())
  732. settings.setValue(CARLA_KEY_MAIN_CONFIRM_EXIT, self.ui.ch_main_confirm_exit.isChecked())
  733. settings.setValue(CARLA_KEY_MAIN_USE_PRO_THEME, self.ui.ch_main_theme_pro.isChecked())
  734. settings.setValue(CARLA_KEY_MAIN_PRO_THEME_COLOR, self.ui.cb_main_theme_color.currentText())
  735. settings.setValue(CARLA_KEY_MAIN_REFRESH_INTERVAL, self.ui.sb_main_refresh_interval.value())
  736. settings.setValue(CARLA_KEY_MAIN_SYSTEM_ICONS, self.ui.ch_main_system_icons.isChecked())
  737. # -------------------------------------------------------------------------------------------------------------
  738. # Canvas
  739. settings.setValue(CARLA_KEY_CANVAS_THEME, self.ui.cb_canvas_theme.currentText())
  740. settings.setValue(CARLA_KEY_CANVAS_SIZE, self.ui.cb_canvas_size.currentText())
  741. settings.setValue(CARLA_KEY_CANVAS_USE_BEZIER_LINES, self.ui.cb_canvas_bezier_lines.isChecked())
  742. settings.setValue(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, self.ui.cb_canvas_hide_groups.isChecked())
  743. settings.setValue(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, self.ui.cb_canvas_auto_select.isChecked())
  744. settings.setValue(CARLA_KEY_CANVAS_EYE_CANDY, self.ui.cb_canvas_eyecandy.isChecked())
  745. settings.setValue(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, self.ui.cb_canvas_fancy_eyecandy.isChecked())
  746. settings.setValue(CARLA_KEY_CANVAS_USE_OPENGL, self.ui.cb_canvas_use_opengl.isChecked())
  747. settings.setValue(CARLA_KEY_CANVAS_HQ_ANTIALIASING, self.ui.cb_canvas_render_hq_aa.isChecked())
  748. # NOTE: checkState() 0, 1, 2 match their enum variants
  749. settings.setValue(CARLA_KEY_CANVAS_ANTIALIASING, self.ui.cb_canvas_render_aa.checkState())
  750. settings.setValue(CARLA_KEY_CANVAS_FULL_REPAINTS, self.ui.cb_canvas_full_repaints.isChecked())
  751. settings.setValue(CARLA_KEY_CANVAS_INLINE_DISPLAYS, self.ui.cb_canvas_inline_displays.isChecked())
  752. # -------------------------------------------------------------------------------------------------------------
  753. settings = QSafeSettings("falkTX", "Carla2")
  754. # -------------------------------------------------------------------------------------------------------------
  755. # Main
  756. settings.setValue(CARLA_KEY_MAIN_EXPERIMENTAL, self.host.experimental)
  757. # -------------------------------------------------------------------------------------------------------------
  758. # Engine
  759. audioDriver = self.ui.cb_engine_audio_driver.currentText()
  760. if audioDriver and self.host.audioDriverForced is None and not self.host.isPlugin:
  761. settings.setValue(CARLA_KEY_ENGINE_AUDIO_DRIVER, audioDriver)
  762. if not self.host.processModeForced:
  763. # engine sends callback if processMode really changes
  764. if audioDriver == "JACK":
  765. self.host.nextProcessMode = self.ui.cb_engine_process_mode_jack.currentIndex()
  766. else:
  767. self.host.nextProcessMode = (self.ui.cb_engine_process_mode_other.currentIndex() +
  768. self.PROCESS_MODE_NON_JACK_PADDING)
  769. settings.setValue(CARLA_KEY_ENGINE_PROCESS_MODE, self.host.nextProcessMode)
  770. self.host.exportLV2 = self.ui.ch_exp_export_lv2.isChecked()
  771. self.host.forceStereo = self.ui.ch_engine_force_stereo.isChecked()
  772. self.host.resetXruns = self.ui.cb_engine_reset_xruns.isChecked()
  773. self.host.maxParameters = self.ui.sb_engine_max_params.value()
  774. self.host.manageUIs = self.ui.ch_engine_manage_uis.isChecked()
  775. self.host.preferPluginBridges = self.ui.ch_engine_prefer_plugin_bridges.isChecked()
  776. self.host.preferUIBridges = self.ui.ch_engine_prefer_ui_bridges.isChecked()
  777. self.host.showLogs = self.ui.ch_main_show_logs.isChecked()
  778. self.host.showPluginBridges = self.ui.cb_exp_plugin_bridges.isChecked()
  779. self.host.showWineBridges = self.ui.ch_exp_wine_bridges.isChecked()
  780. self.host.uiBridgesTimeout = self.ui.sb_engine_ui_bridges_timeout.value()
  781. self.host.uisAlwaysOnTop = self.ui.ch_engine_uis_always_on_top.isChecked()
  782. if self.ui.ch_engine_force_stereo.isEnabled():
  783. settings.setValue(CARLA_KEY_ENGINE_FORCE_STEREO, self.host.forceStereo)
  784. settings.setValue(CARLA_KEY_MAIN_SHOW_LOGS, self.host.showLogs)
  785. settings.setValue(CARLA_KEY_ENGINE_MAX_PARAMETERS, self.host.maxParameters)
  786. settings.setValue(CARLA_KEY_ENGINE_RESET_XRUNS, self.host.resetXruns)
  787. settings.setValue(CARLA_KEY_ENGINE_MANAGE_UIS, self.host.manageUIs)
  788. settings.setValue(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, self.host.preferPluginBridges)
  789. settings.setValue(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, self.host.preferUIBridges)
  790. settings.setValue(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, self.host.uiBridgesTimeout)
  791. settings.setValue(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, self.host.uisAlwaysOnTop)
  792. settings.setValue(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2, self.host.exportLV2)
  793. settings.setValue(CARLA_KEY_EXPERIMENTAL_PLUGIN_BRIDGES, self.host.showPluginBridges)
  794. settings.setValue(CARLA_KEY_EXPERIMENTAL_WINE_BRIDGES, self.host.showWineBridges)
  795. # -------------------------------------------------------------------------------------------------------------
  796. # OSC
  797. settings.setValue(CARLA_KEY_OSC_ENABLED, self.ui.ch_osc_enable.isChecked())
  798. settings.setValue(CARLA_KEY_OSC_TCP_PORT_ENABLED, self.ui.group_osc_tcp_port.isChecked())
  799. settings.setValue(CARLA_KEY_OSC_UDP_PORT_ENABLED, self.ui.group_osc_udp_port.isChecked())
  800. settings.setValue(CARLA_KEY_OSC_TCP_PORT_RANDOM, self.ui.rb_osc_tcp_port_random.isChecked())
  801. settings.setValue(CARLA_KEY_OSC_UDP_PORT_RANDOM, self.ui.rb_osc_udp_port_random.isChecked())
  802. settings.setValue(CARLA_KEY_OSC_TCP_PORT_NUMBER, self.ui.sb_osc_tcp_port_number.value())
  803. settings.setValue(CARLA_KEY_OSC_UDP_PORT_NUMBER, self.ui.sb_osc_udp_port_number.value())
  804. # -------------------------------------------------------------------------------------------------------------
  805. # File Paths
  806. audioPaths = []
  807. midiPaths = []
  808. for i in range(self.ui.lw_files_audio.count()):
  809. audioPaths.append(self.ui.lw_files_audio.item(i).text())
  810. for i in range(self.ui.lw_files_midi.count()):
  811. midiPaths.append(self.ui.lw_files_midi.item(i).text())
  812. self.host.set_engine_option(ENGINE_OPTION_FILE_PATH, FILE_AUDIO, splitter.join(audioPaths))
  813. self.host.set_engine_option(ENGINE_OPTION_FILE_PATH, FILE_MIDI, splitter.join(midiPaths))
  814. settings.setValue(CARLA_KEY_PATHS_AUDIO, audioPaths)
  815. settings.setValue(CARLA_KEY_PATHS_MIDI, midiPaths)
  816. # -------------------------------------------------------------------------------------------------------------
  817. # Plugin Paths
  818. ladspas = []
  819. dssis = []
  820. lv2s = []
  821. vst2s = []
  822. vst3s = []
  823. sf2s = []
  824. sfzs = []
  825. for i in range(self.ui.lw_ladspa.count()):
  826. ladspas.append(self.ui.lw_ladspa.item(i).text())
  827. for i in range(self.ui.lw_dssi.count()):
  828. dssis.append(self.ui.lw_dssi.item(i).text())
  829. for i in range(self.ui.lw_lv2.count()):
  830. lv2s.append(self.ui.lw_lv2.item(i).text())
  831. for i in range(self.ui.lw_vst.count()):
  832. vst2s.append(self.ui.lw_vst.item(i).text())
  833. for i in range(self.ui.lw_vst3.count()):
  834. vst3s.append(self.ui.lw_vst3.item(i).text())
  835. for i in range(self.ui.lw_sf2.count()):
  836. sf2s.append(self.ui.lw_sf2.item(i).text())
  837. for i in range(self.ui.lw_sfz.count()):
  838. sfzs.append(self.ui.lw_sfz.item(i).text())
  839. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(ladspas))
  840. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(dssis))
  841. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(lv2s))
  842. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST2, splitter.join(vst2s))
  843. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(vst3s))
  844. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(sf2s))
  845. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(sfzs))
  846. settings.setValue(CARLA_KEY_PATHS_LADSPA, ladspas)
  847. settings.setValue(CARLA_KEY_PATHS_DSSI, dssis)
  848. settings.setValue(CARLA_KEY_PATHS_LV2, lv2s)
  849. settings.setValue(CARLA_KEY_PATHS_VST2, vst2s)
  850. settings.setValue(CARLA_KEY_PATHS_VST3, vst3s)
  851. settings.setValue(CARLA_KEY_PATHS_SF2, sf2s)
  852. settings.setValue(CARLA_KEY_PATHS_SFZ, sfzs)
  853. # -------------------------------------------------------------------------------------------------------------
  854. # Wine
  855. settings.setValue(CARLA_KEY_WINE_EXECUTABLE, self.ui.le_wine_exec.text())
  856. settings.setValue(CARLA_KEY_WINE_AUTO_PREFIX, self.ui.cb_wine_prefix_detect.isChecked())
  857. settings.setValue(CARLA_KEY_WINE_FALLBACK_PREFIX, self.ui.le_wine_prefix_fallback.text())
  858. settings.setValue(CARLA_KEY_WINE_RT_PRIO_ENABLED, self.ui.group_wine_realtime.isChecked())
  859. settings.setValue(CARLA_KEY_WINE_BASE_RT_PRIO, self.ui.sb_wine_base_prio.value())
  860. settings.setValue(CARLA_KEY_WINE_SERVER_RT_PRIO, self.ui.sb_wine_server_prio.value())
  861. # -------------------------------------------------------------------------------------------------------------
  862. # Experimental
  863. settings.setValue(CARLA_KEY_EXPERIMENTAL_JACK_APPS, self.ui.ch_exp_jack_apps.isChecked())
  864. settings.setValue(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, self.ui.ch_exp_load_lib_global.isChecked())
  865. settings.setValue(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  866. self.ui.ch_exp_prevent_bad_behaviour.isChecked())
  867. # -----------------------------------------------------------------------------------------------------------------
  868. @pyqtSlot()
  869. def slot_resetSettings(self):
  870. currentRow = self.ui.lw_page.currentRow()
  871. # -------------------------------------------------------------------------------------------------------------
  872. # Main
  873. if currentRow == self.TAB_INDEX_MAIN:
  874. self.ui.le_main_proj_folder.setText(CARLA_DEFAULT_MAIN_PROJECT_FOLDER)
  875. self.ui.ch_main_theme_pro.setChecked(CARLA_DEFAULT_MAIN_USE_PRO_THEME and
  876. self.ui.group_main_theme.isEnabled())
  877. self.ui.cb_main_theme_color.setCurrentIndex(
  878. self.ui.cb_main_theme_color.findText(CARLA_DEFAULT_MAIN_PRO_THEME_COLOR))
  879. self.ui.sb_main_refresh_interval.setValue(CARLA_DEFAULT_MAIN_REFRESH_INTERVAL)
  880. self.ui.ch_main_confirm_exit.setChecked(CARLA_DEFAULT_MAIN_CONFIRM_EXIT)
  881. self.ui.ch_main_show_logs.setChecked(CARLA_DEFAULT_MAIN_SHOW_LOGS)
  882. # -------------------------------------------------------------------------------------------------------------
  883. # Canvas
  884. elif currentRow == self.TAB_INDEX_CANVAS:
  885. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(CARLA_DEFAULT_CANVAS_THEME))
  886. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(CARLA_DEFAULT_CANVAS_SIZE))
  887. self.ui.cb_canvas_bezier_lines.setChecked(CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES)
  888. self.ui.cb_canvas_hide_groups.setChecked(CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS)
  889. self.ui.cb_canvas_auto_select.setChecked(CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS)
  890. self.ui.cb_canvas_eyecandy.setChecked(CARLA_DEFAULT_CANVAS_EYE_CANDY and self.ui.cb_canvas_eyecandy.isEnabled())
  891. self.ui.cb_canvas_render_aa.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_ANTIALIASING
  892. self.ui.cb_canvas_full_repaints.setChecked(CARLA_DEFAULT_CANVAS_FULL_REPAINTS)
  893. # -------------------------------------------------------------------------------------------------------------
  894. # Engine
  895. elif currentRow == self.TAB_INDEX_ENGINE:
  896. if not self.host.isPlugin:
  897. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  898. if not self.host.processModeForced:
  899. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  900. self.ui.cb_engine_process_mode_jack.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE)
  901. self.ui.sw_engine_process_mode.setCurrentIndex(0) # show all modes
  902. else:
  903. self.ui.cb_engine_process_mode_other.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE -
  904. self.PROCESS_MODE_NON_JACK_PADDING)
  905. self.ui.sw_engine_process_mode.setCurrentIndex(1) # hide single+multi client modes
  906. self.ui.sb_engine_max_params.setValue(CARLA_DEFAULT_MAX_PARAMETERS)
  907. self.ui.cb_engine_reset_xruns.setChecked(CARLA_DEFAULT_RESET_XRUNS)
  908. self.ui.ch_engine_uis_always_on_top.setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP)
  909. self.ui.ch_engine_prefer_ui_bridges.setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES)
  910. self.ui.sb_engine_ui_bridges_timeout.setValue(CARLA_DEFAULT_UI_BRIDGES_TIMEOUT)
  911. self.ui.ch_engine_manage_uis.setChecked(CARLA_DEFAULT_MANAGE_UIS)
  912. # -------------------------------------------------------------------------------------------------------------
  913. # OSC
  914. elif currentRow == self.TAB_INDEX_OSC:
  915. self.ui.ch_osc_enable.setChecked(CARLA_DEFAULT_OSC_ENABLED)
  916. self.ui.group_osc_tcp_port.setChecked(CARLA_DEFAULT_OSC_TCP_PORT_ENABLED)
  917. self.ui.group_osc_udp_port.setChecked(CARLA_DEFAULT_OSC_UDP_PORT_ENABLED)
  918. self.ui.sb_osc_tcp_port_number.setValue(CARLA_DEFAULT_OSC_TCP_PORT_NUMBER)
  919. self.ui.sb_osc_udp_port_number.setValue(CARLA_DEFAULT_OSC_UDP_PORT_NUMBER)
  920. if CARLA_DEFAULT_OSC_TCP_PORT_RANDOM:
  921. self.ui.rb_osc_tcp_port_specific.setChecked(False)
  922. self.ui.rb_osc_tcp_port_random.setChecked(True)
  923. else:
  924. self.ui.rb_osc_tcp_port_random.setChecked(False)
  925. self.ui.rb_osc_tcp_port_specific.setChecked(True)
  926. if CARLA_DEFAULT_OSC_UDP_PORT_RANDOM:
  927. self.ui.rb_osc_udp_port_specific.setChecked(False)
  928. self.ui.rb_osc_udp_port_random.setChecked(True)
  929. else:
  930. self.ui.rb_osc_udp_port_random.setChecked(False)
  931. self.ui.rb_osc_udp_port_specific.setChecked(True)
  932. # -------------------------------------------------------------------------------------------------------------
  933. # Plugin Paths
  934. elif currentRow == self.TAB_INDEX_FILEPATHS:
  935. curIndex = self.ui.tw_filepaths.currentIndex()
  936. if curIndex == self.FILEPATH_INDEX_AUDIO:
  937. self.ui.lw_files_audio.clear()
  938. elif curIndex == self.FILEPATH_INDEX_MIDI:
  939. self.ui.lw_files_midi.clear()
  940. # -------------------------------------------------------------------------------------------------------------
  941. # Plugin Paths
  942. elif currentRow == self.TAB_INDEX_PLUGINPATHS:
  943. curIndex = self.ui.tw_paths.currentIndex()
  944. if curIndex == self.PLUGINPATH_INDEX_LADSPA:
  945. paths = CARLA_DEFAULT_LADSPA_PATH
  946. paths.sort()
  947. self.ui.lw_ladspa.clear()
  948. for path in paths:
  949. if not path:
  950. continue
  951. self.ui.lw_ladspa.addItem(path)
  952. elif curIndex == self.PLUGINPATH_INDEX_DSSI:
  953. paths = CARLA_DEFAULT_DSSI_PATH
  954. paths.sort()
  955. self.ui.lw_dssi.clear()
  956. for path in paths:
  957. if not path:
  958. continue
  959. self.ui.lw_dssi.addItem(path)
  960. elif curIndex == self.PLUGINPATH_INDEX_LV2:
  961. paths = CARLA_DEFAULT_LV2_PATH
  962. paths.sort()
  963. self.ui.lw_lv2.clear()
  964. for path in paths:
  965. if not path:
  966. continue
  967. self.ui.lw_lv2.addItem(path)
  968. elif curIndex == self.PLUGINPATH_INDEX_VST2:
  969. paths = CARLA_DEFAULT_VST2_PATH
  970. paths.sort()
  971. self.ui.lw_vst.clear()
  972. for path in paths:
  973. if not path:
  974. continue
  975. self.ui.lw_vst.addItem(path)
  976. elif curIndex == self.PLUGINPATH_INDEX_VST3:
  977. paths = CARLA_DEFAULT_VST3_PATH
  978. paths.sort()
  979. self.ui.lw_vst3.clear()
  980. for path in paths:
  981. if not path:
  982. continue
  983. self.ui.lw_vst3.addItem(path)
  984. elif curIndex == self.PLUGINPATH_INDEX_SF2:
  985. paths = CARLA_DEFAULT_SF2_PATH
  986. paths.sort()
  987. self.ui.lw_sf2.clear()
  988. for path in paths:
  989. if not path:
  990. continue
  991. self.ui.lw_sf2.addItem(path)
  992. elif curIndex == self.PLUGINPATH_INDEX_SFZ:
  993. paths = CARLA_DEFAULT_SFZ_PATH
  994. paths.sort()
  995. self.ui.lw_sfz.clear()
  996. for path in paths:
  997. if not path:
  998. continue
  999. self.ui.lw_sfz.addItem(path)
  1000. # -------------------------------------------------------------------------------------------------------------
  1001. # Wine
  1002. elif currentRow == self.TAB_INDEX_WINE:
  1003. self.ui.le_wine_exec.setText(CARLA_DEFAULT_WINE_EXECUTABLE)
  1004. self.ui.cb_wine_prefix_detect.setChecked(CARLA_DEFAULT_WINE_AUTO_PREFIX)
  1005. self.ui.le_wine_prefix_fallback.setText(CARLA_DEFAULT_WINE_FALLBACK_PREFIX)
  1006. self.ui.group_wine_realtime.setChecked(CARLA_DEFAULT_WINE_RT_PRIO_ENABLED)
  1007. self.ui.sb_wine_base_prio.setValue(CARLA_DEFAULT_WINE_BASE_RT_PRIO)
  1008. self.ui.sb_wine_server_prio.setValue(CARLA_DEFAULT_WINE_SERVER_RT_PRIO)
  1009. # -------------------------------------------------------------------------------------------------------------
  1010. # Experimental
  1011. elif currentRow == self.TAB_INDEX_EXPERIMENTAL:
  1012. self.resetExperimentalSettings()
  1013. def resetExperimentalSettings(self):
  1014. # Forever experimental
  1015. self.ui.cb_exp_plugin_bridges.setChecked(CARLA_DEFAULT_EXPERIMENTAL_PLUGIN_BRIDGES)
  1016. self.ui.ch_exp_wine_bridges.setChecked(CARLA_DEFAULT_EXPERIMENTAL_WINE_BRIDGES)
  1017. self.ui.ch_exp_jack_apps.setChecked(CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS)
  1018. self.ui.ch_exp_export_lv2.setChecked(CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT)
  1019. self.ui.ch_exp_load_lib_global.setChecked(CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL)
  1020. self.ui.ch_exp_prevent_bad_behaviour.setChecked(CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR)
  1021. # Temporary, until stable
  1022. self.ui.ch_main_system_icons.setChecked(CARLA_DEFAULT_MAIN_SYSTEM_ICONS)
  1023. self.ui.cb_canvas_fancy_eyecandy.setChecked(CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY)
  1024. self.ui.cb_canvas_use_opengl.setChecked(CARLA_DEFAULT_CANVAS_USE_OPENGL and
  1025. self.ui.cb_canvas_use_opengl.isEnabled())
  1026. self.ui.cb_canvas_render_hq_aa.setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and
  1027. self.ui.cb_canvas_render_hq_aa.isEnabled())
  1028. self.ui.cb_canvas_inline_displays.setChecked(CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS)
  1029. self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO)
  1030. self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES)
  1031. # -----------------------------------------------------------------------------------------------------------------
  1032. @pyqtSlot(bool)
  1033. def slot_enableExperimental(self, toggled):
  1034. if toggled:
  1035. self.ui.lw_page.showRow(self.TAB_INDEX_EXPERIMENTAL)
  1036. if self.ui.ch_exp_wine_bridges.isChecked() and not self.host.isControl:
  1037. self.ui.lw_page.showRow(self.TAB_INDEX_WINE)
  1038. else:
  1039. self.ui.lw_page.hideRow(self.TAB_INDEX_EXPERIMENTAL)
  1040. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  1041. @pyqtSlot(bool)
  1042. def slot_enableWineBridges(self, toggled):
  1043. if toggled and not self.host.isControl:
  1044. self.ui.lw_page.showRow(self.TAB_INDEX_WINE)
  1045. else:
  1046. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  1047. @pyqtSlot(bool)
  1048. def slot_pluginBridgesToggled(self, toggled):
  1049. if not toggled:
  1050. self.ui.ch_exp_wine_bridges.setChecked(False)
  1051. self.ui.ch_engine_prefer_plugin_bridges.setChecked(False)
  1052. self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)
  1053. @pyqtSlot(bool)
  1054. def slot_canvasEyeCandyToggled(self, toggled):
  1055. if not toggled:
  1056. # disable fancy eyecandy too
  1057. self.ui.cb_canvas_fancy_eyecandy.setChecked(False)
  1058. @pyqtSlot(bool)
  1059. def slot_canvasFancyEyeCandyToggled(self, toggled):
  1060. if toggled:
  1061. # make sure normal eyecandy is enabled too
  1062. self.ui.cb_canvas_eyecandy.setChecked(True)
  1063. @pyqtSlot(bool)
  1064. def slot_canvasOpenGLToggled(self, toggled):
  1065. if not toggled:
  1066. # uncheck GL specific option
  1067. self.ui.cb_canvas_render_hq_aa.setChecked(False)
  1068. # -----------------------------------------------------------------------------------------------------------------
  1069. @pyqtSlot()
  1070. def slot_getAndSetProjectPath(self):
  1071. # FIXME
  1072. getAndSetPath(self, self.ui.le_main_proj_folder)
  1073. # -----------------------------------------------------------------------------------------------------------------
  1074. @pyqtSlot()
  1075. def slot_engineAudioDriverChanged(self):
  1076. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  1077. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  1078. else:
  1079. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  1080. @pyqtSlot()
  1081. def slot_showAudioDriverSettings(self):
  1082. driverIndex = self.ui.cb_engine_audio_driver.currentIndex()
  1083. driverName = self.ui.cb_engine_audio_driver.currentText()
  1084. DriverSettingsW(self, self.host, driverIndex, driverName).exec_()
  1085. # -----------------------------------------------------------------------------------------------------------------
  1086. @pyqtSlot()
  1087. def slot_addPluginPath(self):
  1088. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  1089. if not newPath:
  1090. return
  1091. curIndex = self.ui.tw_paths.currentIndex()
  1092. if curIndex == self.PLUGINPATH_INDEX_LADSPA:
  1093. self.ui.lw_ladspa.addItem(newPath)
  1094. elif curIndex == self.PLUGINPATH_INDEX_DSSI:
  1095. self.ui.lw_dssi.addItem(newPath)
  1096. elif curIndex == self.PLUGINPATH_INDEX_LV2:
  1097. self.ui.lw_lv2.addItem(newPath)
  1098. elif curIndex == self.PLUGINPATH_INDEX_VST2:
  1099. self.ui.lw_vst.addItem(newPath)
  1100. elif curIndex == self.PLUGINPATH_INDEX_VST3:
  1101. self.ui.lw_vst3.addItem(newPath)
  1102. elif curIndex == self.PLUGINPATH_INDEX_SF2:
  1103. self.ui.lw_sf2.addItem(newPath)
  1104. elif curIndex == self.PLUGINPATH_INDEX_SFZ:
  1105. self.ui.lw_sfz.addItem(newPath)
  1106. @pyqtSlot()
  1107. def slot_removePluginPath(self):
  1108. curIndex = self.ui.tw_paths.currentIndex()
  1109. if curIndex == self.PLUGINPATH_INDEX_LADSPA:
  1110. self.ui.lw_ladspa.takeItem(self.ui.lw_ladspa.currentRow())
  1111. elif curIndex == self.PLUGINPATH_INDEX_DSSI:
  1112. self.ui.lw_dssi.takeItem(self.ui.lw_dssi.currentRow())
  1113. elif curIndex == self.PLUGINPATH_INDEX_LV2:
  1114. self.ui.lw_lv2.takeItem(self.ui.lw_lv2.currentRow())
  1115. elif curIndex == self.PLUGINPATH_INDEX_VST2:
  1116. self.ui.lw_vst.takeItem(self.ui.lw_vst.currentRow())
  1117. elif curIndex == self.PLUGINPATH_INDEX_VST3:
  1118. self.ui.lw_vst3.takeItem(self.ui.lw_vst3.currentRow())
  1119. elif curIndex == self.PLUGINPATH_INDEX_SF2:
  1120. self.ui.lw_sf2.takeItem(self.ui.lw_sf2.currentRow())
  1121. elif curIndex == self.PLUGINPATH_INDEX_SFZ:
  1122. self.ui.lw_sfz.takeItem(self.ui.lw_sfz.currentRow())
  1123. @pyqtSlot()
  1124. def slot_changePluginPath(self):
  1125. curIndex = self.ui.tw_paths.currentIndex()
  1126. if curIndex == self.PLUGINPATH_INDEX_LADSPA:
  1127. currentPath = self.ui.lw_ladspa.currentItem().text()
  1128. elif curIndex == self.PLUGINPATH_INDEX_DSSI:
  1129. currentPath = self.ui.lw_dssi.currentItem().text()
  1130. elif curIndex == self.PLUGINPATH_INDEX_LV2:
  1131. currentPath = self.ui.lw_lv2.currentItem().text()
  1132. elif curIndex == self.PLUGINPATH_INDEX_VST2:
  1133. currentPath = self.ui.lw_vst.currentItem().text()
  1134. elif curIndex == self.PLUGINPATH_INDEX_VST3:
  1135. currentPath = self.ui.lw_vst3.currentItem().text()
  1136. elif curIndex == self.PLUGINPATH_INDEX_SF2:
  1137. currentPath = self.ui.lw_sf2.currentItem().text()
  1138. elif curIndex == self.PLUGINPATH_INDEX_SFZ:
  1139. currentPath = self.ui.lw_sfz.currentItem().text()
  1140. else:
  1141. currentPath = ""
  1142. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  1143. if not newPath:
  1144. return
  1145. if curIndex == self.PLUGINPATH_INDEX_LADSPA:
  1146. self.ui.lw_ladspa.currentItem().setText(newPath)
  1147. elif curIndex == self.PLUGINPATH_INDEX_DSSI:
  1148. self.ui.lw_dssi.currentItem().setText(newPath)
  1149. elif curIndex == self.PLUGINPATH_INDEX_LV2:
  1150. self.ui.lw_lv2.currentItem().setText(newPath)
  1151. elif curIndex == self.PLUGINPATH_INDEX_VST2:
  1152. self.ui.lw_vst.currentItem().setText(newPath)
  1153. elif curIndex == self.PLUGINPATH_INDEX_VST3:
  1154. self.ui.lw_vst3.currentItem().setText(newPath)
  1155. elif curIndex == self.PLUGINPATH_INDEX_SF2:
  1156. self.ui.lw_sf2.currentItem().setText(newPath)
  1157. elif curIndex == self.PLUGINPATH_INDEX_SFZ:
  1158. self.ui.lw_sfz.currentItem().setText(newPath)
  1159. # -----------------------------------------------------------------------------------------------------------------
  1160. @pyqtSlot(int)
  1161. def slot_pluginPathTabChanged(self, index):
  1162. if index == self.PLUGINPATH_INDEX_LADSPA:
  1163. row = self.ui.lw_ladspa.currentRow()
  1164. elif index == self.PLUGINPATH_INDEX_DSSI:
  1165. row = self.ui.lw_dssi.currentRow()
  1166. elif index == self.PLUGINPATH_INDEX_LV2:
  1167. row = self.ui.lw_lv2.currentRow()
  1168. elif index == self.PLUGINPATH_INDEX_VST2:
  1169. row = self.ui.lw_vst.currentRow()
  1170. elif index == self.PLUGINPATH_INDEX_VST3:
  1171. row = self.ui.lw_vst3.currentRow()
  1172. elif index == self.PLUGINPATH_INDEX_SF2:
  1173. row = self.ui.lw_sf2.currentRow()
  1174. elif index == self.PLUGINPATH_INDEX_SFZ:
  1175. row = self.ui.lw_sfz.currentRow()
  1176. else:
  1177. row = -1
  1178. self.slot_pluginPathRowChanged(row)
  1179. @pyqtSlot(int)
  1180. def slot_pluginPathRowChanged(self, row):
  1181. check = bool(row >= 0)
  1182. self.ui.b_paths_remove.setEnabled(check)
  1183. self.ui.b_paths_change.setEnabled(check)
  1184. # -----------------------------------------------------------------------------------------------------------------
  1185. @pyqtSlot()
  1186. def slot_addFilePath(self):
  1187. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  1188. if not newPath:
  1189. return
  1190. curIndex = self.ui.tw_filepaths.currentIndex()
  1191. if curIndex == self.FILEPATH_INDEX_AUDIO:
  1192. self.ui.lw_files_audio.addItem(newPath)
  1193. elif curIndex == self.FILEPATH_INDEX_MIDI:
  1194. self.ui.lw_files_midi.addItem(newPath)
  1195. @pyqtSlot()
  1196. def slot_removeFilePath(self):
  1197. curIndex = self.ui.tw_filepaths.currentIndex()
  1198. if curIndex == self.FILEPATH_INDEX_AUDIO:
  1199. self.ui.lw_files_audio.takeItem(self.ui.lw_files_audio.currentRow())
  1200. elif curIndex == self.FILEPATH_INDEX_MIDI:
  1201. self.ui.lw_files_midi.takeItem(self.ui.lw_files_midi.currentRow())
  1202. @pyqtSlot()
  1203. def slot_changeFilePath(self):
  1204. curIndex = self.ui.tw_filepaths.currentIndex()
  1205. if curIndex == self.FILEPATH_INDEX_AUDIO:
  1206. currentPath = self.ui.lw_files_audio.currentItem().text()
  1207. elif curIndex == self.FILEPATH_INDEX_MIDI:
  1208. currentPath = self.ui.lw_files_midi.currentItem().text()
  1209. else:
  1210. currentPath = ""
  1211. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  1212. if not newPath:
  1213. return
  1214. if curIndex == self.FILEPATH_INDEX_AUDIO:
  1215. self.ui.lw_files_audio.currentItem().setText(newPath)
  1216. elif curIndex == self.FILEPATH_INDEX_MIDI:
  1217. self.ui.lw_files_midi.currentItem().setText(newPath)
  1218. # -----------------------------------------------------------------------------------------------------------------
  1219. @pyqtSlot(int)
  1220. def slot_filePathTabChanged(self, index):
  1221. if index == self.FILEPATH_INDEX_AUDIO:
  1222. row = self.ui.lw_files_audio.currentRow()
  1223. elif index == self.FILEPATH_INDEX_MIDI:
  1224. row = self.ui.lw_files_midi.currentRow()
  1225. else:
  1226. row = -1
  1227. self.slot_filePathRowChanged(row)
  1228. @pyqtSlot(int)
  1229. def slot_filePathRowChanged(self, row):
  1230. check = bool(row >= 0)
  1231. self.ui.b_filepaths_remove.setEnabled(check)
  1232. self.ui.b_filepaths_change.setEnabled(check)
  1233. # ---------------------------------------------------------------------------------------------------------------------
  1234. # Main
  1235. if __name__ == '__main__':
  1236. from carla_app import CarlaApplication
  1237. from carla_host import initHost as _initHost, loadHostSettings as _loadHostSettings
  1238. # pylint: disable=ungrouped-imports
  1239. from carla_shared import handleInitialCommandLineArguments
  1240. # pylint: enable=ungrouped-imports
  1241. initName, libPrefix = handleInitialCommandLineArguments(__file__ if "__file__" in dir() else None)
  1242. _app = CarlaApplication("Carla2-Settings", libPrefix)
  1243. _host = _initHost("Carla2-Settings", libPrefix, False, False, False)
  1244. _loadHostSettings(_host)
  1245. _gui = CarlaSettingsW(None, _host, True, True)
  1246. _gui.show()
  1247. _app.exit_exec()
  1248. # ---------------------------------------------------------------------------------------------------------------------