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.

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