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.

781 lines
34KB

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