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.

648 lines
28KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla settings code
  4. # Copyright (C) 2011-2013 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 (Global)
  19. try:
  20. from PyQt5.QtCore import QByteArray, QSettings
  21. from PyQt5.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  22. from PyQt5.QtWidgets import QDialog, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  23. except:
  24. from PyQt4.QtCore import QByteArray, QSettings
  25. from PyQt4.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  26. from PyQt4.QtGui import QDialog, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  27. # ------------------------------------------------------------------------------------------------------------
  28. # Imports (Custom)
  29. #import patchcanvas
  30. import ui_carla_settings
  31. import ui_carla_settings_driver
  32. from carla_shared import *
  33. # ------------------------------------------------------------------------------------------------------------
  34. # Carla defaults
  35. # Canvas size
  36. CARLA_DEFAULT_CANVAS_WIDTH = 3100
  37. CARLA_DEFAULT_CANVAS_HEIGHT = 2400
  38. # Engine settings
  39. CARLA_DEFAULT_RUN_DISCOVERY_CHECKS = True
  40. CARLA_DEFAULT_FORCE_STEREO = False
  41. CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES = False
  42. CARLA_DEFAULT_PREFER_UI_BRIDGES = True
  43. CARLA_DEFAULT_UIS_ALWAYS_ON_TOP = True
  44. CARLA_DEFAULT_MAX_PARAMETERS = MAX_DEFAULT_PARAMETERS
  45. CARLA_DEFAULT_UI_BRIDGES_TIMEOUT = 4000
  46. CARLA_DEFAULT_AUDIO_NUM_PERIODS = 2
  47. CARLA_DEFAULT_AUDIO_BUFFER_SIZE = 512
  48. CARLA_DEFAULT_AUDIO_SAMPLE_RATE = 44100
  49. if WINDOWS:
  50. CARLA_DEFAULT_AUDIO_DRIVER = "DirectSound"
  51. elif MACOS:
  52. CARLA_DEFAULT_AUDIO_DRIVER = "CoreAudio"
  53. else:
  54. CARLA_DEFAULT_AUDIO_DRIVER = "JACK"
  55. if LINUX:
  56. CARLA_DEFAULT_PROCESS_MODE = PROCESS_MODE_MULTIPLE_CLIENTS
  57. CARLA_DEFAULT_TRANSPORT_MODE = TRANSPORT_MODE_JACK
  58. else:
  59. CARLA_DEFAULT_PROCESS_MODE = PROCESS_MODE_CONTINUOUS_RACK
  60. CARLA_DEFAULT_TRANSPORT_MODE = TRANSPORT_MODE_INTERNAL
  61. # ------------------------------------------------------------------------------------------------------------
  62. # ...
  63. BUFFER_SIZE_LIST = (16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192)
  64. SAMPLE_RATE_LIST = (22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000)
  65. # ------------------------------------------------------------------------------------------------------------
  66. # Driver Settings
  67. class DriverSettingsW(QDialog):
  68. def __init__(self, parent, driverIndex, driverName):
  69. QDialog.__init__(self, parent)
  70. self.ui = ui_carla_settings_driver.Ui_DriverSettingsW()
  71. self.ui.setupUi(self)
  72. if driverName == "JACK":
  73. print("This dialog is not compatible with JACK")
  74. return
  75. # -------------------------------------------------------------
  76. # Internal stuff
  77. self.fDriverIndex = driverIndex
  78. self.fDriverName = driverName
  79. self.fDeviceNames = Carla.host.get_engine_driver_device_names(driverIndex) if Carla.host is not None else []
  80. # -------------------------------------------------------------
  81. # Set-up GUI
  82. for name in self.fDeviceNames:
  83. self.ui.cb_device.addItem(name)
  84. for bsize in BUFFER_SIZE_LIST:
  85. self.ui.cb_buffersize.addItem(str(bsize))
  86. for srate in SAMPLE_RATE_LIST:
  87. self.ui.cb_samplerate.addItem(str(srate))
  88. # -------------------------------------------------------------
  89. # Load settings
  90. self.loadSettings()
  91. # -------------------------------------------------------------
  92. # Set-up connections
  93. self.accepted.connect(self.slot_saveSettings)
  94. # -------------------------------------------------------------
  95. def loadSettings(self):
  96. settings = QSettings()
  97. audioDevice = settings.value("Engine/Driver-%s/Device" % self.fDriverName, "", type=str)
  98. audioNumPeriods = settings.value("Engine/Driver-%s/NumPeriods" % self.fDriverName, CARLA_DEFAULT_AUDIO_NUM_PERIODS, type=int)
  99. audioBufferSize = settings.value("Engine/Driver-%s/BufferSize" % self.fDriverName, CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int)
  100. audioSampleRate = settings.value("Engine/Driver-%s/SampleRate" % self.fDriverName, CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int)
  101. if audioDevice and audioDevice in self.fDeviceNames:
  102. self.ui.cb_device.setCurrentIndex(self.fDeviceNames.index(audioDevice))
  103. else:
  104. self.ui.cb_device.setCurrentIndex(-1)
  105. if 2 < audioNumPeriods < 3:
  106. self.ui.sb_numperiods.setValue(audioNumPeriods)
  107. else:
  108. self.ui.sb_numperiods.setValue(CARLA_DEFAULT_AUDIO_NUM_PERIODS)
  109. if audioBufferSize and audioBufferSize in BUFFER_SIZE_LIST:
  110. self.ui.cb_buffersize.setCurrentIndex(BUFFER_SIZE_LIST.index(audioBufferSize))
  111. else:
  112. self.ui.cb_buffersize.setCurrentIndex(BUFFER_SIZE_LIST.index(CARLA_DEFAULT_AUDIO_BUFFER_SIZE))
  113. if audioSampleRate and audioSampleRate in SAMPLE_RATE_LIST:
  114. self.ui.cb_samplerate.setCurrentIndex(SAMPLE_RATE_LIST.index(audioSampleRate))
  115. else:
  116. self.ui.cb_samplerate.setCurrentIndex(SAMPLE_RATE_LIST.index(CARLA_DEFAULT_AUDIO_SAMPLE_RATE))
  117. @pyqtSlot()
  118. def slot_saveSettings(self):
  119. settings = QSettings()
  120. settings.setValue("Engine/Driver-%s/Device" % self.fDriverName, self.ui.cb_device.currentText())
  121. settings.setValue("Engine/Driver-%s/NumPeriods" % self.fDriverName, self.ui.sb_numperiods.value())
  122. settings.setValue("Engine/Driver-%s/BufferSize" % self.fDriverName, self.ui.cb_buffersize.currentText())
  123. settings.setValue("Engine/Driver-%s/SampleRate" % self.fDriverName, self.ui.cb_samplerate.currentText())
  124. def done(self, r):
  125. QDialog.done(self, r)
  126. self.close()
  127. # ------------------------------------------------------------------------------------------------------------
  128. # Settings Dialog
  129. class CarlaSettingsW(QDialog):
  130. # Tab indexes
  131. TAB_INDEX_MAIN = 0
  132. TAB_INDEX_CANVAS = 1
  133. TAB_INDEX_CARLA_ENGINE = 2
  134. TAB_INDEX_CARLA_PATHS = 3
  135. TAB_INDEX_NONE = 4
  136. # Single and Multiple client mode is only for JACK,
  137. # but we still want to match QComboBox index to defines,
  138. # so add +2 pos padding if driverName != "JACK".
  139. PROCESS_MODE_NON_JACK_PADDING = 2
  140. def __init__(self, parent):
  141. QDialog.__init__(self, parent, hasGL)
  142. self.ui = ui_carla_settings.Ui_CarlaSettingsW()
  143. self.ui.setupUi(self)
  144. # -------------------------------------------------------------
  145. # Set-up GUI
  146. driverCount = Carla.host.get_engine_driver_count() if Carla.host is not None else 0
  147. for i in range(driverCount):
  148. driverName = cString(Carla.host.get_engine_driver_name(i))
  149. self.ui.cb_engine_audio_driver.addItem(driverName)
  150. # -------------------------------------------------------------
  151. # Load settings
  152. self.loadSettings()
  153. if not hasGL:
  154. self.ui.cb_canvas_use_opengl.setChecked(False)
  155. self.ui.cb_canvas_use_opengl.setEnabled(False)
  156. if WINDOWS:
  157. self.ui.group_theme.setEnabled(False)
  158. self.ui.ch_theme_pro.setChecked(False)
  159. # -------------------------------------------------------------
  160. # Set-up connections
  161. #self.connect(self, SIGNAL("accepted()"), SLOT("slot_saveSettings()"))
  162. #self.connect(self.ui.buttonBox.button(QDialogButtonBox.Reset), SIGNAL("clicked()"), SLOT("slot_resetSettings()"))
  163. #self.connect(self.ui.b_main_def_folder_open, SIGNAL("clicked()"), SLOT("slot_getAndSetProjectPath()"))
  164. #self.connect(self.ui.cb_engine_audio_driver, SIGNAL("currentIndexChanged(int)"), SLOT("slot_engineAudioDriverChanged()"))
  165. #self.connect(self.ui.tb_engine_driver_config, SIGNAL("clicked()"), SLOT("slot_showAudioDriverSettings()"))
  166. #self.connect(self.ui.b_paths_add, SIGNAL("clicked()"), SLOT("slot_addPluginPath()"))
  167. #self.connect(self.ui.b_paths_remove, SIGNAL("clicked()"), SLOT("slot_removePluginPath()"))
  168. #self.connect(self.ui.b_paths_change, SIGNAL("clicked()"), SLOT("slot_changePluginPath()"))
  169. #self.connect(self.ui.tw_paths, SIGNAL("currentChanged(int)"), SLOT("slot_pluginPathTabChanged(int)"))
  170. #self.connect(self.ui.lw_ladspa, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  171. #self.connect(self.ui.lw_dssi, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  172. #self.connect(self.ui.lw_lv2, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  173. #self.connect(self.ui.lw_vst, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  174. #self.connect(self.ui.lw_sf2, SIGNAL("currentRowChanged(int)"), SLOT("slot_pluginPathRowChanged(int)"))
  175. # -------------------------------------------------------------
  176. # Post-connect setup
  177. # TODO - add AU and csound, hide AU on non-mac
  178. self.ui.lw_ladspa.setCurrentRow(0)
  179. self.ui.lw_dssi.setCurrentRow(0)
  180. self.ui.lw_lv2.setCurrentRow(0)
  181. self.ui.lw_vst.setCurrentRow(0)
  182. self.ui.lw_gig.setCurrentRow(0)
  183. self.ui.lw_sf2.setCurrentRow(0)
  184. self.ui.lw_sfz.setCurrentRow(0)
  185. self.ui.lw_page.setCurrentCell(0, 0)
  186. def loadSettings(self):
  187. settings = QSettings()
  188. # ---------------------------------------
  189. self.ui.le_main_def_folder.setText(settings.value("Main/DefaultProjectFolder", HOME, type=str))
  190. self.ui.ch_theme_pro.setChecked(settings.value("Main/UseProTheme", True, type=bool))
  191. self.ui.sb_gui_refresh.setValue(settings.value("Main/RefreshInterval", 50, type=int))
  192. themeColor = settings.value("Main/ProThemeColor", "Black", type=str)
  193. if themeColor == "System":
  194. self.ui.cb_theme_color.setCurrentIndex(1)
  195. else:
  196. self.ui.cb_theme_color.setCurrentIndex(0)
  197. # ---------------------------------------
  198. #self.ui.cb_canvas_hide_groups.setChecked(settings.value("Canvas/AutoHideGroups", False, type=bool))
  199. #self.ui.cb_canvas_bezier_lines.setChecked(settings.value("Canvas/UseBezierLines", True, type=bool))
  200. #self.ui.cb_canvas_eyecandy.setCheckState(settings.value("Canvas/EyeCandy", patchcanvas.EYECANDY_SMALL, type=int))
  201. #self.ui.cb_canvas_use_opengl.setChecked(settings.value("Canvas/UseOpenGL", False, type=bool))
  202. #self.ui.cb_canvas_render_aa.setCheckState(settings.value("Canvas/Antialiasing", patchcanvas.ANTIALIASING_SMALL, type=int))
  203. #self.ui.cb_canvas_render_hq_aa.setChecked(settings.value("Canvas/HighQualityAntialiasing", False, type=bool))
  204. #canvasThemeName = settings.value("Canvas/Theme", patchcanvas.getDefaultThemeName(), type=str)
  205. #for i in range(patchcanvas.Theme.THEME_MAX):
  206. #thisThemeName = patchcanvas.getThemeName(i)
  207. #self.ui.cb_canvas_theme.addItem(thisThemeName)
  208. #if thisThemeName == canvasThemeName:
  209. #self.ui.cb_canvas_theme.setCurrentIndex(i)
  210. # --------------------------------------------
  211. audioDriver = settings.value("Engine/AudioDriver", CARLA_DEFAULT_AUDIO_DRIVER, type=str)
  212. for i in range(self.ui.cb_engine_audio_driver.count()):
  213. if self.ui.cb_engine_audio_driver.itemText(i) == audioDriver:
  214. self.ui.cb_engine_audio_driver.setCurrentIndex(i)
  215. break
  216. else:
  217. self.ui.cb_engine_audio_driver.setCurrentIndex(-1)
  218. if audioDriver == "JACK":
  219. processModeIndex = settings.value("Engine/ProcessMode", PROCESS_MODE_MULTIPLE_CLIENTS, type=int)
  220. self.ui.cb_engine_process_mode_jack.setCurrentIndex(processModeIndex)
  221. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  222. else:
  223. processModeIndex = settings.value("Engine/ProcessMode", PROCESS_MODE_CONTINUOUS_RACK, type=int)
  224. processModeIndex -= self.PROCESS_MODE_NON_JACK_PADDING
  225. self.ui.cb_engine_process_mode_other.setCurrentIndex(processModeIndex)
  226. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  227. self.ui.sb_engine_max_params.setValue(settings.value("Engine/MaxParameters", CARLA_DEFAULT_MAX_PARAMETERS, type=int))
  228. self.ui.ch_engine_uis_always_on_top.setChecked(settings.value("Engine/UIsAlwaysOnTop", CARLA_DEFAULT_UIS_ALWAYS_ON_TOP, type=bool))
  229. self.ui.ch_engine_prefer_ui_bridges.setChecked(settings.value("Engine/PreferUiBridges", CARLA_DEFAULT_PREFER_UI_BRIDGES, type=bool))
  230. #self.ui.sb_engine_oscgui_timeout.setValue(settings.value("Engine/OscUiTimeout", CARLA_DEFAULT_OSC_UI_TIMEOUT, type=int))
  231. self.ui.ch_engine_disable_checks.setChecked(settings.value("Engine/DisableChecks", CARLA_DEFAULT_DISABLE_CHECKS, type=bool))
  232. self.ui.ch_engine_dssi_chunks.setChecked(settings.value("Engine/UseDssiVstChunks", CARLA_DEFAULT_USE_DSSI_VST_CHUNKS, type=bool))
  233. self.ui.ch_engine_prefer_plugin_bridges.setChecked(settings.value("Engine/PreferPluginBridges", CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES, type=bool))
  234. self.ui.ch_engine_force_stereo.setChecked(settings.value("Engine/ForceStereo", CARLA_DEFAULT_FORCE_STEREO, type=bool))
  235. # --------------------------------------------
  236. ladspas = toList(settings.value("Paths/LADSPA", Carla.DEFAULT_LADSPA_PATH))
  237. dssis = toList(settings.value("Paths/DSSI", Carla.DEFAULT_DSSI_PATH))
  238. lv2s = toList(settings.value("Paths/LV2", Carla.DEFAULT_LV2_PATH))
  239. vsts = toList(settings.value("Paths/VST", Carla.DEFAULT_VST_PATH))
  240. gigs = toList(settings.value("Paths/GIG", Carla.DEFAULT_GIG_PATH))
  241. sf2s = toList(settings.value("Paths/SF2", Carla.DEFAULT_SF2_PATH))
  242. sfzs = toList(settings.value("Paths/SFZ", Carla.DEFAULT_SFZ_PATH))
  243. ladspas.sort()
  244. dssis.sort()
  245. lv2s.sort()
  246. vsts.sort()
  247. gigs.sort()
  248. sf2s.sort()
  249. sfzs.sort()
  250. for ladspa in ladspas:
  251. self.ui.lw_ladspa.addItem(ladspa)
  252. for dssi in dssis:
  253. self.ui.lw_dssi.addItem(dssi)
  254. for lv2 in lv2s:
  255. self.ui.lw_lv2.addItem(lv2)
  256. for vst in vsts:
  257. self.ui.lw_vst.addItem(vst)
  258. for gig in gigs:
  259. self.ui.lw_gig.addItem(gig)
  260. for sf2 in sf2s:
  261. self.ui.lw_sf2.addItem(sf2)
  262. for sfz in sfzs:
  263. self.ui.lw_sfz.addItem(sfz)
  264. @pyqtSlot()
  265. def slot_saveSettings(self):
  266. settings = QSettings()
  267. # ---------------------------------------
  268. settings.setValue("Main/DefaultProjectFolder", self.ui.le_main_def_folder.text())
  269. settings.setValue("Main/UseProTheme", self.ui.ch_theme_pro.isChecked())
  270. settings.setValue("Main/ProThemeColor", self.ui.cb_theme_color.currentText())
  271. settings.setValue("Main/RefreshInterval", self.ui.sb_gui_refresh.value())
  272. # ---------------------------------------
  273. settings.setValue("Canvas/Theme", self.ui.cb_canvas_theme.currentText())
  274. settings.setValue("Canvas/AutoHideGroups", self.ui.cb_canvas_hide_groups.isChecked())
  275. settings.setValue("Canvas/UseBezierLines", self.ui.cb_canvas_bezier_lines.isChecked())
  276. settings.setValue("Canvas/UseOpenGL", self.ui.cb_canvas_use_opengl.isChecked())
  277. settings.setValue("Canvas/HighQualityAntialiasing", self.ui.cb_canvas_render_hq_aa.isChecked())
  278. # 0, 1, 2 match their enum variants
  279. settings.setValue("Canvas/EyeCandy", self.ui.cb_canvas_eyecandy.checkState())
  280. settings.setValue("Canvas/Antialiasing", self.ui.cb_canvas_render_aa.checkState())
  281. # --------------------------------------------
  282. audioDriver = self.ui.cb_engine_audio_driver.currentText()
  283. if audioDriver:
  284. settings.setValue("Engine/AudioDriver", audioDriver)
  285. if audioDriver == "JACK":
  286. settings.setValue("Engine/ProcessMode", self.ui.cb_engine_process_mode_jack.currentIndex())
  287. else:
  288. settings.setValue("Engine/ProcessMode", self.ui.cb_engine_process_mode_other.currentIndex()+self.PROCESS_MODE_NON_JACK_PADDING)
  289. settings.setValue("Engine/MaxParameters", self.ui.sb_engine_max_params.value())
  290. settings.setValue("Engine/UIsAlwaysOnTop", self.ui.ch_engine_uis_always_on_top.isChecked())
  291. settings.setValue("Engine/PreferUiBridges", self.ui.ch_engine_prefer_ui_bridges.isChecked())
  292. #settings.setValue("Engine/OscUiTimeout", self.ui.sb_engine_oscgui_timeout.value())
  293. settings.setValue("Engine/DisableChecks", self.ui.ch_engine_disable_checks.isChecked())
  294. settings.setValue("Engine/UseDssiVstChunks", self.ui.ch_engine_dssi_chunks.isChecked())
  295. settings.setValue("Engine/PreferPluginBridges", self.ui.ch_engine_prefer_plugin_bridges.isChecked())
  296. settings.setValue("Engine/ForceStereo", self.ui.ch_engine_force_stereo.isChecked())
  297. # --------------------------------------------
  298. ladspas = []
  299. dssis = []
  300. lv2s = []
  301. vsts = []
  302. gigs = []
  303. sf2s = []
  304. sfzs = []
  305. for i in range(self.ui.lw_ladspa.count()):
  306. ladspas.append(self.ui.lw_ladspa.item(i).text())
  307. for i in range(self.ui.lw_dssi.count()):
  308. dssis.append(self.ui.lw_dssi.item(i).text())
  309. for i in range(self.ui.lw_lv2.count()):
  310. lv2s.append(self.ui.lw_lv2.item(i).text())
  311. for i in range(self.ui.lw_vst.count()):
  312. vsts.append(self.ui.lw_vst.item(i).text())
  313. for i in range(self.ui.lw_gig.count()):
  314. gigs.append(self.ui.lw_gig.item(i).text())
  315. for i in range(self.ui.lw_sf2.count()):
  316. sf2s.append(self.ui.lw_sf2.item(i).text())
  317. for i in range(self.ui.lw_sfz.count()):
  318. sfzs.append(self.ui.lw_sfz.item(i).text())
  319. settings.setValue("Paths/LADSPA", ladspas)
  320. settings.setValue("Paths/DSSI", dssis)
  321. settings.setValue("Paths/LV2", lv2s)
  322. settings.setValue("Paths/VST", vsts)
  323. settings.setValue("Paths/GIG", gigs)
  324. settings.setValue("Paths/SF2", sf2s)
  325. settings.setValue("Paths/SFZ", sfzs)
  326. @pyqtSlot()
  327. def slot_resetSettings(self):
  328. if self.ui.lw_page.currentRow() == self.TAB_INDEX_MAIN:
  329. self.ui.le_main_def_folder.setText(HOME)
  330. self.ui.ch_theme_pro.setChecked(True)
  331. self.ui.cb_theme_color.setCurrentIndex(0)
  332. self.ui.sb_gui_refresh.setValue(50)
  333. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_CANVAS:
  334. self.ui.cb_canvas_theme.setCurrentIndex(0)
  335. self.ui.cb_canvas_hide_groups.setChecked(False)
  336. self.ui.cb_canvas_bezier_lines.setChecked(True)
  337. self.ui.cb_canvas_eyecandy.setCheckState(Qt.PartiallyChecked)
  338. self.ui.cb_canvas_use_opengl.setChecked(False)
  339. self.ui.cb_canvas_render_aa.setCheckState(Qt.PartiallyChecked)
  340. self.ui.cb_canvas_render_hq_aa.setChecked(False)
  341. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_CARLA_ENGINE:
  342. self.ui.cb_engine_audio_driver.setCurrentIndex(0)
  343. self.ui.sb_engine_max_params.setValue(CARLA_DEFAULT_MAX_PARAMETERS)
  344. self.ui.ch_engine_uis_always_on_top.setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP)
  345. self.ui.ch_engine_prefer_ui_bridges.setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES)
  346. #self.ui.sb_engine_oscgui_timeout.setValue(CARLA_DEFAULT_OSC_UI_TIMEOUT)
  347. #self.ui.ch_engine_disable_checks.setChecked(CARLA_DEFAULT_DISABLE_CHECKS)
  348. self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES)
  349. self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO)
  350. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  351. self.ui.cb_engine_process_mode_jack.setCurrentIndex(PROCESS_MODE_MULTIPLE_CLIENTS)
  352. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  353. else:
  354. self.ui.cb_engine_process_mode_other.setCurrentIndex(PROCESS_MODE_CONTINUOUS_RACK-self.PROCESS_MODE_NON_JACK_PADDING)
  355. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  356. elif self.ui.lw_page.currentRow() == self.TAB_INDEX_CARLA_PATHS:
  357. if self.ui.tw_paths.currentIndex() == 0:
  358. paths = DEFAULT_LADSPA_PATH.split(splitter)
  359. paths.sort()
  360. self.ui.lw_ladspa.clear()
  361. for ladspa in paths:
  362. self.ui.lw_ladspa.addItem(ladspa)
  363. elif self.ui.tw_paths.currentIndex() == 1:
  364. paths = DEFAULT_DSSI_PATH.split(splitter)
  365. paths.sort()
  366. self.ui.lw_dssi.clear()
  367. for dssi in paths:
  368. self.ui.lw_dssi.addItem(dssi)
  369. elif self.ui.tw_paths.currentIndex() == 2:
  370. paths = DEFAULT_LV2_PATH.split(splitter)
  371. paths.sort()
  372. self.ui.lw_lv2.clear()
  373. for lv2 in paths:
  374. self.ui.lw_lv2.addItem(lv2)
  375. elif self.ui.tw_paths.currentIndex() == 3:
  376. paths = DEFAULT_VST_PATH.split(splitter)
  377. paths.sort()
  378. self.ui.lw_vst.clear()
  379. for vst in paths:
  380. self.ui.lw_vst.addItem(vst)
  381. elif self.ui.tw_paths.currentIndex() == 4:
  382. paths = DEFAULT_GIG_PATH.split(splitter)
  383. paths.sort()
  384. self.ui.lw_gig.clear()
  385. for gig in paths:
  386. self.ui.lw_gig.addItem(gig)
  387. elif self.ui.tw_paths.currentIndex() == 5:
  388. paths = DEFAULT_SF2_PATH.split(splitter)
  389. paths.sort()
  390. self.ui.lw_sf2.clear()
  391. for sf2 in paths:
  392. self.ui.lw_sf2.addItem(sf2)
  393. elif self.ui.tw_paths.currentIndex() == 6:
  394. paths = DEFAULT_SFZ_PATH.split(splitter)
  395. paths.sort()
  396. self.ui.lw_sfz.clear()
  397. for sfz in paths:
  398. self.ui.lw_sfz.addItem(sfz)
  399. @pyqtSlot()
  400. def slot_getAndSetProjectPath(self):
  401. getAndSetPath(self, self.ui.le_main_def_folder.text(), self.ui.le_main_def_folder)
  402. @pyqtSlot()
  403. def slot_engineAudioDriverChanged(self):
  404. if self.ui.cb_engine_audio_driver.currentText() == "JACK":
  405. self.ui.sw_engine_process_mode.setCurrentIndex(0)
  406. else:
  407. self.ui.sw_engine_process_mode.setCurrentIndex(1)
  408. @pyqtSlot()
  409. def slot_showAudioDriverSettings(self):
  410. driverIndex = self.ui.cb_engine_audio_driver.currentIndex()
  411. driverName = self.ui.cb_engine_audio_driver.currentText()
  412. DriverSettingsW(self, driverIndex, driverName).exec_()
  413. @pyqtSlot()
  414. def slot_addPluginPath(self):
  415. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), "", QFileDialog.ShowDirsOnly)
  416. if newPath:
  417. if self.ui.tw_paths.currentIndex() == 0:
  418. self.ui.lw_ladspa.addItem(newPath)
  419. elif self.ui.tw_paths.currentIndex() == 1:
  420. self.ui.lw_dssi.addItem(newPath)
  421. elif self.ui.tw_paths.currentIndex() == 2:
  422. self.ui.lw_lv2.addItem(newPath)
  423. elif self.ui.tw_paths.currentIndex() == 3:
  424. self.ui.lw_vst.addItem(newPath)
  425. elif self.ui.tw_paths.currentIndex() == 4:
  426. self.ui.lw_gig.addItem(newPath)
  427. elif self.ui.tw_paths.currentIndex() == 5:
  428. self.ui.lw_sf2.addItem(newPath)
  429. elif self.ui.tw_paths.currentIndex() == 6:
  430. self.ui.lw_sfz.addItem(newPath)
  431. @pyqtSlot()
  432. def slot_removePluginPath(self):
  433. if self.ui.tw_paths.currentIndex() == 0:
  434. self.ui.lw_ladspa.takeItem(self.ui.lw_ladspa.currentRow())
  435. elif self.ui.tw_paths.currentIndex() == 1:
  436. self.ui.lw_dssi.takeItem(self.ui.lw_dssi.currentRow())
  437. elif self.ui.tw_paths.currentIndex() == 2:
  438. self.ui.lw_lv2.takeItem(self.ui.lw_lv2.currentRow())
  439. elif self.ui.tw_paths.currentIndex() == 3:
  440. self.ui.lw_vst.takeItem(self.ui.lw_vst.currentRow())
  441. elif self.ui.tw_paths.currentIndex() == 4:
  442. self.ui.lw_gig.takeItem(self.ui.lw_gig.currentRow())
  443. elif self.ui.tw_paths.currentIndex() == 5:
  444. self.ui.lw_sf2.takeItem(self.ui.lw_sf2.currentRow())
  445. elif self.ui.tw_paths.currentIndex() == 6:
  446. self.ui.lw_sfz.takeItem(self.ui.lw_sfz.currentRow())
  447. @pyqtSlot()
  448. def slot_changePluginPath(self):
  449. if self.ui.tw_paths.currentIndex() == 0:
  450. currentPath = self.ui.lw_ladspa.currentItem().text()
  451. elif self.ui.tw_paths.currentIndex() == 1:
  452. currentPath = self.ui.lw_dssi.currentItem().text()
  453. elif self.ui.tw_paths.currentIndex() == 2:
  454. currentPath = self.ui.lw_lv2.currentItem().text()
  455. elif self.ui.tw_paths.currentIndex() == 3:
  456. currentPath = self.ui.lw_vst.currentItem().text()
  457. elif self.ui.tw_paths.currentIndex() == 4:
  458. currentPath = self.ui.lw_gig.currentItem().text()
  459. elif self.ui.tw_paths.currentIndex() == 5:
  460. currentPath = self.ui.lw_sf2.currentItem().text()
  461. elif self.ui.tw_paths.currentIndex() == 6:
  462. currentPath = self.ui.lw_sfz.currentItem().text()
  463. else:
  464. currentPath = ""
  465. newPath = QFileDialog.getExistingDirectory(self, self.tr("Add Path"), currentPath, QFileDialog.ShowDirsOnly)
  466. if newPath:
  467. if self.ui.tw_paths.currentIndex() == 0:
  468. self.ui.lw_ladspa.currentItem().setText(newPath)
  469. elif self.ui.tw_paths.currentIndex() == 1:
  470. self.ui.lw_dssi.currentItem().setText(newPath)
  471. elif self.ui.tw_paths.currentIndex() == 2:
  472. self.ui.lw_lv2.currentItem().setText(newPath)
  473. elif self.ui.tw_paths.currentIndex() == 3:
  474. self.ui.lw_vst.currentItem().setText(newPath)
  475. elif self.ui.tw_paths.currentIndex() == 4:
  476. self.ui.lw_gig.currentItem().setText(newPath)
  477. elif self.ui.tw_paths.currentIndex() == 5:
  478. self.ui.lw_sf2.currentItem().setText(newPath)
  479. elif self.ui.tw_paths.currentIndex() == 6:
  480. self.ui.lw_sfz.currentItem().setText(newPath)
  481. @pyqtSlot(int)
  482. def slot_pluginPathTabChanged(self, index):
  483. if index == 0:
  484. row = self.ui.lw_ladspa.currentRow()
  485. elif index == 1:
  486. row = self.ui.lw_dssi.currentRow()
  487. elif index == 2:
  488. row = self.ui.lw_lv2.currentRow()
  489. elif index == 3:
  490. row = self.ui.lw_vst.currentRow()
  491. elif index == 4:
  492. row = self.ui.lw_gig.currentRow()
  493. elif index == 5:
  494. row = self.ui.lw_sf2.currentRow()
  495. elif index == 6:
  496. row = self.ui.lw_sfz.currentRow()
  497. else:
  498. row = -1
  499. check = bool(row >= 0)
  500. self.ui.b_paths_remove.setEnabled(check)
  501. self.ui.b_paths_change.setEnabled(check)
  502. @pyqtSlot(int)
  503. def slot_pluginPathRowChanged(self, row):
  504. check = bool(row >= 0)
  505. self.ui.b_paths_remove.setEnabled(check)
  506. self.ui.b_paths_change.setEnabled(check)
  507. def done(self, r):
  508. QDialog.done(self, r)
  509. self.close()
  510. # ------------------------------------------------------------------------------------------------------------
  511. # TESTING
  512. from PyQt5.QtWidgets import QApplication
  513. app = QApplication(sys.argv)
  514. gui = CarlaSettingsW(None, True)
  515. gui.show()
  516. app.exec_()