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.

839 lines
38KB

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