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.

878 lines
40KB

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