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.

826 lines
36KB

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