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.

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