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 35KB

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