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.

868 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. # FIXME, not implemented yet
  193. self.ui.ch_engine_uis_always_on_top.hide()
  194. # ----------------------------------------------------------------------------------------------------
  195. # Load settings
  196. self.loadSettings()
  197. # ----------------------------------------------------------------------------------------------------
  198. # Set-up connections
  199. self.accepted.connect(self.slot_saveSettings)
  200. self.ui.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self.slot_resetSettings)
  201. self.ui.b_main_proj_folder_open.clicked.connect(self.slot_getAndSetProjectPath)
  202. self.ui.cb_engine_audio_driver.currentIndexChanged.connect(self.slot_engineAudioDriverChanged)
  203. self.ui.tb_engine_driver_config.clicked.connect(self.slot_showAudioDriverSettings)
  204. self.ui.b_paths_add.clicked.connect(self.slot_addPluginPath)
  205. self.ui.b_paths_remove.clicked.connect(self.slot_removePluginPath)
  206. self.ui.b_paths_change.clicked.connect(self.slot_changePluginPath)
  207. self.ui.cb_paths.currentIndexChanged.connect(self.slot_pluginPathTabChanged)
  208. self.ui.lw_ladspa.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  209. self.ui.lw_dssi.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  210. self.ui.lw_lv2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  211. self.ui.lw_vst.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  212. self.ui.lw_vst3.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  213. self.ui.lw_au.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  214. self.ui.lw_gig.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  215. self.ui.lw_sf2.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  216. self.ui.lw_sfz.currentRowChanged.connect(self.slot_pluginPathRowChanged)
  217. # ----------------------------------------------------------------------------------------------------
  218. # Post-connect setup
  219. self.ui.lw_ladspa.setCurrentRow(0)
  220. self.ui.lw_dssi.setCurrentRow(0)
  221. self.ui.lw_lv2.setCurrentRow(0)
  222. self.ui.lw_vst.setCurrentRow(0)
  223. self.ui.lw_vst3.setCurrentRow(0)
  224. self.ui.lw_au.setCurrentRow(0)
  225. self.ui.lw_gig.setCurrentRow(0)
  226. self.ui.lw_sf2.setCurrentRow(0)
  227. self.ui.lw_sfz.setCurrentRow(0)
  228. self.ui.lw_page.setCurrentCell(0, 0)
  229. # --------------------------------------------------------------------------------------------------------
  230. def loadSettings(self):
  231. settings = QSettings("falkTX", "Carla2")
  232. # ----------------------------------------------------------------------------------------------------
  233. # Main
  234. self.ui.le_main_proj_folder.setText(settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, type=str))
  235. 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())
  236. 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)))
  237. self.ui.sb_main_refresh_interval.setValue(settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, type=int))
  238. self.ui.cb_main_use_custom_skins.setChecked(settings.value(CARLA_KEY_MAIN_USE_CUSTOM_SKINS, CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS, type=bool))
  239. # ----------------------------------------------------------------------------------------------------
  240. # Canvas
  241. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, type=str)))
  242. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, type=str)))
  243. self.ui.cb_canvas_bezier_lines.setChecked(settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, type=bool))
  244. self.ui.cb_canvas_hide_groups.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, type=bool))
  245. self.ui.cb_canvas_eyecandy.setCheckState(settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, type=int))
  246. 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())
  247. self.ui.cb_canvas_render_aa.setCheckState(settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, type=int))
  248. 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())
  249. # ----------------------------------------------------------------------------------------------------
  250. # Engine
  251. if self.host.isPlugin:
  252. audioDriver = "Plugin"
  253. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  254. else:
  255. audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str)
  256. for i in range(self.ui.cb_engine_audio_driver.count()):
  257. if self.ui.cb_engine_audio_driver.itemText(i) == audioDriver:
  258. self.ui.cb_engine_audio_driver.setCurrentIndex(i)
  259. break
  260. else:
  261. self.ui.cb_engine_audio_driver.setCurrentIndex(-1)
  262. if audioDriver == "JACK":
  263. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  264. self.ui.tb_engine_driver_config.setEnabled(False)
  265. else:
  266. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  267. self.ui.tb_engine_driver_config.setEnabled(not self.host.isPlugin)
  268. self.ui.cb_engine_process_mode_jack.setCurrentIndex(self.host.nextProcessMode)
  269. if self.host.nextProcessMode >= self.PROCESS_MODE_NON_JACK_PADDING:
  270. self.ui.cb_engine_process_mode_other.setCurrentIndex(self.host.nextProcessMode-self.PROCESS_MODE_NON_JACK_PADDING)
  271. else:
  272. self.ui.cb_engine_process_mode_other.setCurrentIndex(0)
  273. self.ui.sb_engine_max_params.setValue(self.host.maxParameters)
  274. self.ui.ch_engine_uis_always_on_top.setChecked(self.host.uisAlwaysOnTop)
  275. self.ui.ch_engine_prefer_ui_bridges.setChecked(self.host.preferUIBridges)
  276. self.ui.sb_engine_ui_bridges_timeout.setValue(self.host.uiBridgesTimeout)
  277. self.ui.ch_engine_force_stereo.setChecked(self.host.forceStereo)
  278. self.ui.ch_engine_prefer_plugin_bridges.setChecked(self.host.preferPluginBridges)
  279. # ----------------------------------------------------------------------------------------------------
  280. # Paths
  281. ladspas = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH))
  282. dssis = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH))
  283. lv2s = toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))
  284. vsts = toList(settings.value(CARLA_KEY_PATHS_VST, CARLA_DEFAULT_VST_PATH))
  285. vst3s = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH))
  286. aus = toList(settings.value(CARLA_KEY_PATHS_AU, CARLA_DEFAULT_AU_PATH))
  287. gigs = toList(settings.value(CARLA_KEY_PATHS_GIG, CARLA_DEFAULT_GIG_PATH))
  288. sf2s = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH))
  289. sfzs = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH))
  290. ladspas.sort()
  291. dssis.sort()
  292. lv2s.sort()
  293. vsts.sort()
  294. vst3s.sort()
  295. aus.sort()
  296. gigs.sort()
  297. sf2s.sort()
  298. sfzs.sort()
  299. for ladspa in ladspas:
  300. if not ladspa: continue
  301. self.ui.lw_ladspa.addItem(ladspa)
  302. for dssi in dssis:
  303. if not dssi: continue
  304. self.ui.lw_dssi.addItem(dssi)
  305. for lv2 in lv2s:
  306. if not lv2: continue
  307. self.ui.lw_lv2.addItem(lv2)
  308. for vst in vsts:
  309. if not vst: continue
  310. self.ui.lw_vst.addItem(vst)
  311. for vst3 in vst3s:
  312. if not vst3: continue
  313. self.ui.lw_vst3.addItem(vst3)
  314. for au in aus:
  315. if not au: continue
  316. self.ui.lw_au.addItem(au)
  317. for gig in gigs:
  318. if not gig: continue
  319. self.ui.lw_gig.addItem(gig)
  320. for sf2 in sf2s:
  321. if not sf2: continue
  322. self.ui.lw_sf2.addItem(sf2)
  323. for sfz in sfzs:
  324. if not sfz: continue
  325. self.ui.lw_sfz.addItem(sfz)
  326. # --------------------------------------------------------------------------------------------------------
  327. @pyqtSlot()
  328. def slot_saveSettings(self):
  329. settings = QSettings("falkTX", "Carla2")
  330. # ----------------------------------------------------------------------------------------------------
  331. # Main
  332. settings.setValue(CARLA_KEY_MAIN_PROJECT_FOLDER, self.ui.le_main_proj_folder.text())
  333. settings.setValue(CARLA_KEY_MAIN_USE_PRO_THEME, self.ui.ch_main_theme_pro.isChecked())
  334. settings.setValue(CARLA_KEY_MAIN_PRO_THEME_COLOR, self.ui.cb_main_theme_color.currentText())
  335. settings.setValue(CARLA_KEY_MAIN_REFRESH_INTERVAL, self.ui.sb_main_refresh_interval.value())
  336. settings.setValue(CARLA_KEY_MAIN_USE_CUSTOM_SKINS, self.ui.cb_main_use_custom_skins.isChecked())
  337. # ----------------------------------------------------------------------------------------------------
  338. # Canvas
  339. settings.setValue(CARLA_KEY_CANVAS_THEME, self.ui.cb_canvas_theme.currentText())
  340. settings.setValue(CARLA_KEY_CANVAS_SIZE, self.ui.cb_canvas_size.currentText())
  341. settings.setValue(CARLA_KEY_CANVAS_USE_BEZIER_LINES, self.ui.cb_canvas_bezier_lines.isChecked())
  342. settings.setValue(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, self.ui.cb_canvas_hide_groups.isChecked())
  343. settings.setValue(CARLA_KEY_CANVAS_EYE_CANDY, self.ui.cb_canvas_eyecandy.checkState()) # 0, 1, 2 match their enum variants
  344. settings.setValue(CARLA_KEY_CANVAS_USE_OPENGL, self.ui.cb_canvas_use_opengl.isChecked())
  345. settings.setValue(CARLA_KEY_CANVAS_HQ_ANTIALIASING, self.ui.cb_canvas_render_hq_aa.isChecked())
  346. settings.setValue(CARLA_KEY_CANVAS_ANTIALIASING, self.ui.cb_canvas_render_aa.checkState()) # 0, 1, 2 match their enum variants
  347. # ----------------------------------------------------------------------------------------------------
  348. # Engine
  349. audioDriver = self.ui.cb_engine_audio_driver.currentText()
  350. if audioDriver and not self.host.isPlugin:
  351. settings.setValue(CARLA_KEY_ENGINE_AUDIO_DRIVER, audioDriver)
  352. if not self.host.processModeForced:
  353. # engine sends callback if processMode really changes
  354. self.host.nextProcessMode = 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
  355. self.host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, self.host.nextProcessMode, "")
  356. settings.setValue(CARLA_KEY_ENGINE_PROCESS_MODE, self.host.nextProcessMode)
  357. self.host.forceStereo = self.ui.ch_engine_force_stereo.isChecked()
  358. self.host.preferPluginBridges = self.ui.ch_engine_prefer_plugin_bridges.isChecked()
  359. self.host.preferUIBridges = self.ui.ch_engine_prefer_ui_bridges.isChecked()
  360. self.host.uisAlwaysOnTop = self.ui.ch_engine_uis_always_on_top.isChecked()
  361. self.host.maxParameters = self.ui.sb_engine_max_params.value()
  362. self.host.uiBridgesTimeout = self.ui.sb_engine_ui_bridges_timeout.value()
  363. self.host.set_engine_option(ENGINE_OPTION_FORCE_STEREO, self.host.forceStereo, "")
  364. self.host.set_engine_option(ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, self.host.preferPluginBridges, "")
  365. self.host.set_engine_option(ENGINE_OPTION_PREFER_UI_BRIDGES, self.host.preferUIBridges, "")
  366. self.host.set_engine_option(ENGINE_OPTION_UIS_ALWAYS_ON_TOP, self.host.uisAlwaysOnTop, "")
  367. self.host.set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, self.host.maxParameters, "")
  368. self.host.set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, self.host.uiBridgesTimeout, "")
  369. settings.setValue(CARLA_KEY_ENGINE_FORCE_STEREO, self.host.forceStereo)
  370. settings.setValue(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, self.host.preferPluginBridges)
  371. settings.setValue(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, self.host.preferUIBridges)
  372. settings.setValue(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, self.host.uisAlwaysOnTop)
  373. settings.setValue(CARLA_KEY_ENGINE_MAX_PARAMETERS, self.host.maxParameters)
  374. settings.setValue(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, self.host.uiBridgesTimeout)
  375. # ----------------------------------------------------------------------------------------------------
  376. # Paths
  377. ladspas = []
  378. dssis = []
  379. lv2s = []
  380. vsts = []
  381. vst3s = []
  382. aus = []
  383. gigs = []
  384. sf2s = []
  385. sfzs = []
  386. for i in range(self.ui.lw_ladspa.count()):
  387. ladspas.append(self.ui.lw_ladspa.item(i).text())
  388. for i in range(self.ui.lw_dssi.count()):
  389. dssis.append(self.ui.lw_dssi.item(i).text())
  390. for i in range(self.ui.lw_lv2.count()):
  391. lv2s.append(self.ui.lw_lv2.item(i).text())
  392. for i in range(self.ui.lw_vst.count()):
  393. vsts.append(self.ui.lw_vst.item(i).text())
  394. for i in range(self.ui.lw_vst3.count()):
  395. vst3s.append(self.ui.lw_vst3.item(i).text())
  396. for i in range(self.ui.lw_au.count()):
  397. aus.append(self.ui.lw_au.item(i).text())
  398. for i in range(self.ui.lw_gig.count()):
  399. gigs.append(self.ui.lw_gig.item(i).text())
  400. for i in range(self.ui.lw_sf2.count()):
  401. sf2s.append(self.ui.lw_sf2.item(i).text())
  402. for i in range(self.ui.lw_sfz.count()):
  403. sfzs.append(self.ui.lw_sfz.item(i).text())
  404. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(ladspas))
  405. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(dssis))
  406. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(lv2s))
  407. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST, splitter.join(vsts))
  408. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(vst3s))
  409. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_AU, splitter.join(aus))
  410. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_GIG, splitter.join(gigs))
  411. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(sf2s))
  412. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(sfzs))
  413. settings.setValue(CARLA_KEY_PATHS_LADSPA, ladspas)
  414. settings.setValue(CARLA_KEY_PATHS_DSSI, dssis)
  415. settings.setValue(CARLA_KEY_PATHS_LV2, lv2s)
  416. settings.setValue(CARLA_KEY_PATHS_VST, vsts)
  417. settings.setValue(CARLA_KEY_PATHS_VST3, vst3s)
  418. settings.setValue(CARLA_KEY_PATHS_AU, aus)
  419. settings.setValue(CARLA_KEY_PATHS_GIG, gigs)
  420. settings.setValue(CARLA_KEY_PATHS_SF2, sf2s)
  421. settings.setValue(CARLA_KEY_PATHS_SFZ, sfzs)
  422. # --------------------------------------------------------------------------------------------------------
  423. @pyqtSlot()
  424. def slot_resetSettings(self):
  425. # ----------------------------------------------------------------------------------------------------
  426. # Main
  427. if self.ui.lw_page.currentRow() == self.TAB_INDEX_MAIN:
  428. self.ui.le_main_proj_folder.setText(CARLA_DEFAULT_MAIN_PROJECT_FOLDER)
  429. self.ui.ch_main_theme_pro.setChecked(CARLA_DEFAULT_MAIN_USE_PRO_THEME and self.ui.group_main_theme.isEnabled())
  430. self.ui.cb_main_theme_color.setCurrentIndex(self.ui.cb_main_theme_color.findText(CARLA_DEFAULT_MAIN_PRO_THEME_COLOR))
  431. self.ui.sb_main_refresh_interval.setValue(CARLA_DEFAULT_MAIN_REFRESH_INTERVAL)
  432. self.ui.cb_main_use_custom_skins.setChecked(CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS)
  433. # ----------------------------------------------------------------------------------------------------
  434. # Canvas
  435. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_CANVAS:
  436. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(CARLA_DEFAULT_CANVAS_THEME))
  437. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(CARLA_DEFAULT_CANVAS_SIZE))
  438. self.ui.cb_canvas_bezier_lines.setChecked(CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES)
  439. self.ui.cb_canvas_hide_groups.setChecked(CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS)
  440. self.ui.cb_canvas_eyecandy.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_EYE_CANDY
  441. self.ui.cb_canvas_use_opengl.setChecked(CARLA_DEFAULT_CANVAS_USE_OPENGL and self.ui.cb_canvas_use_opengl.isEnabled())
  442. self.ui.cb_canvas_render_aa.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_ANTIALIASING
  443. self.ui.cb_canvas_render_hq_aa.setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and self.ui.cb_canvas_render_hq_aa.isEnabled())
  444. # ----------------------------------------------------------------------------------------------------
  445. # Engine
  446. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_ENGINE:
  447. if not self.host.isPlugin:
  448. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  449. if not self.host.processModeForced:
  450. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  451. self.ui.cb_engine_process_mode_jack.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE)
  452. self.ui.sw_engine_process_mode.setCurrentIndex(0) # show all modes
  453. else:
  454. self.ui.cb_engine_process_mode_other.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE-self.PROCESS_MODE_NON_JACK_PADDING)
  455. self.ui.sw_engine_process_mode.setCurrentIndex(1) # hide single+multi client modes
  456. self.ui.sb_engine_max_params.setValue(CARLA_DEFAULT_MAX_PARAMETERS)
  457. self.ui.ch_engine_uis_always_on_top.setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP)
  458. self.ui.ch_engine_prefer_ui_bridges.setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES)
  459. self.ui.sb_engine_ui_bridges_timeout.setValue(CARLA_DEFAULT_UI_BRIDGES_TIMEOUT)
  460. self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO)
  461. self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES)
  462. # ----------------------------------------------------------------------------------------------------
  463. # Paths
  464. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_PATHS:
  465. curIndex = self.ui.tw_paths.currentIndex()
  466. if curIndex == self.PATH_INDEX_LADSPA:
  467. paths = CARLA_DEFAULT_LADSPA_PATH
  468. paths.sort()
  469. self.ui.lw_ladspa.clear()
  470. for path in paths:
  471. if not path: continue
  472. self.ui.lw_ladspa.addItem(path)
  473. elif curIndex == self.PATH_INDEX_DSSI:
  474. paths = CARLA_DEFAULT_DSSI_PATH
  475. paths.sort()
  476. self.ui.lw_dssi.clear()
  477. for path in paths:
  478. if not path: continue
  479. self.ui.lw_dssi.addItem(path)
  480. elif curIndex == self.PATH_INDEX_LV2:
  481. paths = CARLA_DEFAULT_LV2_PATH
  482. paths.sort()
  483. self.ui.lw_lv2.clear()
  484. for path in paths:
  485. if not path: continue
  486. self.ui.lw_lv2.addItem(path)
  487. elif curIndex == self.PATH_INDEX_VST:
  488. paths = CARLA_DEFAULT_VST_PATH
  489. paths.sort()
  490. self.ui.lw_vst.clear()
  491. for path in paths:
  492. if not path: continue
  493. self.ui.lw_vst.addItem(path)
  494. elif curIndex == self.PATH_INDEX_VST3:
  495. paths = CARLA_DEFAULT_VST3_PATH
  496. paths.sort()
  497. self.ui.lw_vst3.clear()
  498. for path in paths:
  499. if not path: continue
  500. self.ui.lw_vst3.addItem(path)
  501. elif curIndex == self.PATH_INDEX_AU:
  502. paths = CARLA_DEFAULT_AU_PATH
  503. paths.sort()
  504. self.ui.lw_au.clear()
  505. for path in paths:
  506. if not path: continue
  507. self.ui.lw_au.addItem(path)
  508. elif curIndex == self.PATH_INDEX_GIG:
  509. paths = CARLA_DEFAULT_GIG_PATH
  510. paths.sort()
  511. self.ui.lw_gig.clear()
  512. for path in paths:
  513. if not path: continue
  514. self.ui.lw_gig.addItem(path)
  515. elif curIndex == self.PATH_INDEX_SF2:
  516. paths = CARLA_DEFAULT_SF2_PATH
  517. paths.sort()
  518. self.ui.lw_sf2.clear()
  519. for path in paths:
  520. if not path: continue
  521. self.ui.lw_sf2.addItem(path)
  522. elif curIndex == self.PATH_INDEX_SFZ:
  523. paths = CARLA_DEFAULT_SFZ_PATH
  524. paths.sort()
  525. self.ui.lw_sfz.clear()
  526. for path in paths:
  527. if not path: continue
  528. self.ui.lw_sfz.addItem(path)
  529. # --------------------------------------------------------------------------------------------------------
  530. @pyqtSlot()
  531. def slot_getAndSetProjectPath(self):
  532. # FIXME
  533. getAndSetPath(self, self.ui.le_main_proj_folder)
  534. # --------------------------------------------------------------------------------------------------------
  535. @pyqtSlot()
  536. def slot_engineAudioDriverChanged(self):
  537. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  538. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  539. self.ui.tb_engine_driver_config.setEnabled(False)
  540. else:
  541. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  542. self.ui.tb_engine_driver_config.setEnabled(True)
  543. @pyqtSlot()
  544. def slot_showAudioDriverSettings(self):
  545. driverIndex = self.ui.cb_engine_audio_driver.currentIndex()
  546. driverName = self.ui.cb_engine_audio_driver.currentText()
  547. DriverSettingsW(self, self.host, driverIndex, driverName).exec_()
  548. # --------------------------------------------------------------------------------------------------------
  549. @pyqtSlot()
  550. def slot_addPluginPath(self):
  551. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  552. if not newPath:
  553. return
  554. curIndex = self.ui.tw_paths.currentIndex()
  555. if curIndex == self.PATH_INDEX_LADSPA:
  556. self.ui.lw_ladspa.addItem(newPath)
  557. elif curIndex == self.PATH_INDEX_DSSI:
  558. self.ui.lw_dssi.addItem(newPath)
  559. elif curIndex == self.PATH_INDEX_LV2:
  560. self.ui.lw_lv2.addItem(newPath)
  561. elif curIndex == self.PATH_INDEX_VST:
  562. self.ui.lw_vst.addItem(newPath)
  563. elif curIndex == self.PATH_INDEX_VST3:
  564. self.ui.lw_vst3.addItem(newPath)
  565. elif curIndex == self.PATH_INDEX_AU:
  566. self.ui.lw_au.addItem(newPath)
  567. elif curIndex == self.PATH_INDEX_GIG:
  568. self.ui.lw_gig.addItem(newPath)
  569. elif curIndex == self.PATH_INDEX_SF2:
  570. self.ui.lw_sf2.addItem(newPath)
  571. elif curIndex == self.PATH_INDEX_SFZ:
  572. self.ui.lw_sfz.addItem(newPath)
  573. @pyqtSlot()
  574. def slot_removePluginPath(self):
  575. curIndex = self.ui.tw_paths.currentIndex()
  576. if curIndex == self.PATH_INDEX_LADSPA:
  577. self.ui.lw_ladspa.takeItem(self.ui.lw_ladspa.currentRow())
  578. elif curIndex == self.PATH_INDEX_DSSI:
  579. self.ui.lw_dssi.takeItem(self.ui.lw_dssi.currentRow())
  580. elif curIndex == self.PATH_INDEX_LV2:
  581. self.ui.lw_lv2.takeItem(self.ui.lw_lv2.currentRow())
  582. elif curIndex == self.PATH_INDEX_VST:
  583. self.ui.lw_vst.takeItem(self.ui.lw_vst.currentRow())
  584. elif curIndex == self.PATH_INDEX_VST3:
  585. self.ui.lw_vst3.takeItem(self.ui.lw_vst3.currentRow())
  586. elif curIndex == self.PATH_INDEX_AU:
  587. self.ui.lw_au.takeItem(self.ui.lw_au.currentRow())
  588. elif curIndex == self.PATH_INDEX_GIG:
  589. self.ui.lw_gig.takeItem(self.ui.lw_gig.currentRow())
  590. elif curIndex == self.PATH_INDEX_SF2:
  591. self.ui.lw_sf2.takeItem(self.ui.lw_sf2.currentRow())
  592. elif curIndex == self.PATH_INDEX_SFZ:
  593. self.ui.lw_sfz.takeItem(self.ui.lw_sfz.currentRow())
  594. @pyqtSlot()
  595. def slot_changePluginPath(self):
  596. curIndex = self.ui.tw_paths.currentIndex()
  597. if curIndex == self.PATH_INDEX_LADSPA:
  598. currentPath = self.ui.lw_ladspa.currentItem().text()
  599. elif curIndex == self.PATH_INDEX_DSSI:
  600. currentPath = self.ui.lw_dssi.currentItem().text()
  601. elif curIndex == self.PATH_INDEX_LV2:
  602. currentPath = self.ui.lw_lv2.currentItem().text()
  603. elif curIndex == self.PATH_INDEX_VST:
  604. currentPath = self.ui.lw_vst.currentItem().text()
  605. elif curIndex == self.PATH_INDEX_VST3:
  606. currentPath = self.ui.lw_vst3.currentItem().text()
  607. elif curIndex == self.PATH_INDEX_AU:
  608. currentPath = self.ui.lw_au.currentItem().text()
  609. elif curIndex == self.PATH_INDEX_GIG:
  610. currentPath = self.ui.lw_gig.currentItem().text()
  611. elif curIndex == self.PATH_INDEX_SF2:
  612. currentPath = self.ui.lw_sf2.currentItem().text()
  613. elif curIndex == self.PATH_INDEX_SFZ:
  614. currentPath = self.ui.lw_sfz.currentItem().text()
  615. else:
  616. currentPath = ""
  617. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  618. if not newPath:
  619. return
  620. if curIndex == self.PATH_INDEX_LADSPA:
  621. self.ui.lw_ladspa.currentItem().setText(newPath)
  622. elif curIndex == self.PATH_INDEX_DSSI:
  623. self.ui.lw_dssi.currentItem().setText(newPath)
  624. elif curIndex == self.PATH_INDEX_LV2:
  625. self.ui.lw_lv2.currentItem().setText(newPath)
  626. elif curIndex == self.PATH_INDEX_VST:
  627. self.ui.lw_vst.currentItem().setText(newPath)
  628. elif curIndex == self.PATH_INDEX_VST3:
  629. self.ui.lw_vst3.currentItem().setText(newPath)
  630. elif curIndex == self.PATH_INDEX_AU:
  631. self.ui.lw_au.currentItem().setText(newPath)
  632. elif curIndex == self.PATH_INDEX_GIG:
  633. self.ui.lw_gig.currentItem().setText(newPath)
  634. elif curIndex == self.PATH_INDEX_SF2:
  635. self.ui.lw_sf2.currentItem().setText(newPath)
  636. elif curIndex == self.PATH_INDEX_SFZ:
  637. self.ui.lw_sfz.currentItem().setText(newPath)
  638. # --------------------------------------------------------------------------------------------------------
  639. @pyqtSlot(int)
  640. def slot_pluginPathTabChanged(self, index):
  641. if index == self.PATH_INDEX_LADSPA:
  642. row = self.ui.lw_ladspa.currentRow()
  643. elif index == self.PATH_INDEX_DSSI:
  644. row = self.ui.lw_dssi.currentRow()
  645. elif index == self.PATH_INDEX_LV2:
  646. row = self.ui.lw_lv2.currentRow()
  647. elif index == self.PATH_INDEX_VST:
  648. row = self.ui.lw_vst.currentRow()
  649. elif index == self.PATH_INDEX_VST3:
  650. row = self.ui.lw_vst3.currentRow()
  651. elif index == self.PATH_INDEX_AU:
  652. row = self.ui.lw_au.currentRow()
  653. elif index == self.PATH_INDEX_GIG:
  654. row = self.ui.lw_gig.currentRow()
  655. elif index == self.PATH_INDEX_SF2:
  656. row = self.ui.lw_sf2.currentRow()
  657. elif index == self.PATH_INDEX_SFZ:
  658. row = self.ui.lw_sfz.currentRow()
  659. else:
  660. row = -1
  661. check = bool(row >= 0)
  662. self.ui.b_paths_remove.setEnabled(check)
  663. self.ui.b_paths_change.setEnabled(check)
  664. @pyqtSlot(int)
  665. def slot_pluginPathRowChanged(self, row):
  666. check = bool(row >= 0)
  667. self.ui.b_paths_remove.setEnabled(check)
  668. self.ui.b_paths_change.setEnabled(check)
  669. # --------------------------------------------------------------------------------------------------------
  670. def done(self, r):
  671. QDialog.done(self, r)
  672. self.close()
  673. # ------------------------------------------------------------------------------------------------------------
  674. # Main
  675. if __name__ == '__main__':
  676. from carla_app import CarlaApplication
  677. from carla_host import initHost, loadHostSettings
  678. app = CarlaApplication()
  679. host = initHost("Settings", None, False, False, False)
  680. loadHostSettings(host)
  681. gui = CarlaSettingsW(None, host, True, True)
  682. gui.show()
  683. app.exit_exec()
  684. # ------------------------------------------------------------------------------------------------------------