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.

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