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.

carla_settings.py 30KB

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