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.

865 lines
39KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla settings code
  4. # Copyright (C) 2011-2014 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 (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import pyqtSlot, QByteArray, QDir, QSettings
  24. from PyQt5.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  25. from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  26. else:
  27. from PyQt4.QtCore import pyqtSlot, QByteArray, QDir, QSettings
  28. from PyQt4.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  29. from PyQt4.QtGui import QDialog, QDialogButtonBox, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  30. # ------------------------------------------------------------------------------------------------------------
  31. # Imports (Custom)
  32. import ui_carla_settings
  33. import ui_carla_settings_driver
  34. from carla_shared import *
  35. from patchcanvas_theme import *
  36. # ------------------------------------------------------------------------------------------------------------
  37. # ...
  38. BUFFER_SIZE_LIST = (16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192)
  39. SAMPLE_RATE_LIST = (22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000)
  40. # ------------------------------------------------------------------------------------------------------------
  41. # Driver Settings
  42. class DriverSettingsW(QDialog):
  43. def __init__(self, parent, host, driverIndex, driverName):
  44. QDialog.__init__(self, parent)
  45. self.host = host
  46. self.ui = ui_carla_settings_driver.Ui_DriverSettingsW()
  47. self.ui.setupUi(self)
  48. if False:
  49. # kdevelop likes this :)
  50. host = CarlaHostMeta()
  51. self.host = host
  52. # ----------------------------------------------------------------------------------------------------
  53. # Internal stuff
  54. self.fDriverIndex = driverIndex
  55. self.fDriverName = driverName
  56. self.fDeviceNames = host.get_engine_driver_device_names(driverIndex)
  57. self.fBufferSizes = BUFFER_SIZE_LIST
  58. self.fSampleRates = SAMPLE_RATE_LIST
  59. # ----------------------------------------------------------------------------------------------------
  60. # Set-up GUI
  61. for name in self.fDeviceNames:
  62. self.ui.cb_device.addItem(name)
  63. # ----------------------------------------------------------------------------------------------------
  64. # Load settings
  65. self.loadSettings()
  66. # ----------------------------------------------------------------------------------------------------
  67. # Set-up connections
  68. self.accepted.connect(self.slot_saveSettings)
  69. self.ui.cb_device.currentIndexChanged.connect(self.slot_updateDeviceInfo)
  70. # ----------------------------------------------------------------------------------------------------
  71. def loadSettings(self):
  72. settings = QSettings("falkTX", "Carla2")
  73. audioDevice = settings.value("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), "", type=str)
  74. audioNumPeriods = settings.value("%s%s/NumPeriods" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_NUM_PERIODS, type=int)
  75. audioBufferSize = settings.value("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int)
  76. audioSampleRate = settings.value("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int)
  77. if audioDevice and audioDevice in self.fDeviceNames:
  78. self.ui.cb_device.setCurrentIndex(self.fDeviceNames.index(audioDevice))
  79. else:
  80. self.ui.cb_device.setCurrentIndex(-1)
  81. # fill combo-boxes first
  82. self.slot_updateDeviceInfo()
  83. if audioNumPeriods in (2, 3):
  84. self.ui.sb_numperiods.setValue(audioNumPeriods)
  85. else:
  86. self.ui.sb_numperiods.setValue(CARLA_DEFAULT_AUDIO_NUM_PERIODS)
  87. if audioBufferSize and audioBufferSize in self.fBufferSizes:
  88. self.ui.cb_buffersize.setCurrentIndex(self.fBufferSizes.index(audioBufferSize))
  89. elif self.fBufferSizes == BUFFER_SIZE_LIST:
  90. self.ui.cb_buffersize.setCurrentIndex(BUFFER_SIZE_LIST.index(CARLA_DEFAULT_AUDIO_BUFFER_SIZE))
  91. else:
  92. self.ui.cb_buffersize.setCurrentIndex(len(self.fBufferSizes)/2)
  93. if audioSampleRate and audioSampleRate in self.fSampleRates:
  94. self.ui.cb_samplerate.setCurrentIndex(self.fSampleRates.index(audioSampleRate))
  95. elif self.fSampleRates == SAMPLE_RATE_LIST:
  96. self.ui.cb_samplerate.setCurrentIndex(SAMPLE_RATE_LIST.index(CARLA_DEFAULT_AUDIO_SAMPLE_RATE))
  97. else:
  98. self.ui.cb_samplerate.setCurrentIndex(len(self.fSampleRates)/2)
  99. # --------------------------------------------------------------------------------------------------------
  100. @pyqtSlot()
  101. def slot_saveSettings(self):
  102. settings = QSettings("falkTX", "Carla2")
  103. settings.setValue("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), self.ui.cb_device.currentText())
  104. settings.setValue("%s%s/NumPeriods" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), self.ui.sb_numperiods.value())
  105. settings.setValue("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), self.ui.cb_buffersize.currentText())
  106. settings.setValue("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), self.ui.cb_samplerate.currentText())
  107. # --------------------------------------------------------------------------------------------------------
  108. @pyqtSlot()
  109. def slot_updateDeviceInfo(self):
  110. deviceName = self.ui.cb_device.currentText()
  111. oldBufferSize = self.ui.cb_buffersize.currentText()
  112. oldSampleRate = self.ui.cb_samplerate.currentText()
  113. self.ui.cb_buffersize.clear()
  114. self.ui.cb_samplerate.clear()
  115. if deviceName:
  116. driverDeviceInfo = self.host.get_engine_driver_device_info(self.fDriverIndex, deviceName)
  117. self.fBufferSizes = driverDeviceInfo['bufferSizes']
  118. self.fSampleRates = driverDeviceInfo['sampleRates']
  119. else:
  120. self.fBufferSizes = BUFFER_SIZE_LIST
  121. self.fSampleRates = SAMPLE_RATE_LIST
  122. for bsize in self.fBufferSizes:
  123. sbsize = str(bsize)
  124. self.ui.cb_buffersize.addItem(sbsize)
  125. if oldBufferSize == sbsize:
  126. self.ui.cb_buffersize.setCurrentIndex(self.ui.cb_buffersize.count()-1)
  127. for srate in self.fSampleRates:
  128. ssrate = str(int(srate))
  129. self.ui.cb_samplerate.addItem(ssrate)
  130. if oldSampleRate == ssrate:
  131. self.ui.cb_samplerate.setCurrentIndex(self.ui.cb_samplerate.count()-1)
  132. # --------------------------------------------------------------------------------------------------------
  133. def done(self, r):
  134. QDialog.done(self, r)
  135. self.close()
  136. # ------------------------------------------------------------------------------------------------------------
  137. # Settings Dialog
  138. class CarlaSettingsW(QDialog):
  139. # Tab indexes
  140. TAB_INDEX_MAIN = 0
  141. TAB_INDEX_CANVAS = 1
  142. TAB_INDEX_ENGINE = 2
  143. TAB_INDEX_PATHS = 3
  144. TAB_INDEX_NONE = 4
  145. # Path indexes
  146. PATH_INDEX_LADSPA = 0
  147. PATH_INDEX_DSSI = 1
  148. PATH_INDEX_LV2 = 2
  149. PATH_INDEX_VST = 3
  150. PATH_INDEX_VST3 = 4
  151. PATH_INDEX_AU = 5 if MACOS else -2
  152. PATH_INDEX_GIG = 6 if MACOS else 5
  153. PATH_INDEX_SF2 = 7 if MACOS else 6
  154. PATH_INDEX_SFZ = 8 if MACOS else 7
  155. # Single and Multiple client mode is only for JACK,
  156. # but we still want to match QComboBox index to backend defines,
  157. # so add +2 pos padding if driverName != "JACK".
  158. PROCESS_MODE_NON_JACK_PADDING = 2
  159. # --------------------------------------------------------------------------------------------------------
  160. def __init__(self, parent, host, hasCanvas, hasCanvasGL):
  161. QDialog.__init__(self, parent)
  162. self.host = host
  163. self.ui = ui_carla_settings.Ui_CarlaSettingsW()
  164. self.ui.setupUi(self)
  165. if False:
  166. # kdevelop likes this :)
  167. host = CarlaHostMeta()
  168. self.host = host
  169. # ----------------------------------------------------------------------------------------------------
  170. # Set-up GUI
  171. self.ui.lw_page.setFixedWidth(48 + 6 + 6 + QFontMetrics(self.ui.lw_page.font()).width("88888888"))
  172. for i in range(host.get_engine_driver_count()):
  173. self.ui.cb_engine_audio_driver.addItem(host.get_engine_driver_name(i))
  174. for i in range(Theme.THEME_MAX):
  175. self.ui.cb_canvas_theme.addItem(getThemeName(i))
  176. if WINDOWS and not config_UseQt5:
  177. self.ui.group_main_theme.setEnabled(False)
  178. if not MACOS:
  179. auIndex = self.ui.cb_paths.findText("AU")
  180. self.ui.cb_paths.removeItem(auIndex)
  181. self.ui.tw_paths.removeWidget(self.ui.tw_paths.widget(auIndex))
  182. if not hasCanvas:
  183. self.ui.lw_page.hideRow(self.TAB_INDEX_CANVAS)
  184. elif not hasCanvasGL:
  185. self.ui.cb_canvas_use_opengl.setEnabled(False)
  186. self.ui.cb_canvas_render_hq_aa.setEnabled(False)
  187. if host.isPlugin:
  188. self.ui.cb_engine_audio_driver.setEnabled(False)
  189. if host.processModeForced:
  190. self.ui.cb_engine_process_mode_jack.setEnabled(False)
  191. self.ui.cb_engine_process_mode_other.setEnabled(False)
  192. # ----------------------------------------------------------------------------------------------------
  193. # Load settings
  194. self.loadSettings()
  195. # ----------------------------------------------------------------------------------------------------
  196. # Set-up connections
  197. self.accepted.connect(self.slot_saveSettings)
  198. self.ui.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self.slot_resetSettings)
  199. self.ui.b_main_proj_folder_open.clicked.connect(self.slot_getAndSetProjectPath)
  200. self.ui.cb_engine_audio_driver.currentIndexChanged.connect(self.slot_engineAudioDriverChanged)
  201. self.ui.tb_engine_driver_config.clicked.connect(self.slot_showAudioDriverSettings)
  202. self.ui.b_paths_add.clicked.connect(self.slot_addPluginPath)
  203. self.ui.b_paths_remove.clicked.connect(self.slot_removePluginPath)
  204. self.ui.b_paths_change.clicked.connect(self.slot_changePluginPath)
  205. self.ui.cb_paths.currentIndexChanged.connect(self.slot_pluginPathTabChanged)
  206. self.ui.lw_ladspa.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  207. self.ui.lw_dssi.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  208. self.ui.lw_lv2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  209. self.ui.lw_vst.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  210. self.ui.lw_vst3.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  211. self.ui.lw_au.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  212. self.ui.lw_gig.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  213. self.ui.lw_sf2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  214. self.ui.lw_sfz.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  215. # ----------------------------------------------------------------------------------------------------
  216. # Post-connect setup
  217. self.ui.lw_ladspa.setCurrentRow(0)
  218. self.ui.lw_dssi.setCurrentRow(0)
  219. self.ui.lw_lv2.setCurrentRow(0)
  220. self.ui.lw_vst.setCurrentRow(0)
  221. self.ui.lw_vst3.setCurrentRow(0)
  222. self.ui.lw_au.setCurrentRow(0)
  223. self.ui.lw_gig.setCurrentRow(0)
  224. self.ui.lw_sf2.setCurrentRow(0)
  225. self.ui.lw_sfz.setCurrentRow(0)
  226. self.ui.lw_page.setCurrentCell(0, 0)
  227. # --------------------------------------------------------------------------------------------------------
  228. def loadSettings(self):
  229. settings = QSettings("falkTX", "Carla2")
  230. # ----------------------------------------------------------------------------------------------------
  231. # Main
  232. self.ui.le_main_proj_folder.setText(settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, type=str))
  233. 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())
  234. 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)))
  235. self.ui.sb_main_refresh_interval.setValue(settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, type=int))
  236. self.ui.cb_main_use_custom_skins.setChecked(settings.value(CARLA_KEY_MAIN_USE_CUSTOM_SKINS, CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS, type=bool))
  237. # ----------------------------------------------------------------------------------------------------
  238. # Canvas
  239. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, type=str)))
  240. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, type=str)))
  241. self.ui.cb_canvas_bezier_lines.setChecked(settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, type=bool))
  242. self.ui.cb_canvas_hide_groups.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, type=bool))
  243. self.ui.cb_canvas_eyecandy.setCheckState(settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, type=int))
  244. 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())
  245. self.ui.cb_canvas_render_aa.setCheckState(settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, type=int))
  246. 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())
  247. # ----------------------------------------------------------------------------------------------------
  248. # Engine
  249. if self.host.isPlugin:
  250. audioDriver = "Plugin"
  251. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  252. else:
  253. audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str)
  254. for i in range(self.ui.cb_engine_audio_driver.count()):
  255. if self.ui.cb_engine_audio_driver.itemText(i) == audioDriver:
  256. self.ui.cb_engine_audio_driver.setCurrentIndex(i)
  257. break
  258. else:
  259. self.ui.cb_engine_audio_driver.setCurrentIndex(-1)
  260. if audioDriver == "JACK":
  261. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  262. self.ui.tb_engine_driver_config.setEnabled(False)
  263. else:
  264. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  265. self.ui.tb_engine_driver_config.setEnabled(not self.host.isPlugin)
  266. self.ui.cb_engine_process_mode_jack.setCurrentIndex(self.host.processMode)
  267. if self.host.processMode >= self.PROCESS_MODE_NON_JACK_PADDING:
  268. self.ui.cb_engine_process_mode_other.setCurrentIndex(self.host.processMode-self.PROCESS_MODE_NON_JACK_PADDING)
  269. else:
  270. self.ui.cb_engine_process_mode_other.setCurrentIndex(0)
  271. self.ui.sb_engine_max_params.setValue(self.host.maxParameters)
  272. self.ui.ch_engine_uis_always_on_top.setChecked(self.host.uisAlwaysOnTop)
  273. self.ui.ch_engine_prefer_ui_bridges.setChecked(self.host.preferUIBridges)
  274. self.ui.sb_engine_ui_bridges_timeout.setValue(self.host.uiBridgesTimeout)
  275. self.ui.ch_engine_force_stereo.setChecked(self.host.forceStereo)
  276. self.ui.ch_engine_prefer_plugin_bridges.setChecked(self.host.preferPluginBridges)
  277. # ----------------------------------------------------------------------------------------------------
  278. # Paths
  279. ladspas = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH))
  280. dssis = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH))
  281. lv2s = toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))
  282. vsts = toList(settings.value(CARLA_KEY_PATHS_VST, CARLA_DEFAULT_VST_PATH))
  283. vst3s = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH))
  284. aus = toList(settings.value(CARLA_KEY_PATHS_AU, CARLA_DEFAULT_AU_PATH))
  285. gigs = toList(settings.value(CARLA_KEY_PATHS_GIG, CARLA_DEFAULT_GIG_PATH))
  286. sf2s = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH))
  287. sfzs = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH))
  288. ladspas.sort()
  289. dssis.sort()
  290. lv2s.sort()
  291. vsts.sort()
  292. vst3s.sort()
  293. aus.sort()
  294. gigs.sort()
  295. sf2s.sort()
  296. sfzs.sort()
  297. for ladspa in ladspas:
  298. if not ladspa: continue
  299. self.ui.lw_ladspa.addItem(ladspa)
  300. for dssi in dssis:
  301. if not dssi: continue
  302. self.ui.lw_dssi.addItem(dssi)
  303. for lv2 in lv2s:
  304. if not lv2: continue
  305. self.ui.lw_lv2.addItem(lv2)
  306. for vst in vsts:
  307. if not vst: continue
  308. self.ui.lw_vst.addItem(vst)
  309. for vst3 in vst3s:
  310. if not vst3: continue
  311. self.ui.lw_vst3.addItem(vst3)
  312. for au in aus:
  313. if not au: continue
  314. self.ui.lw_au.addItem(au)
  315. for gig in gigs:
  316. if not gig: continue
  317. self.ui.lw_gig.addItem(gig)
  318. for sf2 in sf2s:
  319. if not sf2: continue
  320. self.ui.lw_sf2.addItem(sf2)
  321. for sfz in sfzs:
  322. if not sfz: continue
  323. self.ui.lw_sfz.addItem(sfz)
  324. # --------------------------------------------------------------------------------------------------------
  325. @pyqtSlot()
  326. def slot_saveSettings(self):
  327. settings = QSettings("falkTX", "Carla2")
  328. # ----------------------------------------------------------------------------------------------------
  329. # Main
  330. settings.setValue(CARLA_KEY_MAIN_PROJECT_FOLDER, self.ui.le_main_proj_folder.text())
  331. settings.setValue(CARLA_KEY_MAIN_USE_PRO_THEME, self.ui.ch_main_theme_pro.isChecked())
  332. settings.setValue(CARLA_KEY_MAIN_PRO_THEME_COLOR, self.ui.cb_main_theme_color.currentText())
  333. settings.setValue(CARLA_KEY_MAIN_REFRESH_INTERVAL, self.ui.sb_main_refresh_interval.value())
  334. settings.setValue(CARLA_KEY_MAIN_USE_CUSTOM_SKINS, self.ui.cb_main_use_custom_skins.isChecked())
  335. # ----------------------------------------------------------------------------------------------------
  336. # Canvas
  337. settings.setValue(CARLA_KEY_CANVAS_THEME, self.ui.cb_canvas_theme.currentText())
  338. settings.setValue(CARLA_KEY_CANVAS_SIZE, self.ui.cb_canvas_size.currentText())
  339. settings.setValue(CARLA_KEY_CANVAS_USE_BEZIER_LINES, self.ui.cb_canvas_bezier_lines.isChecked())
  340. settings.setValue(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, self.ui.cb_canvas_hide_groups.isChecked())
  341. settings.setValue(CARLA_KEY_CANVAS_EYE_CANDY, self.ui.cb_canvas_eyecandy.checkState()) # 0, 1, 2 match their enum variants
  342. settings.setValue(CARLA_KEY_CANVAS_USE_OPENGL, self.ui.cb_canvas_use_opengl.isChecked())
  343. settings.setValue(CARLA_KEY_CANVAS_HQ_ANTIALIASING, self.ui.cb_canvas_render_hq_aa.isChecked())
  344. settings.setValue(CARLA_KEY_CANVAS_ANTIALIASING, self.ui.cb_canvas_render_aa.checkState()) # 0, 1, 2 match their enum variants
  345. # ----------------------------------------------------------------------------------------------------
  346. # Engine
  347. audioDriver = self.ui.cb_engine_audio_driver.currentText()
  348. if audioDriver and not self.host.isPlugin:
  349. settings.setValue(CARLA_KEY_ENGINE_AUDIO_DRIVER, audioDriver)
  350. if not self.host.processModeForced:
  351. # engine sends callback if processMode really changes
  352. processMode = self.ui.cb_engine_process_mode_jack.currentIndex() if audioDriver == "JACK" else self.ui.cb_engine_process_mode_other.currentIndex()+self.PROCESS_MODE_NON_JACK_PADDING
  353. self.host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, processMode, "")
  354. settings.setValue(CARLA_KEY_ENGINE_PROCESS_MODE, processMode)
  355. self.host.forceStereo = self.ui.ch_engine_force_stereo.isChecked()
  356. self.host.preferPluginBridges = self.ui.ch_engine_prefer_plugin_bridges.isChecked()
  357. self.host.preferUIBridges = self.ui.ch_engine_prefer_ui_bridges.isChecked()
  358. self.host.uisAlwaysOnTop = self.ui.ch_engine_uis_always_on_top.isChecked()
  359. self.host.maxParameters = self.ui.sb_engine_max_params.value()
  360. self.host.uiBridgesTimeout = self.ui.sb_engine_ui_bridges_timeout.value()
  361. self.host.set_engine_option(ENGINE_OPTION_FORCE_STEREO, self.host.forceStereo, "")
  362. self.host.set_engine_option(ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, self.host.preferPluginBridges, "")
  363. self.host.set_engine_option(ENGINE_OPTION_PREFER_UI_BRIDGES, self.host.preferUIBridges, "")
  364. self.host.set_engine_option(ENGINE_OPTION_UIS_ALWAYS_ON_TOP, self.host.uisAlwaysOnTop, "")
  365. self.host.set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, self.host.maxParameters, "")
  366. self.host.set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, self.host.uiBridgesTimeout, "")
  367. settings.setValue(CARLA_KEY_ENGINE_FORCE_STEREO, self.host.forceStereo)
  368. settings.setValue(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, self.host.preferPluginBridges)
  369. settings.setValue(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, self.host.preferUIBridges)
  370. settings.setValue(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, self.host.uisAlwaysOnTop)
  371. settings.setValue(CARLA_KEY_ENGINE_MAX_PARAMETERS, self.host.maxParameters)
  372. settings.setValue(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, self.host.uiBridgesTimeout)
  373. # ----------------------------------------------------------------------------------------------------
  374. # Paths
  375. ladspas = []
  376. dssis = []
  377. lv2s = []
  378. vsts = []
  379. vst3s = []
  380. aus = []
  381. gigs = []
  382. sf2s = []
  383. sfzs = []
  384. for i in range(self.ui.lw_ladspa.count()):
  385. ladspas.append(self.ui.lw_ladspa.item(i).text())
  386. for i in range(self.ui.lw_dssi.count()):
  387. dssis.append(self.ui.lw_dssi.item(i).text())
  388. for i in range(self.ui.lw_lv2.count()):
  389. lv2s.append(self.ui.lw_lv2.item(i).text())
  390. for i in range(self.ui.lw_vst.count()):
  391. vsts.append(self.ui.lw_vst.item(i).text())
  392. for i in range(self.ui.lw_vst3.count()):
  393. vst3s.append(self.ui.lw_vst3.item(i).text())
  394. for i in range(self.ui.lw_au.count()):
  395. aus.append(self.ui.lw_au.item(i).text())
  396. for i in range(self.ui.lw_gig.count()):
  397. gigs.append(self.ui.lw_gig.item(i).text())
  398. for i in range(self.ui.lw_sf2.count()):
  399. sf2s.append(self.ui.lw_sf2.item(i).text())
  400. for i in range(self.ui.lw_sfz.count()):
  401. sfzs.append(self.ui.lw_sfz.item(i).text())
  402. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(ladspas))
  403. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(dssis))
  404. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(lv2s))
  405. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST, splitter.join(vsts))
  406. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(vst3s))
  407. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_AU, splitter.join(aus))
  408. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_GIG, splitter.join(gigs))
  409. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(sf2s))
  410. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(sfzs))
  411. settings.setValue(CARLA_KEY_PATHS_LADSPA, ladspas)
  412. settings.setValue(CARLA_KEY_PATHS_DSSI, dssis)
  413. settings.setValue(CARLA_KEY_PATHS_LV2, lv2s)
  414. settings.setValue(CARLA_KEY_PATHS_VST, vsts)
  415. settings.setValue(CARLA_KEY_PATHS_VST3, vst3s)
  416. settings.setValue(CARLA_KEY_PATHS_AU, aus)
  417. settings.setValue(CARLA_KEY_PATHS_GIG, gigs)
  418. settings.setValue(CARLA_KEY_PATHS_SF2, sf2s)
  419. settings.setValue(CARLA_KEY_PATHS_SFZ, sfzs)
  420. # --------------------------------------------------------------------------------------------------------
  421. @pyqtSlot()
  422. def slot_resetSettings(self):
  423. # ----------------------------------------------------------------------------------------------------
  424. # Main
  425. if self.ui.lw_page.currentRow() == self.TAB_INDEX_MAIN:
  426. self.ui.le_main_proj_folder.setText(CARLA_DEFAULT_MAIN_PROJECT_FOLDER)
  427. self.ui.ch_main_theme_pro.setChecked(CARLA_DEFAULT_MAIN_USE_PRO_THEME and self.ui.group_main_theme.isEnabled())
  428. self.ui.cb_main_theme_color.setCurrentIndex(self.ui.cb_main_theme_color.findText(CARLA_DEFAULT_MAIN_PRO_THEME_COLOR))
  429. self.ui.sb_main_refresh_interval.setValue(CARLA_DEFAULT_MAIN_REFRESH_INTERVAL)
  430. self.ui.cb_main_use_custom_skins.setChecked(CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS)
  431. # ----------------------------------------------------------------------------------------------------
  432. # Canvas
  433. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_CANVAS:
  434. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(CARLA_DEFAULT_CANVAS_THEME))
  435. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(CARLA_DEFAULT_CANVAS_SIZE))
  436. self.ui.cb_canvas_bezier_lines.setChecked(CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES)
  437. self.ui.cb_canvas_hide_groups.setChecked(CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS)
  438. self.ui.cb_canvas_eyecandy.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_EYE_CANDY
  439. self.ui.cb_canvas_use_opengl.setChecked(CARLA_DEFAULT_CANVAS_USE_OPENGL and self.ui.cb_canvas_use_opengl.isEnabled())
  440. self.ui.cb_canvas_render_aa.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_ANTIALIASING
  441. self.ui.cb_canvas_render_hq_aa.setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and self.ui.cb_canvas_render_hq_aa.isEnabled())
  442. # ----------------------------------------------------------------------------------------------------
  443. # Engine
  444. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_ENGINE:
  445. if not self.host.isPlugin:
  446. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  447. if not self.host.processModeForced:
  448. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  449. self.ui.cb_engine_process_mode_jack.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE)
  450. self.ui.sw_engine_process_mode.setCurrentIndex(0) # show all modes
  451. else:
  452. self.ui.cb_engine_process_mode_other.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE-self.PROCESS_MODE_NON_JACK_PADDING)
  453. self.ui.sw_engine_process_mode.setCurrentIndex(1) # hide single+multi client modes
  454. self.ui.sb_engine_max_params.setValue(CARLA_DEFAULT_MAX_PARAMETERS)
  455. self.ui.ch_engine_uis_always_on_top.setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP)
  456. self.ui.ch_engine_prefer_ui_bridges.setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES)
  457. self.ui.sb_engine_ui_bridges_timeout.setValue(CARLA_DEFAULT_UI_BRIDGES_TIMEOUT)
  458. self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO)
  459. self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES)
  460. # ----------------------------------------------------------------------------------------------------
  461. # Paths
  462. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_PATHS:
  463. curIndex = self.ui.tw_paths.currentIndex()
  464. if curIndex == self.PATH_INDEX_LADSPA:
  465. paths = CARLA_DEFAULT_LADSPA_PATH
  466. paths.sort()
  467. self.ui.lw_ladspa.clear()
  468. for path in paths:
  469. if not path: continue
  470. self.ui.lw_ladspa.addItem(path)
  471. elif curIndex == self.PATH_INDEX_DSSI:
  472. paths = CARLA_DEFAULT_DSSI_PATH
  473. paths.sort()
  474. self.ui.lw_dssi.clear()
  475. for path in paths:
  476. if not path: continue
  477. self.ui.lw_dssi.addItem(path)
  478. elif curIndex == self.PATH_INDEX_LV2:
  479. paths = CARLA_DEFAULT_LV2_PATH
  480. paths.sort()
  481. self.ui.lw_lv2.clear()
  482. for path in paths:
  483. if not path: continue
  484. self.ui.lw_lv2.addItem(path)
  485. elif curIndex == self.PATH_INDEX_VST:
  486. paths = CARLA_DEFAULT_VST_PATH
  487. paths.sort()
  488. self.ui.lw_vst.clear()
  489. for path in paths:
  490. if not path: continue
  491. self.ui.lw_vst.addItem(path)
  492. elif curIndex == self.PATH_INDEX_VST3:
  493. paths = CARLA_DEFAULT_VST3_PATH
  494. paths.sort()
  495. self.ui.lw_vst3.clear()
  496. for path in paths:
  497. if not path: continue
  498. self.ui.lw_vst3.addItem(path)
  499. elif curIndex == self.PATH_INDEX_AU:
  500. paths = CARLA_DEFAULT_AU_PATH
  501. paths.sort()
  502. self.ui.lw_au.clear()
  503. for path in paths:
  504. if not path: continue
  505. self.ui.lw_au.addItem(path)
  506. elif curIndex == self.PATH_INDEX_GIG:
  507. paths = CARLA_DEFAULT_GIG_PATH
  508. paths.sort()
  509. self.ui.lw_gig.clear()
  510. for path in paths:
  511. if not path: continue
  512. self.ui.lw_gig.addItem(path)
  513. elif curIndex == self.PATH_INDEX_SF2:
  514. paths = CARLA_DEFAULT_SF2_PATH
  515. paths.sort()
  516. self.ui.lw_sf2.clear()
  517. for path in paths:
  518. if not path: continue
  519. self.ui.lw_sf2.addItem(path)
  520. elif curIndex == self.PATH_INDEX_SFZ:
  521. paths = CARLA_DEFAULT_SFZ_PATH
  522. paths.sort()
  523. self.ui.lw_sfz.clear()
  524. for path in paths:
  525. if not path: continue
  526. self.ui.lw_sfz.addItem(path)
  527. # --------------------------------------------------------------------------------------------------------
  528. @pyqtSlot()
  529. def slot_getAndSetProjectPath(self):
  530. # FIXME
  531. getAndSetPath(self, self.ui.le_main_proj_folder)
  532. # --------------------------------------------------------------------------------------------------------
  533. @pyqtSlot()
  534. def slot_engineAudioDriverChanged(self):
  535. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  536. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  537. self.ui.tb_engine_driver_config.setEnabled(False)
  538. else:
  539. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  540. self.ui.tb_engine_driver_config.setEnabled(True)
  541. @pyqtSlot()
  542. def slot_showAudioDriverSettings(self):
  543. driverIndex = self.ui.cb_engine_audio_driver.currentIndex()
  544. driverName = self.ui.cb_engine_audio_driver.currentText()
  545. DriverSettingsW(self, self.host, driverIndex, driverName).exec_()
  546. # --------------------------------------------------------------------------------------------------------
  547. @pyqtSlot()
  548. def slot_addPluginPath(self):
  549. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  550. if not newPath:
  551. return
  552. curIndex = self.ui.tw_paths.currentIndex()
  553. if curIndex == self.PATH_INDEX_LADSPA:
  554. self.ui.lw_ladspa.addItem(newPath)
  555. elif curIndex == self.PATH_INDEX_DSSI:
  556. self.ui.lw_dssi.addItem(newPath)
  557. elif curIndex == self.PATH_INDEX_LV2:
  558. self.ui.lw_lv2.addItem(newPath)
  559. elif curIndex == self.PATH_INDEX_VST:
  560. self.ui.lw_vst.addItem(newPath)
  561. elif curIndex == self.PATH_INDEX_VST3:
  562. self.ui.lw_vst3.addItem(newPath)
  563. elif curIndex == self.PATH_INDEX_AU:
  564. self.ui.lw_au.addItem(newPath)
  565. elif curIndex == self.PATH_INDEX_GIG:
  566. self.ui.lw_gig.addItem(newPath)
  567. elif curIndex == self.PATH_INDEX_SF2:
  568. self.ui.lw_sf2.addItem(newPath)
  569. elif curIndex == self.PATH_INDEX_SFZ:
  570. self.ui.lw_sfz.addItem(newPath)
  571. @pyqtSlot()
  572. def slot_removePluginPath(self):
  573. curIndex = self.ui.tw_paths.currentIndex()
  574. if curIndex == self.PATH_INDEX_LADSPA:
  575. self.ui.lw_ladspa.takeItem(self.ui.lw_ladspa.currentRow())
  576. elif curIndex == self.PATH_INDEX_DSSI:
  577. self.ui.lw_dssi.takeItem(self.ui.lw_dssi.currentRow())
  578. elif curIndex == self.PATH_INDEX_LV2:
  579. self.ui.lw_lv2.takeItem(self.ui.lw_lv2.currentRow())
  580. elif curIndex == self.PATH_INDEX_VST:
  581. self.ui.lw_vst.takeItem(self.ui.lw_vst.currentRow())
  582. elif curIndex == self.PATH_INDEX_VST3:
  583. self.ui.lw_vst3.takeItem(self.ui.lw_vst3.currentRow())
  584. elif curIndex == self.PATH_INDEX_AU:
  585. self.ui.lw_au.takeItem(self.ui.lw_au.currentRow())
  586. elif curIndex == self.PATH_INDEX_GIG:
  587. self.ui.lw_gig.takeItem(self.ui.lw_gig.currentRow())
  588. elif curIndex == self.PATH_INDEX_SF2:
  589. self.ui.lw_sf2.takeItem(self.ui.lw_sf2.currentRow())
  590. elif curIndex == self.PATH_INDEX_SFZ:
  591. self.ui.lw_sfz.takeItem(self.ui.lw_sfz.currentRow())
  592. @pyqtSlot()
  593. def slot_changePluginPath(self):
  594. curIndex = self.ui.tw_paths.currentIndex()
  595. if curIndex == self.PATH_INDEX_LADSPA:
  596. currentPath = self.ui.lw_ladspa.currentItem().text()
  597. elif curIndex == self.PATH_INDEX_DSSI:
  598. currentPath = self.ui.lw_dssi.currentItem().text()
  599. elif curIndex == self.PATH_INDEX_LV2:
  600. currentPath = self.ui.lw_lv2.currentItem().text()
  601. elif curIndex == self.PATH_INDEX_VST:
  602. currentPath = self.ui.lw_vst.currentItem().text()
  603. elif curIndex == self.PATH_INDEX_VST3:
  604. currentPath = self.ui.lw_vst3.currentItem().text()
  605. elif curIndex == self.PATH_INDEX_AU:
  606. currentPath = self.ui.lw_au.currentItem().text()
  607. elif curIndex == self.PATH_INDEX_GIG:
  608. currentPath = self.ui.lw_gig.currentItem().text()
  609. elif curIndex == self.PATH_INDEX_SF2:
  610. currentPath = self.ui.lw_sf2.currentItem().text()
  611. elif curIndex == self.PATH_INDEX_SFZ:
  612. currentPath = self.ui.lw_sfz.currentItem().text()
  613. else:
  614. currentPath = ""
  615. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  616. if not newPath:
  617. return
  618. if curIndex == self.PATH_INDEX_LADSPA:
  619. self.ui.lw_ladspa.currentItem().setText(newPath)
  620. elif curIndex == self.PATH_INDEX_DSSI:
  621. self.ui.lw_dssi.currentItem().setText(newPath)
  622. elif curIndex == self.PATH_INDEX_LV2:
  623. self.ui.lw_lv2.currentItem().setText(newPath)
  624. elif curIndex == self.PATH_INDEX_VST:
  625. self.ui.lw_vst.currentItem().setText(newPath)
  626. elif curIndex == self.PATH_INDEX_VST3:
  627. self.ui.lw_vst3.currentItem().setText(newPath)
  628. elif curIndex == self.PATH_INDEX_AU:
  629. self.ui.lw_au.currentItem().setText(newPath)
  630. elif curIndex == self.PATH_INDEX_GIG:
  631. self.ui.lw_gig.currentItem().setText(newPath)
  632. elif curIndex == self.PATH_INDEX_SF2:
  633. self.ui.lw_sf2.currentItem().setText(newPath)
  634. elif curIndex == self.PATH_INDEX_SFZ:
  635. self.ui.lw_sfz.currentItem().setText(newPath)
  636. # --------------------------------------------------------------------------------------------------------
  637. @pyqtSlot(int)
  638. def slot_pluginPathTabChanged(self, index):
  639. if index == self.PATH_INDEX_LADSPA:
  640. row = self.ui.lw_ladspa.currentRow()
  641. elif index == self.PATH_INDEX_DSSI:
  642. row = self.ui.lw_dssi.currentRow()
  643. elif index == self.PATH_INDEX_LV2:
  644. row = self.ui.lw_lv2.currentRow()
  645. elif index == self.PATH_INDEX_VST:
  646. row = self.ui.lw_vst.currentRow()
  647. elif index == self.PATH_INDEX_VST3:
  648. row = self.ui.lw_vst3.currentRow()
  649. elif index == self.PATH_INDEX_AU:
  650. row = self.ui.lw_au.currentRow()
  651. elif index == self.PATH_INDEX_GIG:
  652. row = self.ui.lw_gig.currentRow()
  653. elif index == self.PATH_INDEX_SF2:
  654. row = self.ui.lw_sf2.currentRow()
  655. elif index == self.PATH_INDEX_SFZ:
  656. row = self.ui.lw_sfz.currentRow()
  657. else:
  658. row = -1
  659. check = bool(row >= 0)
  660. self.ui.b_paths_remove.setEnabled(check)
  661. self.ui.b_paths_change.setEnabled(check)
  662. @pyqtSlot(int)
  663. def slot_pluginPathRowChanged(self, row):
  664. check = bool(row >= 0)
  665. self.ui.b_paths_remove.setEnabled(check)
  666. self.ui.b_paths_change.setEnabled(check)
  667. # --------------------------------------------------------------------------------------------------------
  668. def done(self, r):
  669. QDialog.done(self, r)
  670. self.close()
  671. # ------------------------------------------------------------------------------------------------------------
  672. # Main
  673. if __name__ == '__main__':
  674. from carla_app import CarlaApplication
  675. from carla_host import initHost, loadHostSettings
  676. app = CarlaApplication()
  677. host = initHost("Settings", None, False, False, False)
  678. loadHostSettings(host)
  679. gui = CarlaSettingsW(None, host, True, True)
  680. gui.show()
  681. app.exit_exec()
  682. # ------------------------------------------------------------------------------------------------------------