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.

788 lines
35KB

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