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.

858 lines
39KB

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