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.

864 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. 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
  352. settings.setValue(CARLA_KEY_ENGINE_PROCESS_MODE, processMode)
  353. self.host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, processMode, "")
  354. forceStereo = self.ui.ch_engine_force_stereo.isChecked()
  355. preferPluginBridges = self.ui.ch_engine_prefer_plugin_bridges.isChecked()
  356. preferUIBridges = self.ui.ch_engine_prefer_ui_bridges.isChecked()
  357. uisAlwaysOnTop = self.ui.ch_engine_uis_always_on_top.isChecked()
  358. maxParameters = self.ui.sb_engine_max_params.value()
  359. uiBridgesTimeout = self.ui.sb_engine_ui_bridges_timeout.value()
  360. settings.setValue(CARLA_KEY_ENGINE_FORCE_STEREO, forceStereo)
  361. settings.setValue(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, preferPluginBridges)
  362. settings.setValue(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, preferUIBridges)
  363. settings.setValue(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, uisAlwaysOnTop)
  364. settings.setValue(CARLA_KEY_ENGINE_MAX_PARAMETERS, maxParameters)
  365. settings.setValue(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, uiBridgesTimeout)
  366. self.host.set_engine_option(ENGINE_OPTION_FORCE_STEREO, forceStereo, "")
  367. self.host.set_engine_option(ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, preferPluginBridges, "")
  368. self.host.set_engine_option(ENGINE_OPTION_PREFER_UI_BRIDGES, preferUIBridges, "")
  369. self.host.set_engine_option(ENGINE_OPTION_UIS_ALWAYS_ON_TOP, uisAlwaysOnTop, "")
  370. self.host.set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, maxParameters, "")
  371. self.host.set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, uiBridgesTimeout, "")
  372. # ----------------------------------------------------------------------------------------------------
  373. # Paths
  374. ladspas = []
  375. dssis = []
  376. lv2s = []
  377. vsts = []
  378. vst3s = []
  379. aus = []
  380. gigs = []
  381. sf2s = []
  382. sfzs = []
  383. for i in range(self.ui.lw_ladspa.count()):
  384. ladspas.append(self.ui.lw_ladspa.item(i).text())
  385. for i in range(self.ui.lw_dssi.count()):
  386. dssis.append(self.ui.lw_dssi.item(i).text())
  387. for i in range(self.ui.lw_lv2.count()):
  388. lv2s.append(self.ui.lw_lv2.item(i).text())
  389. for i in range(self.ui.lw_vst.count()):
  390. vsts.append(self.ui.lw_vst.item(i).text())
  391. for i in range(self.ui.lw_vst3.count()):
  392. vst3s.append(self.ui.lw_vst3.item(i).text())
  393. for i in range(self.ui.lw_au.count()):
  394. aus.append(self.ui.lw_au.item(i).text())
  395. for i in range(self.ui.lw_gig.count()):
  396. gigs.append(self.ui.lw_gig.item(i).text())
  397. for i in range(self.ui.lw_sf2.count()):
  398. sf2s.append(self.ui.lw_sf2.item(i).text())
  399. for i in range(self.ui.lw_sfz.count()):
  400. sfzs.append(self.ui.lw_sfz.item(i).text())
  401. settings.setValue(CARLA_KEY_PATHS_LADSPA, ladspas)
  402. settings.setValue(CARLA_KEY_PATHS_DSSI, dssis)
  403. settings.setValue(CARLA_KEY_PATHS_LV2, lv2s)
  404. settings.setValue(CARLA_KEY_PATHS_VST, vsts)
  405. settings.setValue(CARLA_KEY_PATHS_VST3, vst3s)
  406. settings.setValue(CARLA_KEY_PATHS_AU, aus)
  407. settings.setValue(CARLA_KEY_PATHS_GIG, gigs)
  408. settings.setValue(CARLA_KEY_PATHS_SF2, sf2s)
  409. settings.setValue(CARLA_KEY_PATHS_SFZ, sfzs)
  410. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(ladspas))
  411. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(dssis))
  412. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(lv2s))
  413. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST, splitter.join(vsts))
  414. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(vst3s))
  415. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_AU, splitter.join(aus))
  416. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_GIG, splitter.join(gigs))
  417. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(sf2s))
  418. self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(sfzs))
  419. # --------------------------------------------------------------------------------------------------------
  420. @pyqtSlot()
  421. def slot_resetSettings(self):
  422. # ----------------------------------------------------------------------------------------------------
  423. # Main
  424. if self.ui.lw_page.currentRow() == self.TAB_INDEX_MAIN:
  425. self.ui.le_main_proj_folder.setText(CARLA_DEFAULT_MAIN_PROJECT_FOLDER)
  426. self.ui.ch_main_theme_pro.setChecked(CARLA_DEFAULT_MAIN_USE_PRO_THEME and self.ui.group_main_theme.isEnabled())
  427. self.ui.cb_main_theme_color.setCurrentIndex(self.ui.cb_main_theme_color.findText(CARLA_DEFAULT_MAIN_PRO_THEME_COLOR))
  428. self.ui.sb_main_refresh_interval.setValue(CARLA_DEFAULT_MAIN_REFRESH_INTERVAL)
  429. self.ui.cb_main_use_custom_skins.setChecked(CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS)
  430. # ----------------------------------------------------------------------------------------------------
  431. # Canvas
  432. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_CANVAS:
  433. self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(CARLA_DEFAULT_CANVAS_THEME))
  434. self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(CARLA_DEFAULT_CANVAS_SIZE))
  435. self.ui.cb_canvas_bezier_lines.setChecked(CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES)
  436. self.ui.cb_canvas_hide_groups.setChecked(CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS)
  437. self.ui.cb_canvas_eyecandy.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_EYE_CANDY
  438. self.ui.cb_canvas_use_opengl.setChecked(CARLA_DEFAULT_CANVAS_USE_OPENGL and self.ui.cb_canvas_use_opengl.isEnabled())
  439. self.ui.cb_canvas_render_aa.setCheckState(Qt.PartiallyChecked) # CARLA_DEFAULT_CANVAS_ANTIALIASING
  440. self.ui.cb_canvas_render_hq_aa.setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and self.ui.cb_canvas_render_hq_aa.isEnabled())
  441. # ----------------------------------------------------------------------------------------------------
  442. # Engine
  443. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_ENGINE:
  444. if not self.host.isPlugin:
  445. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  446. if not self.host.processModeForced:
  447. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  448. self.ui.cb_engine_process_mode_jack.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE)
  449. self.ui.sw_engine_process_mode.setCurrentIndex(0) # show all modes
  450. else:
  451. self.ui.cb_engine_process_mode_other.setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE-self.PROCESS_MODE_NON_JACK_PADDING)
  452. self.ui.sw_engine_process_mode.setCurrentIndex(1) # hide single+multi client modes
  453. self.ui.sb_engine_max_params.setValue(CARLA_DEFAULT_MAX_PARAMETERS)
  454. self.ui.ch_engine_uis_always_on_top.setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP)
  455. self.ui.ch_engine_prefer_ui_bridges.setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES)
  456. self.ui.sb_engine_ui_bridges_timeout.setValue(CARLA_DEFAULT_UI_BRIDGES_TIMEOUT)
  457. self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO)
  458. self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES)
  459. # ----------------------------------------------------------------------------------------------------
  460. # Paths
  461. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_PATHS:
  462. curIndex = self.ui.tw_paths.currentIndex()
  463. if curIndex == self.PATH_INDEX_LADSPA:
  464. paths = CARLA_DEFAULT_LADSPA_PATH
  465. paths.sort()
  466. self.ui.lw_ladspa.clear()
  467. for path in paths:
  468. if not path: continue
  469. self.ui.lw_ladspa.addItem(path)
  470. elif curIndex == self.PATH_INDEX_DSSI:
  471. paths = CARLA_DEFAULT_DSSI_PATH
  472. paths.sort()
  473. self.ui.lw_dssi.clear()
  474. for path in paths:
  475. if not path: continue
  476. self.ui.lw_dssi.addItem(path)
  477. elif curIndex == self.PATH_INDEX_LV2:
  478. paths = CARLA_DEFAULT_LV2_PATH
  479. paths.sort()
  480. self.ui.lw_lv2.clear()
  481. for path in paths:
  482. if not path: continue
  483. self.ui.lw_lv2.addItem(path)
  484. elif curIndex == self.PATH_INDEX_VST:
  485. paths = CARLA_DEFAULT_VST_PATH
  486. paths.sort()
  487. self.ui.lw_vst.clear()
  488. for path in paths:
  489. if not path: continue
  490. self.ui.lw_vst.addItem(path)
  491. elif curIndex == self.PATH_INDEX_VST3:
  492. paths = CARLA_DEFAULT_VST3_PATH
  493. paths.sort()
  494. self.ui.lw_vst3.clear()
  495. for path in paths:
  496. if not path: continue
  497. self.ui.lw_vst3.addItem(path)
  498. elif curIndex == self.PATH_INDEX_AU:
  499. paths = CARLA_DEFAULT_AU_PATH
  500. paths.sort()
  501. self.ui.lw_au.clear()
  502. for path in paths:
  503. if not path: continue
  504. self.ui.lw_au.addItem(path)
  505. elif curIndex == self.PATH_INDEX_GIG:
  506. paths = CARLA_DEFAULT_GIG_PATH
  507. paths.sort()
  508. self.ui.lw_gig.clear()
  509. for path in paths:
  510. if not path: continue
  511. self.ui.lw_gig.addItem(path)
  512. elif curIndex == self.PATH_INDEX_SF2:
  513. paths = CARLA_DEFAULT_SF2_PATH
  514. paths.sort()
  515. self.ui.lw_sf2.clear()
  516. for path in paths:
  517. if not path: continue
  518. self.ui.lw_sf2.addItem(path)
  519. elif curIndex == self.PATH_INDEX_SFZ:
  520. paths = CARLA_DEFAULT_SFZ_PATH
  521. paths.sort()
  522. self.ui.lw_sfz.clear()
  523. for path in paths:
  524. if not path: continue
  525. self.ui.lw_sfz.addItem(path)
  526. # --------------------------------------------------------------------------------------------------------
  527. @pyqtSlot()
  528. def slot_getAndSetProjectPath(self):
  529. # FIXME
  530. getAndSetPath(self, self.ui.le_main_proj_folder)
  531. # --------------------------------------------------------------------------------------------------------
  532. @pyqtSlot()
  533. def slot_engineAudioDriverChanged(self):
  534. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  535. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  536. self.ui.tb_engine_driver_config.setEnabled(False)
  537. else:
  538. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  539. self.ui.tb_engine_driver_config.setEnabled(True)
  540. @pyqtSlot()
  541. def slot_showAudioDriverSettings(self):
  542. driverIndex = self.ui.cb_engine_audio_driver.currentIndex()
  543. driverName = self.ui.cb_engine_audio_driver.currentText()
  544. DriverSettingsW(self, self.host, driverIndex, driverName).exec_()
  545. # --------------------------------------------------------------------------------------------------------
  546. @pyqtSlot()
  547. def slot_addPluginPath(self):
  548. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  549. if not newPath:
  550. return
  551. curIndex = self.ui.tw_paths.currentIndex()
  552. if curIndex == self.PATH_INDEX_LADSPA:
  553. self.ui.lw_ladspa.addItem(newPath)
  554. elif curIndex == self.PATH_INDEX_DSSI:
  555. self.ui.lw_dssi.addItem(newPath)
  556. elif curIndex == self.PATH_INDEX_LV2:
  557. self.ui.lw_lv2.addItem(newPath)
  558. elif curIndex == self.PATH_INDEX_VST:
  559. self.ui.lw_vst.addItem(newPath)
  560. elif curIndex == self.PATH_INDEX_VST3:
  561. self.ui.lw_vst3.addItem(newPath)
  562. elif curIndex == self.PATH_INDEX_AU:
  563. self.ui.lw_au.addItem(newPath)
  564. elif curIndex == self.PATH_INDEX_GIG:
  565. self.ui.lw_gig.addItem(newPath)
  566. elif curIndex == self.PATH_INDEX_SF2:
  567. self.ui.lw_sf2.addItem(newPath)
  568. elif curIndex == self.PATH_INDEX_SFZ:
  569. self.ui.lw_sfz.addItem(newPath)
  570. @pyqtSlot()
  571. def slot_removePluginPath(self):
  572. curIndex = self.ui.tw_paths.currentIndex()
  573. if curIndex == self.PATH_INDEX_LADSPA:
  574. self.ui.lw_ladspa.takeItem(self.ui.lw_ladspa.currentRow())
  575. elif curIndex == self.PATH_INDEX_DSSI:
  576. self.ui.lw_dssi.takeItem(self.ui.lw_dssi.currentRow())
  577. elif curIndex == self.PATH_INDEX_LV2:
  578. self.ui.lw_lv2.takeItem(self.ui.lw_lv2.currentRow())
  579. elif curIndex == self.PATH_INDEX_VST:
  580. self.ui.lw_vst.takeItem(self.ui.lw_vst.currentRow())
  581. elif curIndex == self.PATH_INDEX_VST3:
  582. self.ui.lw_vst3.takeItem(self.ui.lw_vst3.currentRow())
  583. elif curIndex == self.PATH_INDEX_AU:
  584. self.ui.lw_au.takeItem(self.ui.lw_au.currentRow())
  585. elif curIndex == self.PATH_INDEX_GIG:
  586. self.ui.lw_gig.takeItem(self.ui.lw_gig.currentRow())
  587. elif curIndex == self.PATH_INDEX_SF2:
  588. self.ui.lw_sf2.takeItem(self.ui.lw_sf2.currentRow())
  589. elif curIndex == self.PATH_INDEX_SFZ:
  590. self.ui.lw_sfz.takeItem(self.ui.lw_sfz.currentRow())
  591. @pyqtSlot()
  592. def slot_changePluginPath(self):
  593. curIndex = self.ui.tw_paths.currentIndex()
  594. if curIndex == self.PATH_INDEX_LADSPA:
  595. currentPath = self.ui.lw_ladspa.currentItem().text()
  596. elif curIndex == self.PATH_INDEX_DSSI:
  597. currentPath = self.ui.lw_dssi.currentItem().text()
  598. elif curIndex == self.PATH_INDEX_LV2:
  599. currentPath = self.ui.lw_lv2.currentItem().text()
  600. elif curIndex == self.PATH_INDEX_VST:
  601. currentPath = self.ui.lw_vst.currentItem().text()
  602. elif curIndex == self.PATH_INDEX_VST3:
  603. currentPath = self.ui.lw_vst3.currentItem().text()
  604. elif curIndex == self.PATH_INDEX_AU:
  605. currentPath = self.ui.lw_au.currentItem().text()
  606. elif curIndex == self.PATH_INDEX_GIG:
  607. currentPath = self.ui.lw_gig.currentItem().text()
  608. elif curIndex == self.PATH_INDEX_SF2:
  609. currentPath = self.ui.lw_sf2.currentItem().text()
  610. elif curIndex == self.PATH_INDEX_SFZ:
  611. currentPath = self.ui.lw_sfz.currentItem().text()
  612. else:
  613. currentPath = ""
  614. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  615. if not newPath:
  616. return
  617. if curIndex == self.PATH_INDEX_LADSPA:
  618. self.ui.lw_ladspa.currentItem().setText(newPath)
  619. elif curIndex == self.PATH_INDEX_DSSI:
  620. self.ui.lw_dssi.currentItem().setText(newPath)
  621. elif curIndex == self.PATH_INDEX_LV2:
  622. self.ui.lw_lv2.currentItem().setText(newPath)
  623. elif curIndex == self.PATH_INDEX_VST:
  624. self.ui.lw_vst.currentItem().setText(newPath)
  625. elif curIndex == self.PATH_INDEX_VST3:
  626. self.ui.lw_vst3.currentItem().setText(newPath)
  627. elif curIndex == self.PATH_INDEX_AU:
  628. self.ui.lw_au.currentItem().setText(newPath)
  629. elif curIndex == self.PATH_INDEX_GIG:
  630. self.ui.lw_gig.currentItem().setText(newPath)
  631. elif curIndex == self.PATH_INDEX_SF2:
  632. self.ui.lw_sf2.currentItem().setText(newPath)
  633. elif curIndex == self.PATH_INDEX_SFZ:
  634. self.ui.lw_sfz.currentItem().setText(newPath)
  635. # --------------------------------------------------------------------------------------------------------
  636. @pyqtSlot(int)
  637. def slot_pluginPathTabChanged(self, index):
  638. if index == self.PATH_INDEX_LADSPA:
  639. row = self.ui.lw_ladspa.currentRow()
  640. elif index == self.PATH_INDEX_DSSI:
  641. row = self.ui.lw_dssi.currentRow()
  642. elif index == self.PATH_INDEX_LV2:
  643. row = self.ui.lw_lv2.currentRow()
  644. elif index == self.PATH_INDEX_VST:
  645. row = self.ui.lw_vst.currentRow()
  646. elif index == self.PATH_INDEX_VST3:
  647. row = self.ui.lw_vst3.currentRow()
  648. elif index == self.PATH_INDEX_AU:
  649. row = self.ui.lw_au.currentRow()
  650. elif index == self.PATH_INDEX_GIG:
  651. row = self.ui.lw_gig.currentRow()
  652. elif index == self.PATH_INDEX_SF2:
  653. row = self.ui.lw_sf2.currentRow()
  654. elif index == self.PATH_INDEX_SFZ:
  655. row = self.ui.lw_sfz.currentRow()
  656. else:
  657. row = -1
  658. check = bool(row >= 0)
  659. self.ui.b_paths_remove.setEnabled(check)
  660. self.ui.b_paths_change.setEnabled(check)
  661. @pyqtSlot(int)
  662. def slot_pluginPathRowChanged(self, row):
  663. check = bool(row >= 0)
  664. self.ui.b_paths_remove.setEnabled(check)
  665. self.ui.b_paths_change.setEnabled(check)
  666. # --------------------------------------------------------------------------------------------------------
  667. def done(self, r):
  668. QDialog.done(self, r)
  669. self.close()
  670. # ------------------------------------------------------------------------------------------------------------
  671. # Main
  672. if __name__ == '__main__':
  673. from carla_app import CarlaApplication
  674. from carla_host import initHost, loadHostSettings
  675. app = CarlaApplication()
  676. host = initHost("Settings", None, False, False, False)
  677. loadHostSettings(host)
  678. gui = CarlaSettingsW(None, host, True, True, True)
  679. gui.show()
  680. app.exit_exec()
  681. # ------------------------------------------------------------------------------------------------------------