Collection of tools useful for audio production
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.

3370 lines
129KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla Backend code
  4. # Copyright (C) 2011-2012 Filipe Coelho <falktx@gmail.com> FIXME
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # 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 COPYING file
  17. # TODO - options:
  18. # - max parameters
  19. # - osc gui timeout
  20. # Imports (Global)
  21. import json, os, sys
  22. from time import sleep
  23. #from sip import unwrapinstance
  24. from PyQt4.QtCore import pyqtSlot, Qt, QSettings, QTimer, QThread
  25. from PyQt4.QtGui import QApplication, QColor, QCursor, QDialog, QFontMetrics, QInputDialog, QFrame, QMainWindow, QMenu, QPainter, QTableWidgetItem, QVBoxLayout, QWidget
  26. from PyQt4.QtXml import QDomDocument
  27. # Imports (Custom Stuff)
  28. import ui_carla, ui_carla_about, ui_carla_database, ui_carla_edit, ui_carla_parameter, ui_carla_plugin, ui_carla_refresh
  29. from carla_backend import *
  30. from shared_settings import *
  31. ICON_STATE_NULL = 0
  32. ICON_STATE_WAIT = 1
  33. ICON_STATE_OFF = 2
  34. ICON_STATE_ON = 3
  35. PALETTE_COLOR_NONE = 0
  36. PALETTE_COLOR_WHITE = 1
  37. PALETTE_COLOR_RED = 2
  38. PALETTE_COLOR_GREEN = 3
  39. PALETTE_COLOR_BLUE = 4
  40. PALETTE_COLOR_YELLOW = 5
  41. PALETTE_COLOR_ORANGE = 6
  42. PALETTE_COLOR_BROWN = 7
  43. PALETTE_COLOR_PINK = 8
  44. # Save support
  45. save_state_dict = {
  46. 'Type': "",
  47. 'Name': "",
  48. 'Label': "",
  49. 'Binary': "",
  50. 'UniqueID': 0,
  51. 'Active': False,
  52. 'DryWet': 1.0,
  53. 'Volume': 1.0,
  54. 'Balance-Left': -1.0,
  55. 'Balance-Right': 1.0,
  56. 'Parameters': [],
  57. 'CurrentProgramIndex': -1,
  58. 'CurrentProgramName': "",
  59. 'CurrentMidiBank': -1,
  60. 'CurrentMidiProgram': -1,
  61. 'CustomData': [],
  62. 'Chunk': None
  63. }
  64. save_state_parameter = {
  65. 'index': 0,
  66. 'rindex': 0,
  67. 'name': "",
  68. 'symbol': "",
  69. 'value': 0.0,
  70. 'midi_channel': 1,
  71. 'midi_cc': -1
  72. }
  73. save_state_custom_data = {
  74. 'type': CUSTOM_DATA_INVALID,
  75. 'key': "",
  76. 'value': ""
  77. }
  78. # set defaults
  79. DEFAULT_PROJECT_FOLDER = HOME
  80. setDefaultProjectFolder(DEFAULT_PROJECT_FOLDER)
  81. setDefaultPluginsPaths(LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, SF2_PATH)
  82. def CustomDataType2String(dtype):
  83. if (dtype == CUSTOM_DATA_BOOL):
  84. return "bool"
  85. elif (dtype == CUSTOM_DATA_INT):
  86. return "int"
  87. elif (dtype == CUSTOM_DATA_LONG):
  88. return "long"
  89. elif (dtype == CUSTOM_DATA_FLOAT):
  90. return "float"
  91. elif (dtype == CUSTOM_DATA_STRING):
  92. return "string"
  93. elif (dtype == CUSTOM_DATA_BINARY):
  94. return "binary"
  95. else:
  96. return "null"
  97. def CustomDataString2Type(stype):
  98. if (stype == "bool"):
  99. return CUSTOM_DATA_BOOL
  100. elif (stype == "int"):
  101. return CUSTOM_DATA_INT
  102. elif (stype == "long"):
  103. return CUSTOM_DATA_LONG
  104. elif (stype == "float"):
  105. return CUSTOM_DATA_FLOAT
  106. elif (stype == "string"):
  107. return CUSTOM_DATA_STRING
  108. elif (stype == "binary"):
  109. return CUSTOM_DATA_BINARY
  110. else:
  111. return CUSTOM_DATA_INVALID
  112. def getStateDictFromXML(xml_node):
  113. x_save_state_dict = deepcopy(save_state_dict)
  114. node = xml_node.firstChild()
  115. while not node.isNull():
  116. if (node.toElement().tagName() == "Info"):
  117. xml_info = node.toElement().firstChild()
  118. while not xml_info.isNull():
  119. tag = xml_info.toElement().tagName()
  120. text = xml_info.toElement().text().strip()
  121. if (tag == "Type"):
  122. x_save_state_dict['Type'] = text
  123. elif (tag == "Name"):
  124. x_save_state_dict['Name'] = text
  125. elif (tag == "Label"):
  126. x_save_state_dict['Label'] = text
  127. elif (tag == "Binary"):
  128. x_save_state_dict['Binary'] = text
  129. elif (tag == "UniqueID"):
  130. if (text.isdigit()):
  131. x_save_state_dict['UniqueID'] = int(text)
  132. xml_info = xml_info.nextSibling()
  133. elif (node.toElement().tagName() == "Data"):
  134. xml_data = node.toElement().firstChild()
  135. while not xml_data.isNull():
  136. tag = xml_data.toElement().tagName()
  137. text = xml_data.toElement().text().strip()
  138. if (tag == "Active"):
  139. x_save_state_dict['Active'] = bool(text == "Yes")
  140. elif (tag == "DryWet"):
  141. if (isNumber(text)):
  142. x_save_state_dict['DryWet'] = float(text)
  143. elif (tag == "Vol"):
  144. if (isNumber(text)):
  145. x_save_state_dict['Volume'] = float(text)
  146. elif (tag == "Balance-Left"):
  147. if (isNumber(text)):
  148. x_save_state_dict['Balance-Left'] = float(text)
  149. elif (tag == "Balance-Right"):
  150. if (isNumber(text)):
  151. x_save_state_dict['Balance-Right'] = float(text)
  152. elif (tag == "CurrentProgramIndex"):
  153. if (text.isdigit()):
  154. x_save_state_dict['CurrentProgramIndex'] = int(text)
  155. elif (tag == "CurrentProgramName"):
  156. x_save_state_dict['CurrentProgramName'] = text
  157. elif (tag == "CurrentMidiBank"):
  158. if (text.isdigit()):
  159. x_save_state_dict['CurrentMidiBank'] = int(text)
  160. elif (tag == "CurrentMidiProgram"):
  161. if (text.isdigit()):
  162. x_save_state_dict['CurrentMidiProgram'] = int(text)
  163. elif (tag == "Chunk"):
  164. x_save_state_dict['Chunk'] = text
  165. elif (tag == "Parameter"):
  166. x_save_state_parameter = deepcopy(save_state_parameter)
  167. xml_subdata = xml_data.toElement().firstChild()
  168. while not xml_subdata.isNull():
  169. ptag = xml_subdata.toElement().tagName()
  170. ptext = xml_subdata.toElement().text().strip()
  171. if (ptag == "index"):
  172. if (ptext.isdigit()):
  173. x_save_state_parameter['index'] = int(ptext)
  174. elif (ptag == "rindex"):
  175. if (ptext.isdigit()):
  176. x_save_state_parameter['rindex'] = int(ptext)
  177. elif (ptag == "name"):
  178. x_save_state_parameter['name'] = ptext
  179. elif (ptag == "symbol"):
  180. x_save_state_parameter['symbol'] = ptext
  181. elif (ptag == "value"):
  182. if (isNumber(ptext)):
  183. x_save_state_parameter['value'] = float(ptext)
  184. elif (ptag == "midi_channel"):
  185. if (ptext.isdigit()):
  186. x_save_state_parameter['midi_channel'] = int(ptext)
  187. elif (ptag == "midi_cc"):
  188. if (ptext.isdigit()):
  189. x_save_state_parameter['midi_cc'] = int(ptext)
  190. xml_subdata = xml_subdata.nextSibling()
  191. x_save_state_dict['Parameters'].append(x_save_state_parameter)
  192. elif (tag == "CustomData"):
  193. x_save_state_custom_data = deepcopy(save_state_custom_data)
  194. xml_subdata = xml_data.toElement().firstChild()
  195. while not xml_subdata.isNull():
  196. ctag = xml_subdata.toElement().tagName()
  197. ctext = xml_subdata.toElement().text().strip()
  198. if (ctag == "type"):
  199. print(ctext, CustomDataString2Type(ctext))
  200. x_save_state_custom_data['type'] = CustomDataString2Type(ctext)
  201. elif (ctag == "key"):
  202. x_save_state_custom_data['key'] = ctext
  203. elif (ctag == "value"):
  204. x_save_state_custom_data['value'] = ctext
  205. xml_subdata = xml_subdata.nextSibling()
  206. x_save_state_dict['CustomData'].append(x_save_state_custom_data)
  207. xml_data = xml_data.nextSibling()
  208. node = node.nextSibling()
  209. return x_save_state_dict
  210. # Separate Thread for Plugin Search
  211. class SearchPluginsThread(QThread):
  212. def __init__(self, parent):
  213. QThread.__init__(self, parent)
  214. self.settings_db = self.parent().settings_db
  215. self.check_ladspa = True
  216. self.check_dssi = True
  217. self.check_lv2 = True
  218. self.check_vst = True
  219. self.check_sf2 = True
  220. self.check_native = None
  221. self.check_bins = []
  222. def skipPlugin(self):
  223. # TODO - windows and mac support
  224. apps = ""
  225. apps += " carla-discovery"
  226. apps += " carla-discovery-unix32"
  227. apps += " carla-discovery-unix64"
  228. apps += " carla-discovery-win32.exe"
  229. apps += " carla-discovery-win64.exe"
  230. if (LINUX):
  231. os.system("killall -KILL %s" % (apps))
  232. def pluginLook(self, percent, plugin):
  233. self.emit(SIGNAL("PluginLook(int, QString)"), percent, plugin)
  234. def setSearchBins(self, bins):
  235. self.check_bins = bins
  236. def setSearchNative(self, native):
  237. self.check_native = native
  238. def setSearchTypes(self, ladspa, dssi, lv2, vst, sf2):
  239. self.check_ladspa = ladspa
  240. self.check_dssi = dssi
  241. self.check_lv2 = lv2
  242. self.check_vst = vst
  243. self.check_sf2 = sf2
  244. def setLastLoadedBinary(self, binary):
  245. self.settings_db.setValue("Plugins/LastLoadedBinary", binary)
  246. def run(self):
  247. # TODO - split across several fuctions
  248. global LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, SF2_PATH
  249. blacklist = toList(self.settings_db.value("Plugins/Blacklisted", []))
  250. bins = []
  251. bins_w = []
  252. m_count = type_count = 0
  253. if (self.check_ladspa): m_count += 1
  254. if (self.check_dssi): m_count += 1
  255. if (self.check_vst): m_count += 1
  256. check_native = check_wine = False
  257. if (LINUX):
  258. OS = "LINUX"
  259. elif (MACOS):
  260. OS = "MACOS"
  261. elif (WINDOWS):
  262. OS = "WINDOWS"
  263. else:
  264. OS = "UNKNOWN"
  265. if (LINUX or MACOS):
  266. if (carla_discovery_unix32 in self.check_bins or carla_discovery_unix64 in self.check_bins):
  267. type_count += m_count
  268. check_native = True
  269. if (carla_discovery_unix32 in self.check_bins):
  270. bins.append(carla_discovery_unix32)
  271. if (carla_discovery_unix64 in self.check_bins):
  272. bins.append(carla_discovery_unix64)
  273. if (carla_discovery_win32 in self.check_bins or carla_discovery_win64 in self.check_bins):
  274. type_count += m_count
  275. check_wine = True
  276. if (carla_discovery_win32 in self.check_bins):
  277. bins_w.append(carla_discovery_win32)
  278. if (carla_discovery_win64 in self.check_bins):
  279. bins_w.append(carla_discovery_win64)
  280. elif (WINDOWS):
  281. if (carla_discovery_win32 in self.check_bins or carla_discovery_win64 in self.check_bins):
  282. type_count += m_count
  283. check_native = True
  284. if (carla_discovery_win32 in self.check_bins):
  285. bins.append(carla_discovery_win32)
  286. if (carla_discovery_win64 in self.check_bins):
  287. bins.append(carla_discovery_win64)
  288. if (self.check_lv2): type_count += 1
  289. if (self.check_sf2): type_count += 1
  290. if (type_count == 0):
  291. return
  292. ladspa_plugins = []
  293. dssi_plugins = []
  294. lv2_plugins = []
  295. vst_plugins = []
  296. soundfonts = []
  297. ladspa_rdf_info = []
  298. lv2_rdf_info = []
  299. last_value = 0
  300. percent_value = 100/type_count
  301. # ----- LADSPA
  302. if (self.check_ladspa):
  303. if (check_native):
  304. ladspa_binaries = []
  305. for iPATH in LADSPA_PATH:
  306. binaries = findBinaries(iPATH, OS)
  307. for binary in binaries:
  308. if (binary not in ladspa_binaries):
  309. ladspa_binaries.append(binary)
  310. ladspa_binaries.sort()
  311. for i in range(len(ladspa_binaries)):
  312. ladspa = ladspa_binaries[i]
  313. if (getShortFileName(ladspa) in blacklist):
  314. print("plugin %s is blacklisted, skip it" % (ladspa))
  315. continue
  316. else:
  317. percent = ( float(i) / len(ladspa_binaries) ) * percent_value
  318. self.pluginLook((last_value + percent)*0.9, ladspa)
  319. self.setLastLoadedBinary(ladspa)
  320. for bin_ in bins:
  321. plugins = checkPluginLADSPA(ladspa, bin_)
  322. if (plugins != None):
  323. ladspa_plugins.append(plugins)
  324. last_value += percent_value
  325. if (check_wine):
  326. ladspa_binaries_w = []
  327. for iPATH in LADSPA_PATH:
  328. binaries = findBinaries(iPATH, "WINDOWS")
  329. for binary in binaries:
  330. if (binary not in ladspa_binaries_w):
  331. ladspa_binaries_w.append(binary)
  332. ladspa_binaries_w.sort()
  333. # Check binaries, wine
  334. for i in range(len(ladspa_binaries_w)):
  335. ladspa_w = ladspa_binaries_w[i]
  336. if (getShortFileName(ladspa_w) in blacklist):
  337. print("plugin %s is blacklisted, skip it" % (ladspa_w))
  338. continue
  339. else:
  340. percent = ( float(i) / len(ladspa_binaries_w) ) * percent_value
  341. self.pluginLook((last_value + percent)*0.9, ladspa_w)
  342. self.setLastLoadedBinary(ladspa_w)
  343. for bin_w in bins_w:
  344. plugins_w = checkPluginLADSPA(ladspa_w, bin_w, True)
  345. if (plugins_w != None):
  346. ladspa_plugins.append(plugins_w)
  347. last_value += percent_value
  348. if (haveRDF):
  349. m_value = 0
  350. if (check_native): m_value += 0.1
  351. if (check_wine): m_value += 0.1
  352. if (m_value > 0):
  353. start_value = last_value - (percent_value * m_value)
  354. self.pluginLook(start_value, "LADSPA RDFs...")
  355. ladspa_rdf_info = ladspa_rdf.recheck_all_plugins(self, start_value, percent_value, m_value)
  356. # ----- DSSI
  357. if (self.check_dssi):
  358. if (check_native):
  359. dssi_binaries = []
  360. for iPATH in DSSI_PATH:
  361. binaries = findBinaries(iPATH, OS)
  362. for binary in binaries:
  363. if (binary not in dssi_binaries):
  364. dssi_binaries.append(binary)
  365. dssi_binaries.sort()
  366. for i in range(len(dssi_binaries)):
  367. dssi = dssi_binaries[i]
  368. if (getShortFileName(dssi) in blacklist):
  369. print("plugin %s is blacklisted, skip it" % (dssi))
  370. continue
  371. else:
  372. percent = ( float(i) / len(dssi_binaries) ) * percent_value
  373. self.pluginLook(last_value + percent, dssi)
  374. self.setLastLoadedBinary(dssi)
  375. for bin_ in bins:
  376. plugins = checkPluginDSSI(dssi, bin_)
  377. if (plugins != None):
  378. dssi_plugins.append(plugins)
  379. last_value += percent_value
  380. if (check_wine):
  381. dssi_binaries_w = []
  382. for iPATH in DSSI_PATH:
  383. binaries = findBinaries(iPATH, "WINDOWS")
  384. for binary in binaries:
  385. if (binary not in dssi_binaries_w):
  386. dssi_binaries_w.append(binary)
  387. dssi_binaries_w.sort()
  388. # Check binaries, wine
  389. for i in range(len(dssi_binaries_w)):
  390. dssi_w = dssi_binaries_w[i]
  391. if (getShortFileName(dssi_w) in blacklist):
  392. print("plugin %s is blacklisted, skip it" % (dssi_w))
  393. continue
  394. else:
  395. percent = ( float(i) / len(dssi_binaries_w) ) * percent_value
  396. self.pluginLook(last_value + percent, dssi_w)
  397. self.setLastLoadedBinary(dssi_w)
  398. for bin_w in bins_w:
  399. plugins_w = checkPluginDSSI(dssi_w, bin_w, True)
  400. if (plugins_w != None):
  401. dssi_plugins.append(plugins_w)
  402. last_value += percent_value
  403. ## ----- LV2
  404. if (self.check_lv2 and haveRDF):
  405. self.pluginLook(last_value, "LV2 bundles...")
  406. lv2_rdf.set_rdf_path(LV2_PATH)
  407. lv2_rdf_info = lv2_rdf.recheck_all_plugins(self, last_value, percent_value)
  408. for info in lv2_rdf_info:
  409. plugins = checkPluginLV2(info)
  410. if (plugins != None):
  411. lv2_plugins.append(plugins)
  412. last_value += percent_value
  413. # ----- VST
  414. if (self.check_vst):
  415. if (check_native):
  416. vst_binaries = []
  417. for iPATH in VST_PATH:
  418. binaries = findBinaries(iPATH, OS)
  419. for binary in binaries:
  420. if (binary not in vst_binaries):
  421. vst_binaries.append(binary)
  422. vst_binaries.sort()
  423. for i in range(len(vst_binaries)):
  424. vst = vst_binaries[i]
  425. if (getShortFileName(vst) in blacklist):
  426. print("plugin %s is blacklisted, skip it" % (vst))
  427. continue
  428. else:
  429. percent = ( float(i) / len(vst_binaries) ) * percent_value
  430. self.pluginLook(last_value + percent, vst)
  431. self.setLastLoadedBinary(vst)
  432. for bin_ in bins:
  433. plugins = checkPluginVST(vst, bin_)
  434. if (plugins != None):
  435. vst_plugins.append(plugins)
  436. last_value += percent_value
  437. if (check_wine):
  438. vst_binaries_w = []
  439. for iPATH in VST_PATH:
  440. binaries = findBinaries(iPATH, "WINDOWS")
  441. for binary in binaries:
  442. if (binary not in vst_binaries_w):
  443. vst_binaries_w.append(binary)
  444. vst_binaries_w.sort()
  445. # Check binaries, wine
  446. for i in range(len(vst_binaries_w)):
  447. vst_w = vst_binaries_w[i]
  448. if (getShortFileName(vst_w) in blacklist):
  449. print("plugin %s is blacklisted, skip it" % (vst_w))
  450. continue
  451. else:
  452. percent = ( float(i) / len(vst_binaries_w) ) * percent_value
  453. self.pluginLook(last_value + percent, vst_w)
  454. self.setLastLoadedBinary(vst_w)
  455. for bin_w in bins_w:
  456. plugins_w = checkPluginVST(vst_w, bin_w, True)
  457. if (plugins_w != None):
  458. vst_plugins.append(plugins_w)
  459. last_value += percent_value
  460. # ----- SF2
  461. if (self.check_sf2):
  462. sf2_files = []
  463. for iPATH in SF2_PATH:
  464. files = findSoundFonts(iPATH)
  465. for file_ in files:
  466. if (file_ not in sf2_files):
  467. sf2_files.append(file_)
  468. for i in range(len(sf2_files)):
  469. sf2 = sf2_files[i]
  470. if (getShortFileName(sf2) in blacklist):
  471. print("soundfont %s is blacklisted, skip it" % (sf2))
  472. continue
  473. else:
  474. percent = (( float(i) / len(sf2_files) ) * percent_value)
  475. self.pluginLook(last_value + percent, sf2)
  476. self.setLastLoadedBinary(sf2)
  477. soundfont = checkPluginSF2(sf2, self.check_native)
  478. if (soundfont):
  479. soundfonts.append(soundfont)
  480. self.setLastLoadedBinary("")
  481. # Save plugins to database
  482. self.pluginLook(100, "Database...")
  483. if (self.check_ladspa):
  484. self.settings_db.setValue("Plugins/LADSPA", ladspa_plugins)
  485. if (self.check_dssi):
  486. self.settings_db.setValue("Plugins/DSSI", dssi_plugins)
  487. if (self.check_lv2):
  488. self.settings_db.setValue("Plugins/LV2", lv2_plugins)
  489. if (self.check_vst):
  490. self.settings_db.setValue("Plugins/VST", vst_plugins)
  491. if (self.check_sf2):
  492. self.settings_db.setValue("Plugins/SF2", soundfonts)
  493. self.settings_db.sync()
  494. if (haveRDF):
  495. SettingsDir = os.path.join(HOME, ".config", "Cadence")
  496. if (self.check_ladspa):
  497. f_ladspa = open(os.path.join(SettingsDir, "ladspa_rdf.db"), 'w')
  498. if (f_ladspa):
  499. json.dump(ladspa_rdf_info, f_ladspa)
  500. f_ladspa.close()
  501. if (self.check_lv2):
  502. f_lv2 = open(os.path.join(SettingsDir, "lv2_rdf.db"), 'w')
  503. if (f_lv2):
  504. json.dump(lv2_rdf_info, f_lv2)
  505. f_lv2.close()
  506. # Plugin Refresh Dialog
  507. class PluginRefreshW(QDialog, ui_carla_refresh.Ui_PluginRefreshW):
  508. def __init__(self, parent):
  509. QDialog.__init__(self, parent)
  510. self.setupUi(self)
  511. self.b_skip.setVisible(False)
  512. if (LINUX):
  513. self.ch_unix32.setText("Linux 32bit")
  514. self.ch_unix64.setText("Linux 64bit")
  515. elif (MACOS):
  516. self.ch_unix32.setText("MacOS 32bit")
  517. self.ch_unix64.setText("MacOS 64bit")
  518. self.settings = self.parent().settings
  519. self.settings_db = self.parent().settings_db
  520. self.loadSettings()
  521. self.pThread = SearchPluginsThread(self)
  522. if (carla_discovery_unix32 and not WINDOWS):
  523. self.ico_unix32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  524. else:
  525. self.ico_unix32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  526. self.ch_unix32.setChecked(False)
  527. self.ch_unix32.setEnabled(False)
  528. if (carla_discovery_unix64 and not WINDOWS):
  529. self.ico_unix64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  530. else:
  531. self.ico_unix64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  532. self.ch_unix64.setChecked(False)
  533. self.ch_unix64.setEnabled(False)
  534. if (carla_discovery_win32):
  535. self.ico_win32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  536. else:
  537. self.ico_win32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  538. self.ch_win32.setChecked(False)
  539. self.ch_win32.setEnabled(False)
  540. if (carla_discovery_win64):
  541. self.ico_win64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  542. else:
  543. self.ico_win64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  544. self.ch_win64.setChecked(False)
  545. self.ch_win64.setEnabled(False)
  546. if (haveRDF):
  547. self.ico_rdflib.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  548. else:
  549. self.ico_rdflib.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  550. self.ch_lv2.setChecked(False)
  551. self.ch_lv2.setEnabled(False)
  552. if (LINUX or MACOS):
  553. if (is64bit):
  554. hasNative = bool(carla_discovery_unix64)
  555. hasNonNative = bool(carla_discovery_unix32 or carla_discovery_win32 or carla_discovery_win64)
  556. self.pThread.setSearchNative(carla_discovery_unix64)
  557. else:
  558. hasNative = bool(carla_discovery_unix32)
  559. hasNonNative = bool(carla_discovery_unix64 or carla_discovery_win32 or carla_discovery_win64)
  560. self.pThread.setSearchNative(carla_discovery_unix32)
  561. elif (WINDOWS):
  562. if (is64bit):
  563. hasNative = bool(carla_discovery_win64)
  564. hasNonNative = bool(carla_discovery_win32)
  565. self.pThread.setSearchNative(carla_discovery_win64)
  566. else:
  567. hasNative = bool(carla_discovery_win32)
  568. hasNonNative = bool(carla_discovery_win64)
  569. self.pThread.setSearchNative(carla_discovery_win32)
  570. else:
  571. hasNative = False
  572. if (not hasNative):
  573. self.ch_sf2.setChecked(False)
  574. self.ch_sf2.setEnabled(False)
  575. if (not hasNonNative):
  576. self.ch_ladspa.setChecked(False)
  577. self.ch_ladspa.setEnabled(False)
  578. self.ch_dssi.setChecked(False)
  579. self.ch_dssi.setEnabled(False)
  580. self.ch_vst.setChecked(False)
  581. self.ch_vst.setEnabled(False)
  582. if (not haveRDF):
  583. self.b_refresh.setEnabled(False)
  584. self.connect(self.b_refresh, SIGNAL("clicked()"), SLOT("slot_refresh_plugins()"))
  585. self.connect(self.b_skip, SIGNAL("clicked()"), SLOT("slot_skip()"))
  586. self.connect(self.pThread, SIGNAL("PluginLook(int, QString)"), SLOT("slot_handlePluginLook(int, QString)"))
  587. self.connect(self.pThread, SIGNAL("finished()"), SLOT("slot_handlePluginThreadFinished()"))
  588. @pyqtSlot()
  589. def slot_refresh_plugins(self):
  590. self.progressBar.setMinimum(0)
  591. self.progressBar.setMaximum(100)
  592. self.progressBar.setValue(0)
  593. self.b_refresh.setEnabled(False)
  594. self.b_skip.setVisible(True)
  595. self.b_close.setVisible(False)
  596. bins = []
  597. if (self.ch_unix32.isChecked()):
  598. bins.append(carla_discovery_unix32)
  599. if (self.ch_unix64.isChecked()):
  600. bins.append(carla_discovery_unix64)
  601. if (self.ch_win32.isChecked()):
  602. bins.append(carla_discovery_win32)
  603. if (self.ch_win64.isChecked()):
  604. bins.append(carla_discovery_win64)
  605. self.pThread.setSearchBins(bins)
  606. self.pThread.setSearchTypes(self.ch_ladspa.isChecked(), self.ch_dssi.isChecked(), self.ch_lv2.isChecked(), self.ch_vst.isChecked(), self.ch_sf2.isChecked())
  607. self.pThread.start()
  608. @pyqtSlot()
  609. def slot_skip(self):
  610. self.pThread.skipPlugin()
  611. @pyqtSlot(int, str)
  612. def slot_handlePluginLook(self, percent, plugin):
  613. self.progressBar.setFormat("%s" % (plugin))
  614. self.progressBar.setValue(percent)
  615. @pyqtSlot()
  616. def slot_handlePluginThreadFinished(self):
  617. self.progressBar.setMinimum(0)
  618. self.progressBar.setMaximum(1)
  619. self.progressBar.setValue(1)
  620. self.progressBar.setFormat(self.tr("Done"))
  621. self.b_refresh.setEnabled(True)
  622. self.b_skip.setVisible(False)
  623. self.b_close.setVisible(True)
  624. def saveSettings(self):
  625. self.settings.setValue("PluginDatabase/SearchLADSPA", self.ch_ladspa.isChecked())
  626. self.settings.setValue("PluginDatabase/SearchDSSI", self.ch_dssi.isChecked())
  627. self.settings.setValue("PluginDatabase/SearchLV2", self.ch_lv2.isChecked())
  628. self.settings.setValue("PluginDatabase/SearchVST", self.ch_vst.isChecked())
  629. self.settings.setValue("PluginDatabase/SearchSF2", self.ch_sf2.isChecked())
  630. self.settings.setValue("PluginDatabase/SearchUnix32", self.ch_unix32.isChecked())
  631. self.settings.setValue("PluginDatabase/SearchUnix64", self.ch_unix64.isChecked())
  632. self.settings.setValue("PluginDatabase/SearchWin32", self.ch_win32.isChecked())
  633. self.settings.setValue("PluginDatabase/SearchWin64", self.ch_win64.isChecked())
  634. self.settings_db.setValue("Plugins/LastLoadedBinary", "")
  635. def loadSettings(self):
  636. self.ch_ladspa.setChecked(self.settings.value("PluginDatabase/SearchLADSPA", True, type=bool))
  637. self.ch_dssi.setChecked(self.settings.value("PluginDatabase/SearchDSSI", True, type=bool))
  638. self.ch_lv2.setChecked(self.settings.value("PluginDatabase/SearchLV2", True, type=bool))
  639. self.ch_vst.setChecked(self.settings.value("PluginDatabase/SearchVST", True, type=bool))
  640. self.ch_sf2.setChecked(self.settings.value("PluginDatabase/SearchSF2", True, type=bool))
  641. self.ch_unix32.setChecked(self.settings.value("PluginDatabase/SearchUnix32", True, type=bool))
  642. self.ch_unix64.setChecked(self.settings.value("PluginDatabase/SearchUnix64", True, type=bool))
  643. self.ch_win32.setChecked(self.settings.value("PluginDatabase/SearchWin32", True, type=bool))
  644. self.ch_win64.setChecked(self.settings.value("PluginDatabase/SearchWin64", True, type=bool))
  645. def closeEvent(self, event):
  646. if (self.pThread.isRunning()):
  647. self.pThread.terminate()
  648. self.pThread.wait()
  649. self.saveSettings()
  650. QDialog.closeEvent(self, event)
  651. # Plugin Database Dialog
  652. class PluginDatabaseW(QDialog, ui_carla_database.Ui_PluginDatabaseW):
  653. def __init__(self, parent):
  654. QDialog.__init__(self, parent)
  655. self.setupUi(self)
  656. self.b_add.setEnabled(False)
  657. if (BINARY_NATIVE in (BINARY_UNIX32, BINARY_WIN32)):
  658. self.ch_bridged.setText(self.tr("Bridged (64bit)"))
  659. else:
  660. self.ch_bridged.setText(self.tr("Bridged (32bit)"))
  661. self.settings = self.parent().settings
  662. self.settings_db = self.parent().settings_db
  663. self.loadSettings()
  664. if (not (LINUX or MACOS)):
  665. self.ch_bridged_wine.setChecked(False)
  666. self.ch_bridged_wine.setEnabled(False)
  667. # Blacklist plugins
  668. if not self.settings_db.contains("Plugins/Blacklisted"):
  669. blacklist = []
  670. # Broken or useless plugins
  671. #blacklist.append("dssi-vst.so")
  672. blacklist.append("liteon_biquad-vst.so")
  673. blacklist.append("liteon_biquad-vst_64bit.so")
  674. blacklist.append("fx_blur-vst.so")
  675. blacklist.append("fx_blur-vst_64bit.so")
  676. blacklist.append("fx_tempodelay-vst.so")
  677. blacklist.append("Scrubby_64bit.so")
  678. blacklist.append("Skidder_64bit.so")
  679. blacklist.append("libwormhole2_64bit.so")
  680. blacklist.append("vexvst.so")
  681. #blacklist.append("deckadance.dll")
  682. self.settings_db.setValue("Plugins/Blacklisted", blacklist)
  683. self.connect(self.b_add, SIGNAL("clicked()"), SLOT("slot_add_plugin()"))
  684. self.connect(self.b_refresh, SIGNAL("clicked()"), SLOT("slot_refresh_plugins()"))
  685. self.connect(self.tb_filters, SIGNAL("clicked()"), SLOT("slot_maybe_show_filters()"))
  686. self.connect(self.tableWidget, SIGNAL("currentCellChanged(int, int, int, int)"), SLOT("slot_checkPlugin(int)"))
  687. self.connect(self.tableWidget, SIGNAL("cellDoubleClicked(int, int)"), SLOT("slot_add_plugin()"))
  688. self.connect(self.lineEdit, SIGNAL("textChanged(QString)"), SLOT("slot_checkFilters()"))
  689. self.connect(self.ch_effects, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  690. self.connect(self.ch_instruments, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  691. self.connect(self.ch_midi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  692. self.connect(self.ch_other, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  693. self.connect(self.ch_sf2, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  694. self.connect(self.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  695. self.connect(self.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  696. self.connect(self.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  697. self.connect(self.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  698. self.connect(self.ch_native, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  699. self.connect(self.ch_bridged, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  700. self.connect(self.ch_bridged_wine, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  701. self.connect(self.ch_gui, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  702. self.connect(self.ch_stereo, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  703. self.ret_plugin = None
  704. def showFilters(self, yesno):
  705. if (yesno):
  706. arrow = Qt.UpArrow
  707. else:
  708. arrow = Qt.DownArrow
  709. self.tb_filters.setArrowType(arrow)
  710. self.frame.setVisible(yesno)
  711. def reAddPlugins(self):
  712. row_count = self.tableWidget.rowCount()
  713. for x in range(row_count):
  714. self.tableWidget.removeRow(0)
  715. self.last_table_index = 0
  716. self.tableWidget.setSortingEnabled(False)
  717. ladspa_plugins = toList(self.settings_db.value("Plugins/LADSPA", []))
  718. dssi_plugins = toList(self.settings_db.value("Plugins/DSSI", []))
  719. lv2_plugins = toList(self.settings_db.value("Plugins/LV2", []))
  720. vst_plugins = toList(self.settings_db.value("Plugins/VST", []))
  721. soundfonts = toList(self.settings_db.value("Plugins/SF2", []))
  722. ladspa_count = 0
  723. dssi_count = 0
  724. lv2_count = 0
  725. vst_count = 0
  726. sf2_count = 0
  727. for plugins in ladspa_plugins:
  728. for plugin in plugins:
  729. self.addPluginToTable(plugin, "LADSPA")
  730. ladspa_count += 1
  731. for plugins in dssi_plugins:
  732. for plugin in plugins:
  733. self.addPluginToTable(plugin, "DSSI")
  734. dssi_count += 1
  735. for plugins in lv2_plugins:
  736. for plugin in plugins:
  737. self.addPluginToTable(plugin, "LV2")
  738. lv2_count += 1
  739. for plugins in vst_plugins:
  740. for plugin in plugins:
  741. self.addPluginToTable(plugin, "VST")
  742. vst_count += 1
  743. for soundfonts_i in soundfonts:
  744. for soundfont in soundfonts_i:
  745. self.addPluginToTable(soundfont, "SF2")
  746. sf2_count += 1
  747. self.slot_checkFilters()
  748. self.tableWidget.setSortingEnabled(True)
  749. self.tableWidget.sortByColumn(0, Qt.AscendingOrder)
  750. self.label.setText(self.tr("Have %i LADSPA, %i DSSI, %i LV2, %i VST and %i SoundFonts" % (ladspa_count, dssi_count, lv2_count, vst_count, sf2_count)))
  751. def addPluginToTable(self, plugin, ptype):
  752. index = self.last_table_index
  753. if (plugin['build'] == BINARY_NATIVE):
  754. bridge_text = self.tr("No")
  755. else:
  756. type_text = self.tr("Unknown")
  757. if (LINUX or MACOS):
  758. if (plugin['build'] == BINARY_UNIX32):
  759. type_text = "32bit"
  760. elif (plugin['build'] == BINARY_UNIX64):
  761. type_text = "64bit"
  762. elif (plugin['build'] == BINARY_WIN32):
  763. type_text = "Windows 32bit"
  764. elif (plugin['build'] == BINARY_WIN64):
  765. type_text = "Windows 64bit"
  766. elif (WINDOWS):
  767. if (plugin['build'] == BINARY_WIN32):
  768. type_text = "32bit"
  769. elif (plugin['build'] == BINARY_WIN64):
  770. type_text = "64bit"
  771. bridge_text = self.tr("Yes (%s)" % (type_text))
  772. self.tableWidget.insertRow(index)
  773. self.tableWidget.setItem(index, 0, QTableWidgetItem(plugin['name']))
  774. self.tableWidget.setItem(index, 1, QTableWidgetItem(plugin['label']))
  775. self.tableWidget.setItem(index, 2, QTableWidgetItem(plugin['maker']))
  776. self.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['unique_id'])))
  777. self.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins'])))
  778. self.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs'])))
  779. self.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins'])))
  780. self.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs'])))
  781. self.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total'])))
  782. self.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_GUI) else self.tr("No")))
  783. self.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No")))
  784. self.tableWidget.setItem(index, 11, QTableWidgetItem(bridge_text))
  785. self.tableWidget.setItem(index, 12, QTableWidgetItem(ptype))
  786. self.tableWidget.setItem(index, 13, QTableWidgetItem(plugin['binary']))
  787. self.tableWidget.item(self.last_table_index, 0).plugin_data = plugin
  788. self.last_table_index += 1
  789. @pyqtSlot()
  790. def slot_add_plugin(self):
  791. if (self.tableWidget.currentRow() >= 0):
  792. self.ret_plugin = self.tableWidget.item(self.tableWidget.currentRow(), 0).plugin_data
  793. self.accept()
  794. else:
  795. self.reject()
  796. @pyqtSlot()
  797. def slot_refresh_plugins(self):
  798. lastLoadedPlugin = self.settings_db.value("Plugins/LastLoadedBinary", "", type=str)
  799. if (lastLoadedPlugin):
  800. lastLoadedPlugin = getShortFileName(lastLoadedPlugin)
  801. ask = QMessageBox.question(self, self.tr("Warning"), self.tr(""
  802. "There was an error while checking the plugin %s.\n"
  803. "Do you want to blacklist it?" % (lastLoadedPlugin)), QMessageBox.Yes|QMessageBox.No, QMessageBox.Yes)
  804. if (ask == QMessageBox.Yes):
  805. blacklist = toList(self.settings_db.value("Plugins/Blacklisted", []))
  806. blacklist.append(lastLoadedPlugin)
  807. self.settings_db.setValue("Plugins/Blacklisted", blacklist)
  808. self.label.setText(self.tr("Looking for plugins..."))
  809. PluginRefreshW(self).exec_()
  810. self.reAddPlugins()
  811. self.parent().loadRDFs()
  812. @pyqtSlot()
  813. def slot_maybe_show_filters(self):
  814. self.showFilters(not self.frame.isVisible())
  815. @pyqtSlot(int)
  816. def slot_checkPlugin(self, row):
  817. self.b_add.setEnabled(row >= 0)
  818. @pyqtSlot()
  819. def slot_checkFilters(self):
  820. text = self.lineEdit.text().lower()
  821. hide_effects = not self.ch_effects.isChecked()
  822. hide_instruments = not self.ch_instruments.isChecked()
  823. hide_midi = not self.ch_midi.isChecked()
  824. hide_other = not self.ch_other.isChecked()
  825. hide_ladspa = not self.ch_ladspa.isChecked()
  826. hide_dssi = not self.ch_dssi.isChecked()
  827. hide_lv2 = not self.ch_lv2.isChecked()
  828. hide_vst = not self.ch_vst.isChecked()
  829. hide_sf2 = not self.ch_sf2.isChecked()
  830. hide_native = not self.ch_native.isChecked()
  831. hide_bridged = not self.ch_bridged.isChecked()
  832. hide_bridged_wine = not self.ch_bridged_wine.isChecked()
  833. hide_non_gui = self.ch_gui.isChecked()
  834. hide_non_stereo = self.ch_stereo.isChecked()
  835. if (LINUX or MACOS):
  836. native_bins = [BINARY_UNIX32, BINARY_UNIX64]
  837. wine_bins = [BINARY_WIN32, BINARY_WIN64]
  838. elif (WINDOWS):
  839. native_bins = [BINARY_WIN32, BINARY_WIN64]
  840. wine_bins = []
  841. else:
  842. native_bins = []
  843. wine_bins = []
  844. row_count = self.tableWidget.rowCount()
  845. for i in range(row_count):
  846. self.tableWidget.showRow(i)
  847. plugin = self.tableWidget.item(i, 0).plugin_data
  848. ains = plugin['audio.ins']
  849. aouts = plugin['audio.outs']
  850. mins = plugin['midi.ins']
  851. mouts = plugin['midi.outs']
  852. ptype = self.tableWidget.item(i, 12).text()
  853. is_synth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  854. is_effect = bool(ains > 0 and aouts > 0 and not is_synth)
  855. is_midi = bool(ains == 0 and aouts == 0 and mins > 0 and mouts > 0)
  856. is_sf2 = bool(ptype == "SF2")
  857. is_other = bool(not (is_effect or is_synth or is_midi or is_sf2))
  858. is_native = bool(plugin['build'] == BINARY_NATIVE)
  859. is_stereo = bool(ains == 2 and aouts == 2) or (is_synth and aouts == 2)
  860. has_gui = bool(plugin['hints'] & PLUGIN_HAS_GUI)
  861. is_bridged = bool(not is_native and plugin['build'] in native_bins)
  862. is_bridged_wine = bool(not is_native and plugin['build'] in wine_bins)
  863. if (hide_effects and is_effect):
  864. self.tableWidget.hideRow(i)
  865. elif (hide_instruments and is_synth):
  866. self.tableWidget.hideRow(i)
  867. elif (hide_midi and is_midi):
  868. self.tableWidget.hideRow(i)
  869. elif (hide_other and is_other):
  870. self.tableWidget.hideRow(i)
  871. elif (hide_sf2 and is_sf2):
  872. self.tableWidget.hideRow(i)
  873. elif (hide_ladspa and ptype == "LADSPA"):
  874. self.tableWidget.hideRow(i)
  875. elif (hide_dssi and ptype == "DSSI"):
  876. self.tableWidget.hideRow(i)
  877. elif (hide_lv2 and ptype == "LV2"):
  878. self.tableWidget.hideRow(i)
  879. elif (hide_vst and ptype == "VST"):
  880. self.tableWidget.hideRow(i)
  881. elif (hide_native and is_native):
  882. self.tableWidget.hideRow(i)
  883. elif (hide_bridged and is_bridged):
  884. self.tableWidget.hideRow(i)
  885. elif (hide_bridged_wine and is_bridged_wine):
  886. self.tableWidget.hideRow(i)
  887. elif (hide_non_gui and not has_gui):
  888. self.tableWidget.hideRow(i)
  889. elif (hide_non_stereo and not is_stereo):
  890. self.tableWidget.hideRow(i)
  891. elif (text and not (
  892. text in self.tableWidget.item(i, 0).text().lower() or
  893. text in self.tableWidget.item(i, 1).text().lower() or
  894. text in self.tableWidget.item(i, 2).text().lower() or
  895. text in self.tableWidget.item(i, 3).text().lower() or
  896. text in self.tableWidget.item(i, 13).text().lower())
  897. ):
  898. self.tableWidget.hideRow(i)
  899. def saveSettings(self):
  900. self.settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  901. self.settings.setValue("PluginDatabase/TableGeometry", self.tableWidget.horizontalHeader().saveState())
  902. self.settings.setValue("PluginDatabase/ShowFilters", (self.tb_filters.arrowType() == Qt.UpArrow))
  903. self.settings.setValue("PluginDatabase/ShowEffects", self.ch_effects.isChecked())
  904. self.settings.setValue("PluginDatabase/ShowInstruments", self.ch_instruments.isChecked())
  905. self.settings.setValue("PluginDatabase/ShowMIDI", self.ch_midi.isChecked())
  906. self.settings.setValue("PluginDatabase/ShowOther", self.ch_other.isChecked())
  907. self.settings.setValue("PluginDatabase/ShowLADSPA", self.ch_ladspa.isChecked())
  908. self.settings.setValue("PluginDatabase/ShowDSSI", self.ch_dssi.isChecked())
  909. self.settings.setValue("PluginDatabase/ShowLV2", self.ch_lv2.isChecked())
  910. self.settings.setValue("PluginDatabase/ShowVST", self.ch_vst.isChecked())
  911. self.settings.setValue("PluginDatabase/ShowSF2", self.ch_sf2.isChecked())
  912. self.settings.setValue("PluginDatabase/ShowNative", self.ch_native.isChecked())
  913. self.settings.setValue("PluginDatabase/ShowBridged", self.ch_bridged.isChecked())
  914. self.settings.setValue("PluginDatabase/ShowBridgedWine", self.ch_bridged_wine.isChecked())
  915. self.settings.setValue("PluginDatabase/ShowHasGUI", self.ch_gui.isChecked())
  916. self.settings.setValue("PluginDatabase/ShowStereoOnly", self.ch_stereo.isChecked())
  917. def loadSettings(self):
  918. self.restoreGeometry(self.settings.value("PluginDatabase/Geometry", ""))
  919. self.tableWidget.horizontalHeader().restoreState(self.settings.value("PluginDatabase/TableGeometry", ""))
  920. self.showFilters(self.settings.value("PluginDatabase/ShowFilters", False, type=bool))
  921. self.ch_effects.setChecked(self.settings.value("PluginDatabase/ShowEffects", True, type=bool))
  922. self.ch_instruments.setChecked(self.settings.value("PluginDatabase/ShowInstruments", True, type=bool))
  923. self.ch_midi.setChecked(self.settings.value("PluginDatabase/ShowMIDI", True, type=bool))
  924. self.ch_other.setChecked(self.settings.value("PluginDatabase/ShowOther", True, type=bool))
  925. self.ch_ladspa.setChecked(self.settings.value("PluginDatabase/ShowLADSPA", True, type=bool))
  926. self.ch_dssi.setChecked(self.settings.value("PluginDatabase/ShowDSSI", True, type=bool))
  927. self.ch_lv2.setChecked(self.settings.value("PluginDatabase/ShowLV2", True, type=bool))
  928. self.ch_vst.setChecked(self.settings.value("PluginDatabase/ShowVST", True, type=bool))
  929. self.ch_sf2.setChecked(self.settings.value("PluginDatabase/ShowSF2", True, type=bool))
  930. self.ch_native.setChecked(self.settings.value("PluginDatabase/ShowNative", True, type=bool))
  931. self.ch_bridged.setChecked(self.settings.value("PluginDatabase/ShowBridged", True, type=bool))
  932. self.ch_bridged_wine.setChecked(self.settings.value("PluginDatabase/ShowBridgedWine", True, type=bool))
  933. self.ch_gui.setChecked(self.settings.value("PluginDatabase/ShowHasGUI", False, type=bool))
  934. self.ch_stereo.setChecked(self.settings.value("PluginDatabase/ShowStereoOnly", False, type=bool))
  935. self.reAddPlugins()
  936. def closeEvent(self, event):
  937. self.saveSettings()
  938. QDialog.closeEvent(self, event)
  939. # About Carla Dialog
  940. class AboutW(QDialog, ui_carla_about.Ui_AboutW):
  941. def __init__(self, parent=None):
  942. super(AboutW, self).__init__(parent)
  943. self.setupUi(self)
  944. self.l_about.setText(self.tr(""
  945. "<br>Version %s"
  946. "<br>Carla is a Multi-Plugin Host for JACK.<br>"
  947. "<br>Copyright (C) 2011 falkTX<br>"
  948. "<br><i>VST is a trademark of Steinberg Media Technologies GmbH.</i>"
  949. "" % (VERSION)))
  950. host_osc_url = toString(CarlaHost.get_host_osc_url())
  951. self.le_osc_url.setText(host_osc_url)
  952. self.l_osc_cmds.setText(""
  953. " /set_active <i-value>\n"
  954. " /set_drywet <f-value>\n"
  955. " /set_vol <f-value>\n"
  956. " /set_balance_left <f-value>\n"
  957. " /set_balance_right <f-value>\n"
  958. " /set_parameter <i-index> <f-value>\n"
  959. " /set_program <i-index>\n"
  960. " /set_midi_program <i-index>\n"
  961. " /note_on <i-note> <i-velo>\n"
  962. " /note_off <i-note> <i-velo>\n"
  963. )
  964. self.l_example.setText("/Carla/2/set_parameter_value 2 0.5")
  965. self.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number)</i>")
  966. self.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  967. self.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  968. self.l_lv2.setText(self.tr("About 95&#37; complete (missing state files and other minor features).<br/>"
  969. "Implemented Feature/Extensions:"
  970. "<ul>"
  971. #"<li>http://lv2plug.in/ns/ext/cv-port</li>"
  972. #"<li>http://lv2plug.in/ns/ext/data-access</li>"
  973. #"<li>http://lv2plug.in/ns/ext/event</li>"
  974. #"<li>http://lv2plug.in/ns/ext/host-info</li>"
  975. #"<li>http://lv2plug.in/ns/ext/instance-access</li>"
  976. #"<li>http://lv2plug.in/ns/ext/midi</li>"
  977. #"<li>http://lv2plug.in/ns/ext/port-props</li>"
  978. #"<li>http://lv2plug.in/ns/ext/presets</li>"
  979. #"<li>http://lv2plug.in/ns/ext/state (not files)</li>"
  980. #"<li>http://lv2plug.in/ns/ext/time</li>"
  981. #"<li>http://lv2plug.in/ns/ext/ui-resize</li>"
  982. #"<li>http://lv2plug.in/ns/ext/uri-map</li>"
  983. #"<li>http://lv2plug.in/ns/ext/urid</li>"
  984. #"<li>http://lv2plug.in/ns/extensions/units</li>"
  985. #"<li>http://lv2plug.in/ns/extensions/ui</li>"
  986. #"<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  987. #"<li>http://home.gna.org/lv2dynparam/rtmempool/v1</li>"
  988. #"<li>http://nedko.arnaudov.name/lv2/external_ui/</li>"
  989. "</ul>"
  990. "<i>(Note that Gtk2 UIs with instance-access will not work, such as IR.lv2)</i>"))
  991. self.l_vst.setText(self.tr("<p>About 75&#37; complete (missing MIDI-Output and some minor stuff)</p>"))
  992. # Single Plugin Parameter
  993. class PluginParameter(QWidget, ui_carla_parameter.Ui_PluginParameter):
  994. def __init__(self, parent, pinfo, plugin_id):
  995. QWidget.__init__(self, parent)
  996. self.setupUi(self)
  997. self.ptype = pinfo['type']
  998. self.parameter_id = pinfo['index']
  999. self.hints = pinfo['hints']
  1000. self.midi_cc = -1
  1001. self.midi_channel = 1
  1002. self.plugin_id = plugin_id
  1003. self.add_MIDI_CCs_to_ComboBox()
  1004. self.label.setText(pinfo['name'])
  1005. if (self.ptype == PARAMETER_INPUT):
  1006. self.widget.set_minimum(pinfo['minimum'])
  1007. self.widget.set_maximum(pinfo['maximum'])
  1008. self.widget.set_default(pinfo['default'])
  1009. self.widget.set_value(pinfo['current'], False)
  1010. self.widget.set_label(pinfo['label'])
  1011. self.widget.set_step(pinfo['step'])
  1012. self.widget.set_step_small(pinfo['step_small'])
  1013. self.widget.set_step_large(pinfo['step_large'])
  1014. self.widget.set_scalepoints(pinfo['scalepoints'], (pinfo['hints'] & PARAMETER_USES_SCALEPOINTS))
  1015. if (not self.hints & PARAMETER_IS_ENABLED):
  1016. self.widget.set_read_only(True)
  1017. self.combo.setEnabled(False)
  1018. self.sb_channel.setEnabled(False)
  1019. elif (not self.hints & PARAMETER_IS_AUTOMABLE):
  1020. self.combo.setEnabled(False)
  1021. self.sb_channel.setEnabled(False)
  1022. elif (self.ptype == PARAMETER_OUTPUT):
  1023. self.widget.set_minimum(pinfo['minimum'])
  1024. self.widget.set_maximum(pinfo['maximum'])
  1025. self.widget.set_value(pinfo['current'], False)
  1026. self.widget.set_label(pinfo['label'])
  1027. self.widget.set_read_only(True)
  1028. if (not self.hints & PARAMETER_IS_AUTOMABLE):
  1029. self.combo.setEnabled(False)
  1030. self.sb_channel.setEnabled(False)
  1031. else:
  1032. self.widget.setVisible(False)
  1033. self.combo.setVisible(False)
  1034. self.sb_channel.setVisible(False)
  1035. self.set_parameter_midi_channel(pinfo['midi_channel'])
  1036. self.set_parameter_midi_cc(pinfo['midi_cc'])
  1037. self.connect(self.widget, SIGNAL("valueChanged(double)"), SLOT("slot_valueChanged(double)"))
  1038. self.connect(self.sb_channel, SIGNAL("valueChanged(int)"), SLOT("slot_midiChannelChanged(int)"))
  1039. self.connect(self.combo, SIGNAL("currentIndexChanged(int)"), SLOT("slot_midiCcChanged(int)"))
  1040. #if force_parameters_style:
  1041. #self.widget.force_plastique_style()
  1042. self.widget.updateAll()
  1043. def set_default_value(self, value):
  1044. self.widget.set_default(value)
  1045. def set_parameter_value(self, value, send=True):
  1046. self.widget.set_value(value, send)
  1047. def set_parameter_midi_channel(self, channel):
  1048. self.midi_channel = channel
  1049. self.sb_channel.setValue(channel-1)
  1050. def set_parameter_midi_cc(self, cc_index):
  1051. self.midi_cc = cc_index
  1052. self.set_MIDI_CC_in_ComboBox(cc_index)
  1053. def add_MIDI_CCs_to_ComboBox(self):
  1054. for MIDI_CC in MIDI_CC_LIST:
  1055. self.combo.addItem(MIDI_CC)
  1056. def set_MIDI_CC_in_ComboBox(self, midi_cc):
  1057. for i in range(len(MIDI_CC_LIST)):
  1058. midi_cc_text = MIDI_CC_LIST[i].split(" ")[0]
  1059. if (int(midi_cc_text, 16) == midi_cc):
  1060. cc_index = i
  1061. break
  1062. else:
  1063. cc_index = -1
  1064. cc_index += 1
  1065. self.combo.setCurrentIndex(cc_index)
  1066. @pyqtSlot(float)
  1067. def slot_valueChanged(self, value):
  1068. self.emit(SIGNAL("valueChanged(int, double)"), self.parameter_id, value)
  1069. @pyqtSlot(int)
  1070. def slot_midiChannelChanged(self, channel):
  1071. if (self.midi_channel != channel):
  1072. self.emit(SIGNAL("midiChannelChanged(int, int)"), self.parameter_id, channel)
  1073. self.midi_channel = channel
  1074. @pyqtSlot(int)
  1075. def slot_midiCcChanged(self, cc_index):
  1076. if (cc_index <= 0):
  1077. midi_cc = -1
  1078. else:
  1079. midi_cc_text = MIDI_CC_LIST[cc_index-1].split(" ")[0]
  1080. midi_cc = int(midi_cc_text, 16)
  1081. if (self.midi_cc != midi_cc):
  1082. self.emit(SIGNAL("midiCcChanged(int, int)"), self.parameter_id, midi_cc)
  1083. self.midi_cc = midi_cc
  1084. # Plugin GUI
  1085. class PluginGUI(QDialog):
  1086. def __init__(self, parent, plugin_name, gui_data):
  1087. super(PluginGUI, self).__init__(parent)
  1088. self.myLayout = QVBoxLayout(self)
  1089. self.myLayout.setContentsMargins(0, 0, 0, 0)
  1090. self.setLayout(self.myLayout)
  1091. self.resizable = gui_data['resizable']
  1092. self.setNewSize(gui_data['width'], gui_data['height'])
  1093. if (not plugin_name):
  1094. plugin_name = "Plugin"
  1095. self.setWindowTitle("%s (GUI)" % (plugin_name))
  1096. def setNewSize(self, width, height):
  1097. if (width < 30):
  1098. width = 30
  1099. if (height < 30):
  1100. height = 30
  1101. if (self.resizable):
  1102. self.resize(width, height)
  1103. else:
  1104. self.setFixedSize(width, height)
  1105. def hideEvent(self, event):
  1106. # FIXME
  1107. event.accept()
  1108. self.close()
  1109. # Plugin Editor (Built-in)
  1110. class PluginEdit(QDialog, ui_carla_edit.Ui_PluginEdit):
  1111. def __init__(self, parent, plugin_id):
  1112. QDialog.__init__(self, parent)
  1113. self.setupUi(self)
  1114. self.pinfo = None
  1115. self.ptype = PLUGIN_NONE
  1116. self.plugin_id = plugin_id
  1117. self.parameter_count = 0
  1118. self.parameter_list = [] # type, id, widget
  1119. self.parameter_list_to_update = [] # ids
  1120. self.state_filename = None
  1121. self.cur_program_index = -1
  1122. self.cur_midi_program_index = -1
  1123. self.tab_icon_off = QIcon(":/bitmaps/led_off.png")
  1124. self.tab_icon_on = QIcon(":/bitmaps/led_yellow.png")
  1125. self.tab_icon_count = 0
  1126. self.tab_icon_timers = []
  1127. self.connect(self.b_save_state, SIGNAL("clicked()"), SLOT("slot_saveState()"))
  1128. self.connect(self.b_load_state, SIGNAL("clicked()"), SLOT("slot_loadState()"))
  1129. self.connect(self.keyboard, SIGNAL("noteOn(int)"), SLOT("slot_noteOn(int)"))
  1130. self.connect(self.keyboard, SIGNAL("noteOff(int)"), SLOT("slot_noteOff(int)"))
  1131. self.connect(self.keyboard, SIGNAL("notesOn()"), SLOT("slot_notesOn()"))
  1132. self.connect(self.keyboard, SIGNAL("notesOff()"), SLOT("slot_notesOff()"))
  1133. self.connect(self.cb_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_programIndexChanged(int)"))
  1134. self.connect(self.cb_midi_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_midiProgramIndexChanged(int)"))
  1135. self.keyboard.setMode(self.keyboard.HORIZONTAL)
  1136. self.keyboard.setOctaves(6)
  1137. self.scrollArea.ensureVisible(self.keyboard.width()*1/5, 0)
  1138. self.scrollArea.setVisible(False)
  1139. # TODO - not implemented yet
  1140. self.b_reload_program.setEnabled(False)
  1141. self.b_reload_midi_program.setEnabled(False)
  1142. self.do_reload_all()
  1143. def set_parameter_to_update(self, parameter_id):
  1144. if (parameter_id not in self.parameter_list_to_update):
  1145. self.parameter_list_to_update.append(parameter_id)
  1146. def set_parameter_midi_channel(self, parameter_id, channel):
  1147. for ptype, pid, pwidget in self.parameter_list:
  1148. if (pid == parameter_id):
  1149. pwidget.set_parameter_midi_channel(channel)
  1150. break
  1151. def set_parameter_midi_cc(self, parameter_id, midi_cc):
  1152. for ptype, pid, pwidget in self.parameter_list:
  1153. if (pid == parameter_id):
  1154. pwidget.set_parameter_midi_cc(midi_cc)
  1155. break
  1156. def set_program(self, program_id):
  1157. self.cur_program_index = program_id
  1158. self.cb_programs.setCurrentIndex(program_id)
  1159. QTimer.singleShot(0, self, SLOT("slot_checkInputControlParameters()"))
  1160. def set_midi_program(self, midi_program_id):
  1161. self.cur_midi_program_index = midi_program_id
  1162. self.cb_midi_programs.setCurrentIndex(midi_program_id)
  1163. QTimer.singleShot(0, self, SLOT("slot_checkInputControlParameters()"))
  1164. def do_update(self):
  1165. # Update current program text
  1166. if (self.cb_programs.count() > 0):
  1167. pindex = self.cb_programs.currentIndex()
  1168. pname = toString(CarlaHost.get_program_name(self.plugin_id, pindex))
  1169. self.cb_programs.setItemText(pindex, pname)
  1170. # Update current midi program text
  1171. if (self.cb_midi_programs.count() > 0):
  1172. mpindex = self.cb_midi_programs.currentIndex()
  1173. mpname = "%s %s" % (self.cb_midi_programs.currentText().split(" ", 1)[0], toString(CarlaHost.get_midi_program_name(self.plugin_id, mpindex)))
  1174. self.cb_midi_programs.setItemText(pindex, mpname)
  1175. QTimer.singleShot(0, self, SLOT("slot_checkInputControlParameters()"))
  1176. QTimer.singleShot(0, self, SLOT("slot_checkOutputControlParameters()"))
  1177. def do_reload_all(self):
  1178. self.pinfo = CarlaHost.get_plugin_info(self.plugin_id)
  1179. if (self.pinfo['valid']):
  1180. self.pinfo["binary"] = toString(self.pinfo["binary"])
  1181. self.pinfo["name"] = toString(self.pinfo["name"])
  1182. self.pinfo["label"] = toString(self.pinfo["label"])
  1183. self.pinfo["maker"] = toString(self.pinfo["maker"])
  1184. self.pinfo["copyright"] = toString(self.pinfo["copyright"])
  1185. else:
  1186. self.pinfo["type"] = PLUGIN_NONE
  1187. self.pinfo["category"] = PLUGIN_CATEGORY_NONE
  1188. self.pinfo["hints"] = 0x0
  1189. self.pinfo["binary"] = ""
  1190. self.pinfo["name"] = "(Unknown)"
  1191. self.pinfo["label"] = ""
  1192. self.pinfo["maker"] = ""
  1193. self.pinfo["copyright"] = ""
  1194. self.pinfo["unique_id"] = 0
  1195. self.do_reload_info()
  1196. self.do_reload_parameters()
  1197. self.do_reload_programs()
  1198. def do_reload_info(self):
  1199. if (self.ptype == PLUGIN_NONE and self.pinfo['type'] in (PLUGIN_DSSI, PLUGIN_SF2)):
  1200. self.tab_programs.setCurrentIndex(1)
  1201. self.ptype = self.pinfo['type']
  1202. real_plugin_name = toString(CarlaHost.get_real_plugin_name(self.plugin_id))
  1203. self.le_name.setText(real_plugin_name)
  1204. self.le_name.setToolTip(real_plugin_name)
  1205. self.le_label.setText(self.pinfo['label'])
  1206. self.le_label.setToolTip(self.pinfo['label'])
  1207. self.le_maker.setText(self.pinfo['maker'])
  1208. self.le_maker.setToolTip(self.pinfo['maker'])
  1209. self.le_copyright.setText(self.pinfo['copyright'])
  1210. self.le_copyright.setToolTip(self.pinfo['copyright'])
  1211. self.le_unique_id.setText(str(self.pinfo['unique_id']))
  1212. self.le_unique_id.setToolTip(str(self.pinfo['unique_id']))
  1213. self.label_plugin.setText("\n%s\n" % (self.pinfo['name']))
  1214. self.setWindowTitle(self.pinfo['name'])
  1215. if (self.ptype == PLUGIN_LADSPA):
  1216. self.le_type.setText("LADSPA")
  1217. elif (self.ptype == PLUGIN_DSSI):
  1218. self.le_type.setText("DSSI")
  1219. elif (self.ptype == PLUGIN_LV2):
  1220. self.le_type.setText("LV2")
  1221. elif (self.ptype == PLUGIN_VST):
  1222. self.le_type.setText("VST")
  1223. elif (self.ptype == PLUGIN_SF2):
  1224. self.le_type.setText("SoundFont")
  1225. else:
  1226. self.le_type.setText(self.tr("Unknown"))
  1227. audio_count = CarlaHost.get_audio_port_count_info(self.plugin_id)
  1228. if (not audio_count['valid']):
  1229. audio_count['ins'] = 0
  1230. audio_count['outs'] = 0
  1231. audio_count['total'] = 0
  1232. midi_count = CarlaHost.get_midi_port_count_info(self.plugin_id)
  1233. if (not midi_count['valid']):
  1234. midi_count['ins'] = 0
  1235. midi_count['outs'] = 0
  1236. midi_count['total'] = 0
  1237. param_count = CarlaHost.get_parameter_count_info(self.plugin_id)
  1238. if (not param_count['valid']):
  1239. param_count['ins'] = 0
  1240. param_count['outs'] = 0
  1241. param_count['total'] = 0
  1242. self.le_ains.setText(str(audio_count['ins']))
  1243. self.le_aouts.setText(str(audio_count['outs']))
  1244. self.le_params.setText(str(param_count['ins']))
  1245. self.le_couts.setText(str(param_count['outs']))
  1246. self.le_is_synth.setText(self.tr("Yes") if (self.pinfo['hints'] & PLUGIN_IS_SYNTH) else (self.tr("No")))
  1247. self.le_has_gui.setText(self.tr("Yes") if (self.pinfo['hints'] & PLUGIN_HAS_GUI) else (self.tr("No")))
  1248. self.scrollArea.setVisible(self.pinfo['hints'] & PLUGIN_IS_SYNTH or (midi_count['ins'] > 0 and midi_count['outs'] > 0))
  1249. self.parent().recheck_hints(self.pinfo['hints'])
  1250. def do_reload_parameters(self):
  1251. parameters_count = CarlaHost.get_parameter_count(self.plugin_id)
  1252. self.parameter_list = []
  1253. self.parameter_list_to_update = []
  1254. self.tab_icon_count = 0
  1255. self.tab_icon_timers = []
  1256. for i in range(self.tabWidget.count()):
  1257. if (i == 0): continue
  1258. self.tabWidget.widget(1).deleteLater()
  1259. self.tabWidget.removeTab(1)
  1260. if (parameters_count <= 0):
  1261. pass
  1262. elif (parameters_count <= MAX_PARAMETERS):
  1263. p_in = []
  1264. p_in_tmp = []
  1265. p_in_index = 0
  1266. p_in_width = 0
  1267. p_out = []
  1268. p_out_tmp = []
  1269. p_out_index = 0
  1270. p_out_width = 0
  1271. for i in range(parameters_count):
  1272. param_info = CarlaHost.get_parameter_info(self.plugin_id, i)
  1273. param_data = CarlaHost.get_parameter_data(self.plugin_id, i)
  1274. param_ranges = CarlaHost.get_parameter_ranges(self.plugin_id, i)
  1275. if not param_info['valid']:
  1276. continue
  1277. parameter = {
  1278. 'type': param_data['type'],
  1279. 'hints': param_data['hints'],
  1280. 'name': toString(param_info['name']),
  1281. 'label': toString(param_info['label']),
  1282. 'scalepoints': [],
  1283. 'index': param_data['index'],
  1284. 'default': param_ranges['def'],
  1285. 'minimum': param_ranges['min'],
  1286. 'maximum': param_ranges['max'],
  1287. 'step': param_ranges['step'],
  1288. 'step_small': param_ranges['step_small'],
  1289. 'step_large': param_ranges['step_large'],
  1290. 'midi_channel': param_data['midi_channel'],
  1291. 'midi_cc': param_data['midi_cc'],
  1292. 'current': CarlaHost.get_current_parameter_value(self.plugin_id, i)
  1293. }
  1294. for j in range(param_info['scalepoint_count']):
  1295. scalepoint = CarlaHost.get_scalepoint_info(self.plugin_id, i, j)
  1296. parameter['scalepoints'].append({'value': scalepoint['value'], 'label': toString(scalepoint['label'])})
  1297. # -----------------------------------------------------------------
  1298. # Get width values, in packs of 10
  1299. if (parameter['type'] == PARAMETER_INPUT):
  1300. p_in_tmp.append(parameter)
  1301. p_in_width_tmp = QFontMetrics(self.font()).width(parameter['name'])
  1302. if (p_in_width_tmp > p_in_width):
  1303. p_in_width = p_in_width_tmp
  1304. if (len(p_in_tmp) == 10):
  1305. p_in.append((p_in_tmp, p_in_width))
  1306. p_in_tmp = []
  1307. p_in_index = 0
  1308. p_in_width = 0
  1309. else:
  1310. p_in_index += 1
  1311. elif (parameter['type'] == PARAMETER_OUTPUT):
  1312. p_out_tmp.append(parameter)
  1313. p_out_width_tmp = QFontMetrics(self.font()).width(parameter['name'])
  1314. if (p_out_width_tmp > p_out_width):
  1315. p_out_width = p_out_width_tmp
  1316. if (len(p_out_tmp) == 10):
  1317. p_out.append((p_out_tmp, p_out_width))
  1318. p_out_tmp = []
  1319. p_out_index = 0
  1320. p_out_width = 0
  1321. else:
  1322. p_out_index += 1
  1323. else:
  1324. # Final page width values
  1325. if (len(p_in_tmp) > 0 and len(p_in_tmp) < 10):
  1326. p_in.append((p_in_tmp, p_in_width))
  1327. if (len(p_out_tmp) > 0 and len(p_out_tmp) < 10):
  1328. p_out.append((p_out_tmp, p_out_width))
  1329. # -----------------------------------------------------------------
  1330. # Create parameter widgets
  1331. if (len(p_in) > 0):
  1332. self.createParameterWidgets(p_in, self.tr("Parameters"), PARAMETER_INPUT)
  1333. if (len(p_out) > 0):
  1334. self.createParameterWidgets(p_out, self.tr("Outputs"), PARAMETER_OUTPUT)
  1335. else: # > MAX_PARAMETERS
  1336. fake_name = "This plugin has too many parameters to display here!"
  1337. p_fake = []
  1338. p_fake_tmp = []
  1339. p_fake_width = QFontMetrics(self.font()).width(fake_name)
  1340. parameter = {
  1341. 'type': PARAMETER_UNKNOWN,
  1342. 'hints': 0,
  1343. 'name': fake_name,
  1344. 'label': "",
  1345. 'scalepoints': [],
  1346. 'index': 0,
  1347. 'default': 0,
  1348. 'minimum': 0,
  1349. 'maximum': 0,
  1350. 'step': 0,
  1351. 'step_small': 0,
  1352. 'step_large': 0,
  1353. 'midi_channel': 0,
  1354. 'midi_cc': -1,
  1355. 'current': 0.0
  1356. }
  1357. p_fake_tmp.append(parameter)
  1358. p_fake.append((p_fake_tmp, p_fake_width))
  1359. self.createParameterWidgets(p_fake, self.tr("Information"), PARAMETER_UNKNOWN)
  1360. def do_reload_programs(self):
  1361. # Programs
  1362. self.cb_programs.blockSignals(True)
  1363. self.cb_programs.clear()
  1364. program_count = CarlaHost.get_program_count(self.plugin_id)
  1365. if (program_count > 0):
  1366. self.cb_programs.setEnabled(True)
  1367. for i in range(program_count):
  1368. pname = toString(CarlaHost.get_program_name(self.plugin_id, i))
  1369. self.cb_programs.addItem(pname)
  1370. self.cur_program_index = CarlaHost.get_current_program_index(self.plugin_id)
  1371. self.cb_programs.setCurrentIndex(self.cur_program_index)
  1372. else:
  1373. self.cb_programs.setEnabled(False)
  1374. self.cb_programs.blockSignals(False)
  1375. # MIDI Programs
  1376. self.cb_midi_programs.blockSignals(True)
  1377. self.cb_midi_programs.clear()
  1378. midi_program_count = CarlaHost.get_midi_program_count(self.plugin_id)
  1379. if (midi_program_count > 0):
  1380. self.cb_midi_programs.setEnabled(True)
  1381. for i in range(midi_program_count):
  1382. midip = CarlaHost.get_midi_program_info(self.plugin_id, i)
  1383. bank = int(midip['bank'])
  1384. prog = int(midip['program'])
  1385. label = toString(midip['label'])
  1386. self.cb_midi_programs.addItem("%03i:%03i - %s" % (bank, prog, label))
  1387. self.cur_midi_program_index = CarlaHost.get_current_midi_program_index(self.plugin_id)
  1388. self.cb_midi_programs.setCurrentIndex(self.cur_midi_program_index)
  1389. else:
  1390. self.cb_midi_programs.setEnabled(False)
  1391. self.cb_midi_programs.blockSignals(False)
  1392. def saveState_InternalFormat(self):
  1393. content = ("<?xml version='1.0' encoding='UTF-8'?>\n"
  1394. "<!DOCTYPE CARLA-PRESET>\n"
  1395. "<CARLA-PRESET VERSION='%s'>\n") % (VERSION)
  1396. content += self.parent().getSaveXMLContent()
  1397. content += "</CARLA-PRESET>\n"
  1398. try:
  1399. open(self.state_filename, "w").write(content)
  1400. except:
  1401. QMessageBox.critical(self, self.tr("Error"), self.tr("Failed to save state file"))
  1402. def saveState_Lv2Format(self):
  1403. pass
  1404. def saveState_VstFormat(self):
  1405. pass
  1406. def loadState_InternalFormat(self):
  1407. try:
  1408. state_read = open(self.state_filename, "r").read()
  1409. except:
  1410. QMessageBox.critical(self, self.tr("Error"), self.tr("Failed to load state file"))
  1411. return
  1412. xml = QDomDocument()
  1413. xml.setContent(state_read)
  1414. xml_node = xml.documentElement()
  1415. if (xml_node.tagName() != "CARLA-PRESET"):
  1416. QMessageBox.critical(self, self.tr("Error"), self.tr("Not a valid Carla state file"))
  1417. return
  1418. x_save_state_dict = getStateDictFromXML(xml_node)
  1419. self.parent().loadStateDict(x_save_state_dict)
  1420. def createParameterWidgets(self, p_list_full, tab_name, ptype):
  1421. for i in range(len(p_list_full)):
  1422. p_list = p_list_full[i][0]
  1423. width = p_list_full[i][1]
  1424. if (len(p_list) > 0):
  1425. container = QWidget(self.tabWidget)
  1426. layout = QVBoxLayout(container)
  1427. container.setLayout(layout)
  1428. for j in range(len(p_list)):
  1429. pwidget = PluginParameter(container, p_list[j], self.plugin_id)
  1430. pwidget.label.setMinimumWidth(width)
  1431. pwidget.label.setMaximumWidth(width)
  1432. pwidget.tab_index = self.tabWidget.count()
  1433. layout.addWidget(pwidget)
  1434. self.parameter_list.append((ptype, p_list[j]['index'], pwidget))
  1435. if (ptype == PARAMETER_INPUT):
  1436. self.connect(pwidget, SIGNAL("valueChanged(int, double)"), SLOT("slot_parameterValueChanged(int, double)"))
  1437. self.connect(pwidget, SIGNAL("midiChannelChanged(int, int)"), SLOT("slot_parameterMidiChannelChanged(int, int)"))
  1438. self.connect(pwidget, SIGNAL("midiCcChanged(int, int)"), SLOT("slot_parameterMidiCcChanged(int, int)"))
  1439. layout.addStretch()
  1440. self.tabWidget.addTab(container, "%s (%i)" % (tab_name, i+1))
  1441. if (ptype == PARAMETER_INPUT):
  1442. self.tabWidget.setTabIcon(pwidget.tab_index, self.tab_icon_off)
  1443. self.tab_icon_timers.append(ICON_STATE_NULL)
  1444. def animateTab(self, index):
  1445. if (self.tab_icon_timers[index-1] == ICON_STATE_NULL):
  1446. self.tabWidget.setTabIcon(index, self.tab_icon_on)
  1447. self.tab_icon_timers[index-1] = ICON_STATE_ON
  1448. def check_gui_stuff(self):
  1449. # Check Tab icons
  1450. for i in range(len(self.tab_icon_timers)):
  1451. if (self.tab_icon_timers[i] == ICON_STATE_ON):
  1452. self.tab_icon_timers[i] = ICON_STATE_WAIT
  1453. elif (self.tab_icon_timers[i] == ICON_STATE_WAIT):
  1454. self.tab_icon_timers[i] = ICON_STATE_OFF
  1455. elif (self.tab_icon_timers[i] == ICON_STATE_OFF):
  1456. self.tabWidget.setTabIcon(i+1, self.tab_icon_off)
  1457. self.tab_icon_timers[i] = ICON_STATE_NULL
  1458. # Check parameters needing update
  1459. for parameter_id in self.parameter_list_to_update:
  1460. value = CarlaHost.get_current_parameter_value(self.plugin_id, parameter_id)
  1461. for ptype, pid, pwidget in self.parameter_list:
  1462. if (pid == parameter_id):
  1463. pwidget.set_parameter_value(value, False)
  1464. if (ptype == PARAMETER_INPUT):
  1465. self.animateTab(pwidget.tab_index)
  1466. break
  1467. # Clear all parameters
  1468. self.parameter_list_to_update = []
  1469. # Update output parameters
  1470. QTimer.singleShot(0, self, SLOT("slot_checkOutputControlParameters()"))
  1471. @pyqtSlot()
  1472. def slot_saveState(self):
  1473. # TODO - LV2 and VST native formats
  1474. if (self.state_filename):
  1475. ask_try = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  1476. if (ask_try == QMessageBox.Ok):
  1477. self.saveState_InternalFormat()
  1478. else:
  1479. self.state_filename = None
  1480. self.slot_saveState()
  1481. else:
  1482. file_filter = self.tr("Carla State File (*.carxs)")
  1483. filename_try = QFileDialog.getSaveFileName(self, self.tr("Save Carla State File"), filter=file_filter)
  1484. if (filename_try):
  1485. self.state_filename = filename_try
  1486. self.saveState_InternalFormat()
  1487. @pyqtSlot()
  1488. def slot_loadState(self):
  1489. # TODO - LV2 and VST native formats
  1490. file_filter = self.tr("Carla State File (*.carxs)")
  1491. filename_try = QFileDialog.getOpenFileName(self, self.tr("Open Carla State File"), filter=file_filter)
  1492. if (filename_try):
  1493. self.state_filename = filename_try
  1494. self.loadState_InternalFormat()
  1495. @pyqtSlot(int, float)
  1496. def slot_parameterValueChanged(self, parameter_id, value):
  1497. CarlaHost.set_parameter_value(self.plugin_id, parameter_id, value)
  1498. @pyqtSlot(int, int)
  1499. def slot_parameterMidiChannelChanged(self, parameter_id, channel):
  1500. CarlaHost.set_parameter_midi_channel(self.plugin_id, parameter_id, channel-1)
  1501. @pyqtSlot(int, int)
  1502. def slot_parameterMidiCcChanged(self, parameter_id, cc_index):
  1503. CarlaHost.set_parameter_midi_cc(self.plugin_id, parameter_id, cc_index)
  1504. @pyqtSlot(int)
  1505. def slot_programIndexChanged(self, index):
  1506. if (self.cur_program_index != index):
  1507. CarlaHost.set_program(self.plugin_id, index)
  1508. QTimer.singleShot(0, self, SLOT("slot_checkInputControlParameters()"))
  1509. self.cur_program_index = index
  1510. @pyqtSlot(int)
  1511. def slot_midiProgramIndexChanged(self, index):
  1512. if (self.cur_midi_program_index != index):
  1513. CarlaHost.set_midi_program(self.plugin_id, index)
  1514. QTimer.singleShot(0, self, SLOT("slot_checkInputControlParameters()"))
  1515. self.cur_midi_program_index = index
  1516. @pyqtSlot(int)
  1517. def slot_noteOn(self, note):
  1518. CarlaHost.send_midi_note(self.plugin_id, True, note, 100)
  1519. @pyqtSlot(int)
  1520. def slot_noteOff(self, note):
  1521. CarlaHost.send_midi_note(self.plugin_id, False, note, 0)
  1522. @pyqtSlot()
  1523. def slot_notesOn(self):
  1524. self.parent().led_midi.setChecked(True)
  1525. @pyqtSlot()
  1526. def slot_notesOff(self):
  1527. self.parent().led_midi.setChecked(False)
  1528. @pyqtSlot()
  1529. def slot_checkInputControlParameters(self):
  1530. for ptype, pid, pwidget in self.parameter_list:
  1531. if (ptype == PARAMETER_INPUT):
  1532. pwidget.set_default_value(CarlaHost.get_default_parameter_value(self.plugin_id, pid))
  1533. pwidget.set_parameter_value(CarlaHost.get_current_parameter_value(self.plugin_id, pid), False)
  1534. @pyqtSlot()
  1535. def slot_checkOutputControlParameters(self):
  1536. for ptype, pid, pwidget in self.parameter_list:
  1537. if (ptype == PARAMETER_OUTPUT):
  1538. pwidget.set_parameter_value(CarlaHost.get_current_parameter_value(self.plugin_id, pid), False)
  1539. # (New) Plugin Widget
  1540. class PluginWidget(QFrame, ui_carla_plugin.Ui_PluginWidget):
  1541. def __init__(self, parent, plugin_id):
  1542. QFrame.__init__(self, parent)
  1543. self.setupUi(self)
  1544. self.plugin_id = plugin_id
  1545. self.params_total = 0
  1546. self.parameter_activity_timer = None
  1547. self.last_led_ain_state = False
  1548. self.last_led_aout_state = False
  1549. # Fake effect
  1550. self.color_1 = QColor( 0, 0, 0, 220)
  1551. self.color_2 = QColor( 0, 0, 0, 170)
  1552. self.color_3 = QColor( 7, 7, 7, 250)
  1553. self.color_4 = QColor(14, 14, 14, 255)
  1554. self.led_enable.setColor(self.led_enable.BIG_RED)
  1555. self.led_enable.setChecked(False)
  1556. self.led_control.setColor(self.led_control.YELLOW)
  1557. self.led_control.setEnabled(False)
  1558. self.led_midi.setColor(self.led_midi.RED)
  1559. self.led_midi.setEnabled(False)
  1560. self.led_audio_in.setColor(self.led_audio_in.GREEN)
  1561. self.led_audio_in.setEnabled(False)
  1562. self.led_audio_out.setColor(self.led_audio_out.BLUE)
  1563. self.led_audio_out.setEnabled(False)
  1564. self.dial_drywet.setPixmap(1)
  1565. self.dial_vol.setPixmap(2)
  1566. self.dial_b_left.setPixmap(1)
  1567. self.dial_b_right.setPixmap(1)
  1568. self.dial_drywet.setLabel("Wet")
  1569. self.dial_vol.setLabel("Vol")
  1570. self.dial_b_left.setLabel("L")
  1571. self.dial_b_right.setLabel("R")
  1572. self.peak_in.setColor(self.peak_in.GREEN)
  1573. self.peak_in.setOrientation(self.peak_in.HORIZONTAL)
  1574. self.peak_out.setColor(self.peak_in.BLUE)
  1575. self.peak_out.setOrientation(self.peak_out.HORIZONTAL)
  1576. audio_count = CarlaHost.get_audio_port_count_info(self.plugin_id)
  1577. if (not audio_count['valid']):
  1578. audio_count['ins'] = 0
  1579. audio_count['outs'] = 0
  1580. audio_count['total'] = 0
  1581. self.peaks_in = audio_count['ins']
  1582. self.peaks_out = audio_count['outs']
  1583. if (self.peaks_in > 2):
  1584. self.peaks_in = 2
  1585. if (self.peaks_out > 2):
  1586. self.peaks_out = 2
  1587. self.peak_in.setChannels(self.peaks_in)
  1588. self.peak_out.setChannels(self.peaks_out)
  1589. self.pinfo = CarlaHost.get_plugin_info(self.plugin_id)
  1590. if (self.pinfo['valid']):
  1591. self.pinfo["binary"] = toString(self.pinfo["binary"])
  1592. self.pinfo["name"] = toString(self.pinfo["name"])
  1593. self.pinfo["label"] = toString(self.pinfo["label"])
  1594. self.pinfo["maker"] = toString(self.pinfo["maker"])
  1595. self.pinfo["copyright"] = toString(self.pinfo["copyright"])
  1596. else:
  1597. self.pinfo["type"] = PLUGIN_NONE
  1598. self.pinfo["category"] = PLUGIN_CATEGORY_NONE
  1599. self.pinfo["hints"] = 0
  1600. self.pinfo["binary"] = ""
  1601. self.pinfo["name"] = "(Unknown)"
  1602. self.pinfo["label"] = ""
  1603. self.pinfo["maker"] = ""
  1604. self.pinfo["copyright"] = ""
  1605. self.pinfo["unique_id"] = 0
  1606. # Set widget page
  1607. if (self.pinfo['type'] == PLUGIN_NONE or audio_count['total'] == 0):
  1608. self.stackedWidget.setCurrentIndex(1)
  1609. self.label_name.setText(self.pinfo['name'])
  1610. # Enable/disable features
  1611. self.recheck_hints(self.pinfo['hints'])
  1612. # Colorify
  1613. if (self.pinfo['category'] == PLUGIN_CATEGORY_SYNTH):
  1614. self.setWidgetColor(PALETTE_COLOR_WHITE)
  1615. elif (self.pinfo['category'] == PLUGIN_CATEGORY_DELAY):
  1616. self.setWidgetColor(PALETTE_COLOR_ORANGE)
  1617. elif (self.pinfo['category'] == PLUGIN_CATEGORY_EQ):
  1618. self.setWidgetColor(PALETTE_COLOR_GREEN)
  1619. elif (self.pinfo['category'] == PLUGIN_CATEGORY_FILTER):
  1620. self.setWidgetColor(PALETTE_COLOR_BLUE)
  1621. elif (self.pinfo['category'] == PLUGIN_CATEGORY_DYNAMICS):
  1622. self.setWidgetColor(PALETTE_COLOR_PINK)
  1623. elif (self.pinfo['category'] == PLUGIN_CATEGORY_MODULATOR):
  1624. self.setWidgetColor(PALETTE_COLOR_RED)
  1625. elif (self.pinfo['category'] == PLUGIN_CATEGORY_UTILITY):
  1626. self.setWidgetColor(PALETTE_COLOR_YELLOW)
  1627. elif (self.pinfo['category'] == PLUGIN_CATEGORY_OUTRO):
  1628. self.setWidgetColor(PALETTE_COLOR_BROWN)
  1629. else:
  1630. self.setWidgetColor(PALETTE_COLOR_NONE)
  1631. if (self.pinfo['hints'] & PLUGIN_IS_SYNTH):
  1632. self.led_audio_in.setVisible(False)
  1633. else:
  1634. self.led_midi.setVisible(False)
  1635. self.edit_dialog = PluginEdit(self, self.plugin_id)
  1636. self.edit_dialog.hide()
  1637. self.edit_dialog_geometry = None
  1638. if (self.pinfo['hints'] & PLUGIN_HAS_GUI):
  1639. gui_info = CarlaHost.get_gui_info(self.plugin_id)
  1640. self.gui_dialog_type = gui_info['type']
  1641. if (self.gui_dialog_type in (GUI_INTERNAL_QT4, GUI_INTERNAL_X11)):
  1642. self.gui_dialog = None
  1643. #self.gui_dialog = PluginGUI(self, self.pinfo['name'], gui_data)
  1644. #self.gui_dialog.hide()
  1645. self.gui_dialog_geometry = None
  1646. #self.connect(self.gui_dialog, SIGNAL("finished(int)"), self.gui_dialog_closed)
  1647. #CarlaHost.set_gui_data(self.plugin_id, Display, unwrapinstance(self.gui_dialog))
  1648. elif (self.gui_dialog_type in (GUI_EXTERNAL_OSC, GUI_EXTERNAL_LV2)):
  1649. self.gui_dialog = None
  1650. else:
  1651. self.gui_dialog = None
  1652. self.gui_dialog_type = GUI_NONE
  1653. self.b_gui.setEnabled(False)
  1654. else:
  1655. self.gui_dialog = None
  1656. self.gui_dialog_type = GUI_NONE
  1657. self.connect(self.led_enable, SIGNAL("clicked(bool)"), SLOT("slot_setActive(bool)"))
  1658. self.connect(self.dial_drywet, SIGNAL("sliderMoved(int)"), SLOT("slot_setDryWet(int)"))
  1659. self.connect(self.dial_vol, SIGNAL("sliderMoved(int)"), SLOT("slot_setVolume(int)"))
  1660. self.connect(self.dial_b_left, SIGNAL("sliderMoved(int)"), SLOT("slot_setBalanceLeft(int)"))
  1661. self.connect(self.dial_b_right, SIGNAL("sliderMoved(int)"), SLOT("slot_setBalanceRight(int)"))
  1662. self.connect(self.b_gui, SIGNAL("clicked(bool)"), SLOT("slot_guiClicked(bool)"))
  1663. self.connect(self.b_edit, SIGNAL("clicked(bool)"), SLOT("slot_editClicked(bool)"))
  1664. self.connect(self.b_remove, SIGNAL("clicked()"), SLOT("slot_removeClicked()"))
  1665. self.connect(self.dial_drywet, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1666. self.connect(self.dial_vol, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1667. self.connect(self.dial_b_left, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1668. self.connect(self.dial_b_right, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  1669. self.connect(self.edit_dialog, SIGNAL("finished(int)"), SLOT("slot_editClosed()"))
  1670. self.check_gui_stuff()
  1671. def set_active(self, active, gui_send=False, callback_send=True):
  1672. if (gui_send): self.led_enable.setChecked(active)
  1673. if (callback_send): CarlaHost.set_active(self.plugin_id, active)
  1674. def set_drywet(self, value, gui_send=False, callback_send=True):
  1675. if (gui_send): self.dial_drywet.setValue(value)
  1676. if (callback_send): CarlaHost.set_drywet(self.plugin_id, float(value)/1000)
  1677. message = self.tr("Output dry/wet (%s%%)" % (value/10))
  1678. self.dial_drywet.setStatusTip(message)
  1679. gui.statusBar().showMessage(message)
  1680. def set_volume(self, value, gui_send=False, callback_send=True):
  1681. if (gui_send): self.dial_vol.setValue(value)
  1682. if (callback_send): CarlaHost.set_volume(self.plugin_id, float(value)/1000)
  1683. message = self.tr("Output volume (%s%%)" % (value/10))
  1684. self.dial_vol.setStatusTip(message)
  1685. gui.statusBar().showMessage(message)
  1686. def set_balance_left(self, value, gui_send=False, callback_send=True):
  1687. if (gui_send): self.dial_b_left.setValue(value)
  1688. if (callback_send): CarlaHost.set_balance_left(self.plugin_id, float(value)/1000)
  1689. if (value == 0):
  1690. message = self.tr("Left Panning (Center)")
  1691. elif (value < 0):
  1692. message = self.tr("Left Panning (%s%% Left)" % (-value/10))
  1693. else:
  1694. message = self.tr("Left Panning (%s%% Right)" % (value/10))
  1695. self.dial_b_left.setStatusTip(message)
  1696. gui.statusBar().showMessage(message)
  1697. def set_balance_right(self, value, gui_send=False, callback_send=True):
  1698. if (gui_send): self.dial_b_right.setValue(value)
  1699. if (callback_send): CarlaHost.set_balance_right(self.plugin_id, float(value)/1000)
  1700. if (value == 0):
  1701. message = self.tr("Right Panning (Center)")
  1702. elif (value < 0):
  1703. message = self.tr("Right Panning (%s%% Left" % (-value/10))
  1704. else:
  1705. message = self.tr("Right Panning (%s%% Right)" % (value/10))
  1706. self.dial_b_right.setStatusTip(message)
  1707. gui.statusBar().showMessage(message)
  1708. def setWidgetColor(self, color):
  1709. if (color == PALETTE_COLOR_WHITE):
  1710. r = 110
  1711. g = 110
  1712. b = 110
  1713. texture = 7
  1714. elif (color == PALETTE_COLOR_RED):
  1715. r = 110
  1716. g = 15
  1717. b = 15
  1718. texture = 3
  1719. elif (color == PALETTE_COLOR_GREEN):
  1720. r = 15
  1721. g = 110
  1722. b = 15
  1723. texture = 6
  1724. elif (color == PALETTE_COLOR_BLUE):
  1725. r = 15
  1726. g = 15
  1727. b = 110
  1728. texture = 4
  1729. elif (color == PALETTE_COLOR_YELLOW):
  1730. r = 110
  1731. g = 110
  1732. b = 15
  1733. texture = 2
  1734. elif (color == PALETTE_COLOR_ORANGE):
  1735. r = 180
  1736. g = 110
  1737. b = 15
  1738. texture = 5
  1739. elif (color == PALETTE_COLOR_BROWN):
  1740. r = 110
  1741. g = 35
  1742. b = 15
  1743. texture = 1
  1744. elif (color == PALETTE_COLOR_PINK):
  1745. r = 110
  1746. g = 15
  1747. b = 110
  1748. texture = 8
  1749. else:
  1750. r = 35
  1751. g = 35
  1752. b = 35
  1753. texture = 9
  1754. self.setStyleSheet("""
  1755. QFrame#PluginWidget {
  1756. background-image: url(:/bitmaps/textures/metal_%i-512px.jpg);
  1757. background-repeat: repeat-x;
  1758. background-position: top left;
  1759. }
  1760. QLabel#label_name {
  1761. color: white;
  1762. }
  1763. QFrame#frame_name {
  1764. background-image: url(:/bitmaps/glass.png);
  1765. background-color: rgb(%i, %i, %i);
  1766. border: 2px outset;
  1767. border-color: rgb(%i, %i, %i);
  1768. }
  1769. QFrame#frame_controls {
  1770. background-image: url(:/bitmaps/glass2.png);
  1771. background-color: rgb(30, 30, 30);
  1772. border: 2px outset;
  1773. border-color: rgb(30, 30, 30);
  1774. }
  1775. QFrame#frame_peaks {
  1776. background-color: rgba(30, 30, 30, 200);
  1777. border: 2px outset;
  1778. border-color: rgba(30, 30, 30, 225);
  1779. }
  1780. """ % (texture, r, g, b, r, g, b))
  1781. def recheck_hints(self, hints):
  1782. self.pinfo['hints'] = hints
  1783. self.dial_drywet.setEnabled(self.pinfo['hints'] & PLUGIN_CAN_DRYWET)
  1784. self.dial_vol.setEnabled(self.pinfo['hints'] & PLUGIN_CAN_VOLUME)
  1785. self.dial_b_left.setEnabled(self.pinfo['hints'] & PLUGIN_CAN_BALANCE)
  1786. self.dial_b_right.setEnabled(self.pinfo['hints'] & PLUGIN_CAN_BALANCE)
  1787. self.b_gui.setEnabled(self.pinfo['hints'] & PLUGIN_HAS_GUI)
  1788. def getSaveXMLContent(self):
  1789. CarlaHost.prepare_for_save(self.plugin_id)
  1790. if (self.pinfo['type'] == PLUGIN_LADSPA):
  1791. type_str = "LADSPA"
  1792. elif (self.pinfo['type'] == PLUGIN_DSSI):
  1793. type_str = "DSSI"
  1794. elif (self.pinfo['type'] == PLUGIN_LV2):
  1795. type_str = "LV2"
  1796. elif (self.pinfo['type'] == PLUGIN_VST):
  1797. type_str = "VST"
  1798. elif (self.pinfo['type'] == PLUGIN_SF2):
  1799. type_str = "SoundFont"
  1800. else:
  1801. type_str = "Unknown"
  1802. x_save_state_dict = deepcopy(save_state_dict)
  1803. # ----------------------------
  1804. # Basic info
  1805. x_save_state_dict['Type'] = type_str
  1806. x_save_state_dict['Name'] = self.pinfo['name'] # toString(CarlaHost.get_real_plugin_name(self.plugin_id))
  1807. x_save_state_dict['Label'] = self.pinfo['label']
  1808. x_save_state_dict['Binary'] = self.pinfo['binary']
  1809. x_save_state_dict['UniqueID'] = self.pinfo['unique_id']
  1810. # ----------------------------
  1811. # Internals
  1812. x_save_state_dict['Active'] = self.led_enable.isChecked()
  1813. x_save_state_dict['DryWet'] = float(self.dial_drywet.value())/1000
  1814. x_save_state_dict['Volume'] = float(self.dial_vol.value())/1000
  1815. x_save_state_dict['Balance-Left'] = float(self.dial_b_left.value())/1000
  1816. x_save_state_dict['Balance-Right'] = float(self.dial_b_right.value())/1000
  1817. # ----------------------------
  1818. # Current Program
  1819. if (self.edit_dialog.cb_programs.currentIndex() >= 0):
  1820. x_save_state_dict['CurrentProgramIndex'] = self.edit_dialog.cb_programs.currentIndex()
  1821. x_save_state_dict['CurrentProgramName'] = self.edit_dialog.cb_programs.currentText()
  1822. # ----------------------------
  1823. # Current MIDI Program
  1824. if (self.edit_dialog.cb_midi_programs.currentIndex() >= 0):
  1825. midi_program_info = CarlaHost.get_midi_program_info(self.plugin_id, self.edit_dialog.cb_midi_programs.currentIndex())
  1826. x_save_state_dict['CurrentMidiBank'] = midi_program_info['bank']
  1827. x_save_state_dict['CurrentMidiProgram'] = midi_program_info['program']
  1828. # ----------------------------
  1829. # Parameters
  1830. parameter_count = CarlaHost.get_parameter_count(self.plugin_id)
  1831. for i in range(parameter_count):
  1832. parameter_info = CarlaHost.get_parameter_info(self.plugin_id, i)
  1833. parameter_data = CarlaHost.get_parameter_data(self.plugin_id, i)
  1834. if (not parameter_info['valid'] or parameter_data['type'] != PARAMETER_INPUT):
  1835. continue
  1836. x_save_state_parameter = deepcopy(save_state_parameter)
  1837. x_save_state_parameter['index'] = parameter_data['index']
  1838. x_save_state_parameter['rindex'] = parameter_data['rindex']
  1839. x_save_state_parameter['name'] = toString(parameter_info['name'])
  1840. x_save_state_parameter['symbol'] = toString(parameter_info['symbol'])
  1841. x_save_state_parameter['value'] = CarlaHost.get_current_parameter_value(self.plugin_id, parameter_data['index'])
  1842. x_save_state_parameter['midi_channel'] = parameter_data['midi_channel']+1
  1843. x_save_state_parameter['midi_cc'] = parameter_data['midi_cc']
  1844. if (parameter_data['hints'] & PARAMETER_USES_SAMPLERATE):
  1845. x_save_state_parameter['value'] /= CarlaHost.get_sample_rate()
  1846. x_save_state_dict['Parameters'].append(x_save_state_parameter)
  1847. # ----------------------------
  1848. # Custom Data
  1849. custom_data_count = CarlaHost.get_custom_data_count(self.plugin_id)
  1850. for i in range(custom_data_count):
  1851. custom_data = CarlaHost.get_custom_data(self.plugin_id, i)
  1852. if (custom_data['type'] == CUSTOM_DATA_INVALID):
  1853. continue
  1854. x_save_state_custom_data = deepcopy(save_state_custom_data)
  1855. x_save_state_custom_data['type'] = CustomDataType2String(custom_data['type'])
  1856. x_save_state_custom_data['key'] = toString(custom_data['key'])
  1857. x_save_state_custom_data['value'] = toString(custom_data['value'])
  1858. x_save_state_dict['CustomData'].append(x_save_state_custom_data)
  1859. # ----------------------------
  1860. # Chunk
  1861. if (self.pinfo['hints'] & PLUGIN_USES_CHUNKS):
  1862. x_save_state_dict['Chunk'] = toString(CarlaHost.get_chunk_data(self.plugin_id))
  1863. # ----------------------------
  1864. # Generate XML for this plugin
  1865. # TODO - convert to xml safe strings where needed
  1866. content = ""
  1867. content += " <Info>\n"
  1868. content += " <Type>%s</Type>\n" % (x_save_state_dict['Type'])
  1869. content += " <Name>%s</Name>\n" % (x_save_state_dict['Name'])
  1870. content += " <Label>%s</Label>\n" % (x_save_state_dict['Label'])
  1871. content += " <Binary>%s</Binary>\n" % (x_save_state_dict['Binary'])
  1872. content += " <UniqueID>%li</UniqueID>\n" % (x_save_state_dict['UniqueID'])
  1873. content += " </Info>\n"
  1874. content += "\n"
  1875. content += " <Data>\n"
  1876. content += " <Active>%s</Active>\n" % ("Yes" if x_save_state_dict['Active'] else "No")
  1877. content += " <DryWet>%f</DryWet>\n" % (x_save_state_dict['DryWet'])
  1878. content += " <Volume>%f</Volume>\n" % (x_save_state_dict['Volume'])
  1879. content += " <Balance-Left>%f</Balance-Left>\n" % (x_save_state_dict['Balance-Left'])
  1880. content += " <Balance-Right>%f</Balance-Right>\n" % (x_save_state_dict['Balance-Right'])
  1881. for parameter in x_save_state_dict['Parameters']:
  1882. content += "\n"
  1883. content += " <Parameter>\n"
  1884. content += " <index>%i</index>\n" % (parameter['index'])
  1885. content += " <rindex>%i</rindex>\n" % (parameter['rindex'])
  1886. content += " <name>%s</name>\n" % (parameter['name'])
  1887. if (parameter['symbol']):
  1888. content += " <symbol>%s</symbol>\n" % (parameter['symbol'])
  1889. content += " <value>%f</value>\n" % (parameter['value'])
  1890. if (parameter['midi_cc'] > 0):
  1891. content += " <midi_channel>%i</midi_channel>\n" % (parameter['midi_channel'])
  1892. content += " <midi_cc>%i</midi_cc>\n" % (parameter['midi_cc'])
  1893. content += " </Parameter>\n"
  1894. if (x_save_state_dict['CurrentProgramIndex'] >= 0):
  1895. content += "\n"
  1896. content += " <CurrentProgramIndex>%i</CurrentProgramIndex>\n" % (x_save_state_dict['CurrentProgramIndex'])
  1897. content += " <CurrentProgramName>%s</CurrentProgramName>\n" % (x_save_state_dict['CurrentProgramName'])
  1898. if (x_save_state_dict['CurrentMidiBank'] >= 0 and x_save_state_dict['CurrentMidiProgram'] >= 0):
  1899. content += "\n"
  1900. content += " <CurrentMidiBank>%i</CurrentMidiBank>\n" % (x_save_state_dict['CurrentMidiBank'])
  1901. content += " <CurrentMidiProgram>%i</CurrentMidiProgram>\n" % (x_save_state_dict['CurrentMidiProgram'])
  1902. for custom_data in x_save_state_dict['CustomData']:
  1903. content += "\n"
  1904. content += " <CustomData>\n"
  1905. content += " <type>%s</type>\n" % (custom_data['type'])
  1906. content += " <key>%s</key>\n" % (custom_data['key'])
  1907. content += " <value>%s</value>\n" % (custom_data['value'])
  1908. content += " </CustomData>\n"
  1909. if (x_save_state_dict['Chunk']):
  1910. content += "\n"
  1911. content += " <Chunk>\n"
  1912. content += "%s" % (x_save_state_dict['Chunk'])
  1913. content += " </Chunk>\n"
  1914. content += " </Data>\n"
  1915. return content
  1916. def loadStateDict(self, content):
  1917. # Part 1 - set custom data
  1918. for custom_data in content['CustomData']:
  1919. CarlaHost.set_custom_data(self.plugin_id, custom_data['type'], custom_data['key'], custom_data['value'])
  1920. ## Part 2 - set program (carefully)
  1921. #program_id = -1
  1922. #program_count = CarlaHost.get_program_count(self.plugin_id)
  1923. #if (content['ProgramName']):
  1924. #test_pname = CarlaHost.get_program_name(self.plugin_id, content['ProgramIndex'])
  1925. #if (content['ProgramName'] == test_pname):
  1926. #program_id = content['ProgramIndex']
  1927. #else:
  1928. #for i in range(program_count):
  1929. #new_test_pname = CarlaHost.get_program_name(self.plugin_id, i)
  1930. #if (content['ProgramName'] == new_test_pname):
  1931. #program_id = i
  1932. #break
  1933. #else:
  1934. #if (content['ProgramIndex'] < program_count):
  1935. #program_id = content['ProgramIndex']
  1936. #else:
  1937. #if (content['ProgramIndex'] < program_count):
  1938. #program_id = content['ProgramIndex']
  1939. #if (program_id >= 0):
  1940. #CarlaHost.set_program(self.plugin_id, program_id)
  1941. #self.edit_dialog.set_program(program_id)
  1942. # Part 3 - set midi program
  1943. if (content['CurrentMidiBank'] >= 0 and content['CurrentMidiProgram'] >= 0):
  1944. midi_program_count = CarlaHost.get_midi_program_count(self.plugin_id)
  1945. for i in range(midi_program_count):
  1946. program_info = CarlaHost.get_midi_program_info(self.plugin_id, i)
  1947. if (program_info['bank'] == content['CurrentMidiBank'] and program_info['program'] == content['CurrentMidiProgram']):
  1948. CarlaHost.set_midi_program(self.plugin_id, i)
  1949. self.edit_dialog.set_midi_program(i)
  1950. break
  1951. # Part 4a - get plugin parameter symbols
  1952. param_symbols = [] # (index, symbol)
  1953. for parameter in content['Parameters']:
  1954. if (parameter['symbol']):
  1955. param_info = CarlaHost.get_parameter_info(self.plugin_id, parameter['index'])
  1956. if (param_info['valid'] and param_info['symbol']):
  1957. param_symbols.append((parameter['index'], param_info['symbol']))
  1958. # Part 4b - set parameter values (carefully)
  1959. for parameter in content['Parameters']:
  1960. index = -1
  1961. if (content['Type'] == "LADSPA"):
  1962. # Try to set by symbol, otherwise use index
  1963. if (parameter['symbol']):
  1964. for param_symbol in param_symbols:
  1965. if (param_symbol[1] == parameter['symbol']):
  1966. index = param_symbol[0]
  1967. break
  1968. else:
  1969. index = parameter['index']
  1970. else:
  1971. index = parameter['index']
  1972. elif (content['Type'] == "LV2"):
  1973. # Symbol only
  1974. if (parameter['symbol']):
  1975. for param_symbol in param_symbols:
  1976. if (param_symbol[1] == parameter['symbol']):
  1977. index = param_symbol[0]
  1978. break
  1979. else:
  1980. print("Failed to find LV2 parameter symbol for %i -> %s" % (parameter['index'], parameter['name']))
  1981. else:
  1982. print("LV2 Plugin parameter #%i, '%s', has no symbol" % (parameter['index'], parameter['name']))
  1983. else:
  1984. # Index only
  1985. index = parameter['index']
  1986. # Now set parameter
  1987. if (index >= 0):
  1988. param_data = CarlaHost.get_parameter_data(self.plugin_id, parameter['index'])
  1989. if (param_data['hints'] & PARAMETER_USES_SAMPLERATE):
  1990. parameter['value'] *= CarlaHost.get_sample_rate()
  1991. CarlaHost.set_parameter_value(self.plugin_id, index, parameter['value'])
  1992. CarlaHost.set_parameter_midi_channel(self.plugin_id, index, parameter['midi_channel']-1)
  1993. CarlaHost.set_parameter_midi_cc(self.plugin_id, index, parameter['midi_cc'])
  1994. else:
  1995. print("Could not set parameter data for %i -> %s" % (parameter['index'], parameter['name']))
  1996. # Part 5 - set chunk data
  1997. if (content['Chunk']):
  1998. CarlaHost.set_chunk_data(self.plugin_id, content['Chunk'])
  1999. # Part 6 - set internal stuff
  2000. self.set_drywet(content['DryWet']*1000, True, True)
  2001. self.set_volume(content['Volume']*1000, True, True)
  2002. self.set_balance_left(content['Balance-Left']*1000, True, True)
  2003. self.set_balance_right(content['Balance-Right']*1000, True, True)
  2004. self.edit_dialog.do_reload_all()
  2005. self.set_active(content['Active'], True, True)
  2006. def check_gui_stuff(self):
  2007. # Input peaks
  2008. if (self.peaks_in > 0):
  2009. if (self.peaks_in > 1):
  2010. peak1 = CarlaHost.get_input_peak_value(self.plugin_id, 1)
  2011. peak2 = CarlaHost.get_input_peak_value(self.plugin_id, 2)
  2012. led_ain_state = bool(peak1 != 0.0 or peak2 != 0.0)
  2013. self.peak_in.displayMeter(1, peak1)
  2014. self.peak_in.displayMeter(2, peak2)
  2015. else:
  2016. peak = CarlaHost.get_input_peak_value(self.plugin_id, 1)
  2017. led_ain_state = bool(peak != 0.0)
  2018. self.peak_in.displayMeter(1, peak)
  2019. if (led_ain_state != self.last_led_ain_state):
  2020. self.led_audio_in.setChecked(led_ain_state)
  2021. self.last_led_ain_state = led_ain_state
  2022. # Output peaks
  2023. if (self.peaks_out > 0):
  2024. if (self.peaks_out > 1):
  2025. peak1 = CarlaHost.get_output_peak_value(self.plugin_id, 1)
  2026. peak2 = CarlaHost.get_output_peak_value(self.plugin_id, 2)
  2027. led_aout_state = bool(peak1 != 0.0 or peak2 != 0.0)
  2028. self.peak_out.displayMeter(1, peak1)
  2029. self.peak_out.displayMeter(2, peak2)
  2030. else:
  2031. peak = CarlaHost.get_output_peak_value(self.plugin_id, 1)
  2032. led_aout_state = bool(peak != 0.0)
  2033. self.peak_out.displayMeter(1, peak)
  2034. if (led_aout_state != self.last_led_aout_state):
  2035. self.led_audio_out.setChecked(led_aout_state)
  2036. self.last_led_aout_state = led_aout_state
  2037. def check_gui_stuff2(self):
  2038. # Parameter Activity LED
  2039. if (self.parameter_activity_timer == ICON_STATE_ON):
  2040. self.led_control.setChecked(True)
  2041. self.parameter_activity_timer = ICON_STATE_WAIT
  2042. elif (self.parameter_activity_timer == ICON_STATE_WAIT):
  2043. self.parameter_activity_timer = ICON_STATE_OFF
  2044. elif (self.parameter_activity_timer == ICON_STATE_OFF):
  2045. self.led_control.setChecked(False)
  2046. self.parameter_activity_timer = None
  2047. # Update edit dialog
  2048. self.edit_dialog.check_gui_stuff()
  2049. @pyqtSlot(bool)
  2050. def slot_setActive(self, yesno):
  2051. self.set_active(yesno, False, True)
  2052. @pyqtSlot(int)
  2053. def slot_setDryWet(self, value):
  2054. self.set_drywet(value, False, True)
  2055. @pyqtSlot(int)
  2056. def slot_setVolume(self, value):
  2057. self.set_volume(value, False, True)
  2058. @pyqtSlot(int)
  2059. def slot_setBalanceLeft(self, value):
  2060. self.set_balance_left(value, False, True)
  2061. @pyqtSlot(int)
  2062. def slot_setBalanceRight(self, value):
  2063. self.set_balance_right(value, False, True)
  2064. @pyqtSlot(bool)
  2065. def slot_guiClicked(self, show):
  2066. print("slot_guiClicked", show)
  2067. if (self.gui_dialog_type in (GUI_INTERNAL_QT4, GUI_INTERNAL_X11)):
  2068. if (show):
  2069. if (self.gui_dialog_geometry):
  2070. self.gui_dialog.restoreGeometry(self.gui_dialog_geometry)
  2071. else:
  2072. self.gui_dialog_geometry = self.gui_dialog.saveGeometry()
  2073. self.gui_dialog.setVisible(show)
  2074. CarlaHost.show_gui(self.plugin_id, show)
  2075. @pyqtSlot()
  2076. def slot_guiClosed(self):
  2077. self.b_gui.setChecked(False)
  2078. @pyqtSlot(bool)
  2079. def slot_editClicked(self, show):
  2080. print("slot_editClicked", show)
  2081. if (show):
  2082. if (self.edit_dialog_geometry):
  2083. self.edit_dialog.restoreGeometry(self.edit_dialog_geometry)
  2084. else:
  2085. self.edit_dialog_geometry = self.edit_dialog.saveGeometry()
  2086. self.edit_dialog.setVisible(show)
  2087. @pyqtSlot()
  2088. def slot_editClosed(self):
  2089. self.b_edit.setChecked(False)
  2090. @pyqtSlot()
  2091. def slot_removeClicked(self):
  2092. gui.remove_plugin(self.plugin_id, True)
  2093. @pyqtSlot()
  2094. def slot_showCustomDialMenu(self):
  2095. dial_name = self.sender().objectName()
  2096. if (dial_name == "dial_drywet"):
  2097. minimum = 0
  2098. maximum = 100
  2099. default = 100
  2100. label = "Dry/Wet"
  2101. elif (dial_name == "dial_vol"):
  2102. minimum = 0
  2103. maximum = 127
  2104. default = 100
  2105. label = "Volume"
  2106. elif (dial_name == "dial_b_left"):
  2107. minimum = -100
  2108. maximum = 100
  2109. default = -100
  2110. label = "Balance-Left"
  2111. elif (dial_name == "dial_b_right"):
  2112. minimum = -100
  2113. maximum = 100
  2114. default = 100
  2115. label = "Balance-Right"
  2116. else:
  2117. minimum = 0
  2118. maximum = 100
  2119. default = 100
  2120. label = "Unknown"
  2121. current = self.sender().value()/10
  2122. menu = QMenu(self)
  2123. act_x_reset = menu.addAction(self.tr("Reset (%i%%)" % (default)))
  2124. menu.addSeparator()
  2125. act_x_min = menu.addAction(self.tr("Set to Minimum (%i%%)" % (minimum)))
  2126. act_x_cen = menu.addAction(self.tr("Set to Center"))
  2127. act_x_max = menu.addAction(self.tr("Set to Maximum (%i%%)" % (maximum)))
  2128. menu.addSeparator()
  2129. act_x_set = menu.addAction(self.tr("Set value..."))
  2130. if (label not in ("Balance-Left", "Balance-Right")):
  2131. menu.removeAction(act_x_cen)
  2132. act_x_sel = menu.exec_(QCursor.pos())
  2133. if (act_x_sel == act_x_set):
  2134. value_try = QInputDialog.getInteger(self, self.tr("Set value"), label, current, minimum, maximum, 1)
  2135. if (value_try[1]):
  2136. value = value_try[0]*10
  2137. else:
  2138. value = None
  2139. elif (act_x_sel == act_x_min):
  2140. value = minimum*10
  2141. elif (act_x_sel == act_x_max):
  2142. value = maximum*10
  2143. elif (act_x_sel == act_x_reset):
  2144. value = default*10
  2145. elif (act_x_sel == act_x_cen):
  2146. value = 0
  2147. else:
  2148. value = None
  2149. if (value != None):
  2150. if (label == "Dry/Wet"):
  2151. self.set_drywet(value, True, True)
  2152. elif (label == "Volume"):
  2153. self.set_volume(value, True, True)
  2154. elif (label == "Balance-Left"):
  2155. self.set_balance_left(value, True, True)
  2156. elif (label == "Balance-Right"):
  2157. self.set_balance_right(value, True, True)
  2158. def paintEvent(self, event):
  2159. painter = QPainter(self)
  2160. painter.setPen(self.color_1)
  2161. painter.drawLine(0, 3, self.width(), 3)
  2162. painter.drawLine(0, self.height()-4, self.width(), self.height()-4)
  2163. painter.setPen(self.color_2)
  2164. painter.drawLine(0, 2, self.width(), 2)
  2165. painter.drawLine(0, self.height()-3, self.width(), self.height()-3)
  2166. painter.setPen(self.color_3)
  2167. painter.drawLine(0, 1, self.width(), 1)
  2168. painter.drawLine(0, self.height()-2, self.width(), self.height()-2)
  2169. painter.setPen(self.color_4)
  2170. painter.drawLine(0, 0, self.width(), 0)
  2171. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  2172. QFrame.paintEvent(self, event)
  2173. # Main Window
  2174. class CarlaMainW(QMainWindow, ui_carla.Ui_CarlaMainW):
  2175. def __init__(self, parent=None):
  2176. QMainWindow.__init__(self, parent)
  2177. self.setupUi(self)
  2178. # -------------------------------------------------------------
  2179. # Load Settings
  2180. self.settings = QSettings("Cadence", "Carla")
  2181. self.settings_db = QSettings("Cadence", "Carla-Database")
  2182. self.loadSettings(True)
  2183. self.loadRDFs()
  2184. self.setStyleSheet("""
  2185. QWidget#centralwidget {
  2186. background-color: qlineargradient(spread:pad,
  2187. x1:0.0, y1:0.0,
  2188. x2:0.2, y2:1.0,
  2189. stop:0 rgb( 7, 7, 7),
  2190. stop:1 rgb(28, 28, 28)
  2191. );
  2192. }
  2193. """)
  2194. # -------------------------------------------------------------
  2195. # Internal stuff
  2196. self.m_plugin_list = []
  2197. for x in range(MAX_PLUGINS):
  2198. self.m_plugin_list.append(None)
  2199. self.m_project_filename = None
  2200. CarlaHost.set_callback_function(self.callback_function)
  2201. # -------------------------------------------------------------
  2202. # Set-up GUI stuff
  2203. self.act_plugin_remove_all.setEnabled(False)
  2204. self.resize(self.width(), 0)
  2205. # -------------------------------------------------------------
  2206. # Connect actions to functions
  2207. self.connect(self.act_file_new, SIGNAL("triggered()"), SLOT("slot_file_new()"))
  2208. self.connect(self.act_file_open, SIGNAL("triggered()"), SLOT("slot_file_open()"))
  2209. self.connect(self.act_file_save, SIGNAL("triggered()"), SLOT("slot_file_save()"))
  2210. self.connect(self.act_file_save_as, SIGNAL("triggered()"), SLOT("slot_file_save_as()"))
  2211. self.connect(self.act_plugin_add, SIGNAL("triggered()"), SLOT("slot_plugin_add()"))
  2212. self.connect(self.act_plugin_remove_all, SIGNAL("triggered()"), SLOT("slot_remove_all()"))
  2213. self.connect(self.act_settings_configure, SIGNAL("triggered()"), SLOT("slot_configureCarla()"))
  2214. self.connect(self.act_help_about, SIGNAL("triggered()"), SLOT("slot_aboutCarla()"))
  2215. self.connect(self.act_help_about_qt, SIGNAL("triggered()"), app, SLOT("aboutQt()"))
  2216. self.connect(self, SIGNAL("SIGUSR1()"), SLOT("slot_handleSIGUSR1()"))
  2217. self.connect(self, SIGNAL("DebugCallback(int, int, int, double)"), SLOT("slot_handleDebugCallback(int, int, int, double)"))
  2218. self.connect(self, SIGNAL("ParameterCallback(int, int, double)"), SLOT("slot_handleParameterCallback(int, int, double)"))
  2219. self.connect(self, SIGNAL("ProgramCallback(int, int)"), SLOT("slot_handleProgramCallback(int, int)"))
  2220. self.connect(self, SIGNAL("MidiProgramCallback(int, int)"), SLOT("slot_handleMidiProgramCallback(int, int)"))
  2221. self.connect(self, SIGNAL("NoteOnCallback(int, int, int)"), SLOT("slot_handleNoteOnCallback(int, int)"))
  2222. self.connect(self, SIGNAL("NoteOffCallback(int, int)"), SLOT("slot_handleNoteOffCallback(int, int)"))
  2223. self.connect(self, SIGNAL("ShowGuiCallback(int, int)"), SLOT("slot_handleShowGuiCallback(int, int)"))
  2224. self.connect(self, SIGNAL("ResizeGuiCallback(int, int, int)"), SLOT("slot_handleResizeGuiCallback(int, int, int)"))
  2225. self.connect(self, SIGNAL("UpdateCallback(int)"), SLOT("slot_handleUpdateCallback(int)"))
  2226. self.connect(self, SIGNAL("ReloadInfoCallback(int)"), SLOT("slot_handleReloadInfoCallback(int)"))
  2227. self.connect(self, SIGNAL("ReloadParametersCallback(int)"), SLOT("slot_handleReloadParametersCallback(int)"))
  2228. self.connect(self, SIGNAL("ReloadProgramsCallback(int)"), SLOT("slot_handleReloadProgramsCallback(int)"))
  2229. self.connect(self, SIGNAL("ReloadAllCallback(int)"), SLOT("slot_handleReloadAllCallback(int)"))
  2230. self.connect(self, SIGNAL("QuitCallback()"), SLOT("slot_handleQuitCallback()"))
  2231. self.TIMER_GUI_STUFF = self.startTimer(self.m_savedSettings["Main/RefreshInterval"]) # Peaks
  2232. self.TIMER_GUI_STUFF2 = self.startTimer(self.m_savedSettings["Main/RefreshInterval"]*2) # LEDs and edit dialog
  2233. def callback_function(self, action, plugin_id, value1, value2, value3):
  2234. if (plugin_id < 0 or plugin_id >= MAX_PLUGINS):
  2235. return
  2236. if (action == CALLBACK_DEBUG):
  2237. self.emit(SIGNAL("DebugCallback(int, int, int, double)"), plugin_id, value1, value2, value3)
  2238. elif (action == CALLBACK_PARAMETER_CHANGED):
  2239. self.emit(SIGNAL("ParameterCallback(int, int, double)"), plugin_id, value1, value3)
  2240. elif (action == CALLBACK_PROGRAM_CHANGED):
  2241. self.emit(SIGNAL("ProgramCallback(int, int)"), plugin_id, value1)
  2242. elif (action == CALLBACK_MIDI_PROGRAM_CHANGED):
  2243. self.emit(SIGNAL("MidiProgramCallback(int, int)"), plugin_id, value1)
  2244. elif (action == CALLBACK_NOTE_ON):
  2245. self.emit(SIGNAL("NoteOnCallback(int, int, int)"), plugin_id, value1, value2)
  2246. elif (action == CALLBACK_NOTE_OFF):
  2247. self.emit(SIGNAL("NoteOffCallback(int, int)"), plugin_id, value1)
  2248. elif (action == CALLBACK_SHOW_GUI):
  2249. self.emit(SIGNAL("ShowGuiCallback(int, int)"), plugin_id, value1)
  2250. elif (action == CALLBACK_RESIZE_GUI):
  2251. self.emit(SIGNAL("ResizeGuiCallback(int, int, int)"), plugin_id, value1, value2)
  2252. elif (action == CALLBACK_UPDATE):
  2253. self.emit(SIGNAL("UpdateCallback(int)"), plugin_id)
  2254. elif (action == CALLBACK_RELOAD_INFO):
  2255. self.emit(SIGNAL("ReloadInfoCallback(int)"), plugin_id)
  2256. elif (action == CALLBACK_RELOAD_PARAMETERS):
  2257. self.emit(SIGNAL("ReloadParametersCallback(int)"), plugin_id)
  2258. elif (action == CALLBACK_RELOAD_PROGRAMS):
  2259. self.emit(SIGNAL("ReloadProgramsCallback(int)"), plugin_id)
  2260. elif (action == CALLBACK_RELOAD_ALL):
  2261. self.emit(SIGNAL("ReloadAllCallback(int)"), plugin_id)
  2262. elif (action == CALLBACK_QUIT):
  2263. self.emit(SIGNAL("QuitCallback()"))
  2264. @pyqtSlot()
  2265. def slot_handleSIGUSR1(self):
  2266. print("Got SIGUSR1 -> Saving project now")
  2267. QTimer.singleShot(0, self, SLOT("slot_file_save()"))
  2268. @pyqtSlot(int, int, int, float)
  2269. def slot_handleDebugCallback(self, plugin_id, value1, value2, value3):
  2270. print("DEBUG :: %i, %i, %i, %f)" % (plugin_id, value1, value2, value3))
  2271. @pyqtSlot(int, int, float)
  2272. def slot_handleParameterCallback(self, plugin_id, parameter_id, value):
  2273. pwidget = self.m_plugin_list[plugin_id]
  2274. if (pwidget):
  2275. pwidget.parameter_activity_timer = ICON_STATE_ON
  2276. if (parameter_id == PARAMETER_ACTIVE):
  2277. pwidget.set_active((value > 0.0), True, False)
  2278. elif (parameter_id == PARAMETER_DRYWET):
  2279. pwidget.set_drywet(value*1000, True, False)
  2280. elif (parameter_id == PARAMETER_VOLUME):
  2281. pwidget.set_volume(value*1000, True, False)
  2282. elif (parameter_id == PARAMETER_BALANCE_LEFT):
  2283. pwidget.set_balance_left(value*1000, True, False)
  2284. elif (parameter_id == PARAMETER_BALANCE_RIGHT):
  2285. pwidget.set_balance_right(value*1000, True, False)
  2286. elif (parameter_id >= 0):
  2287. pwidget.edit_dialog.set_parameter_to_update(parameter_id)
  2288. @pyqtSlot(int, int)
  2289. def slot_handleProgramCallback(self, plugin_id, program_id):
  2290. pwidget = self.m_plugin_list[plugin_id]
  2291. if (pwidget):
  2292. pwidget.edit_dialog.set_program(program_id)
  2293. @pyqtSlot(int, int)
  2294. def slot_handleMidiProgramCallback(self, plugin_id, midi_program_id):
  2295. pwidget = self.m_plugin_list[plugin_id]
  2296. if (pwidget):
  2297. pwidget.edit_dialog.set_midi_program(midi_program_id)
  2298. @pyqtSlot(int, int)
  2299. def slot_handleNoteOnCallback(self, plugin_id, note):
  2300. pwidget = self.m_plugin_list[plugin_id]
  2301. if (pwidget):
  2302. pwidget.edit_dialog.keyboard.noteOn(note, False)
  2303. @pyqtSlot(int, int)
  2304. def slot_handleNoteOffCallback(self, plugin_id, note):
  2305. pwidget = self.m_plugin_list[plugin_id]
  2306. if (pwidget):
  2307. pwidget.edit_dialog.keyboard.noteOff(note, False)
  2308. @pyqtSlot(int, int)
  2309. def slot_handleShowGuiCallback(self, plugin_id, show):
  2310. pwidget = self.m_plugin_list[plugin_id]
  2311. if (pwidget):
  2312. if (show == 0):
  2313. pwidget.b_gui.setChecked(False)
  2314. pwidget.b_gui.setEnabled(True)
  2315. elif (show == 1):
  2316. pwidget.b_gui.setChecked(True)
  2317. pwidget.b_gui.setEnabled(True)
  2318. elif (show == -1):
  2319. pwidget.b_gui.setChecked(False)
  2320. pwidget.b_gui.setEnabled(False)
  2321. @pyqtSlot(int, int, int)
  2322. def slot_handleResizeGuiCallback(self, plugin_id, width, height):
  2323. pwidget = self.m_plugin_list[plugin_id]
  2324. if (pwidget):
  2325. gui_dialog = pwidget.gui_dialog
  2326. if (gui_dialog):
  2327. gui_dialog.set_new_size(width, height)
  2328. @pyqtSlot(int)
  2329. def slot_handleUpdateCallback(self, plugin_id):
  2330. pwidget = self.m_plugin_list[plugin_id]
  2331. if (pwidget):
  2332. pwidget.edit_dialog.do_update()
  2333. @pyqtSlot(int)
  2334. def slot_handleReloadInfoCallback(self, plugin_id):
  2335. pwidget = self.m_plugin_list[plugin_id]
  2336. if (pwidget):
  2337. pwidget.edit_dialog.do_reload_info()
  2338. @pyqtSlot(int)
  2339. def slot_handleReloadParametersCallback(self, plugin_id):
  2340. pwidget = self.m_plugin_list[plugin_id]
  2341. if (pwidget):
  2342. pwidget.edit_dialog.do_reload_parameters()
  2343. @pyqtSlot(int)
  2344. def slot_handleReloadProgramsCallback(self, plugin_id):
  2345. pwidget = self.m_plugin_list[plugin_id]
  2346. if (pwidget):
  2347. pwidget.edit_dialog.do_reload_programs()
  2348. @pyqtSlot(int)
  2349. def slot_handleReloadAllCallback(self, plugin_id):
  2350. pwidget = self.m_plugin_list[plugin_id]
  2351. if (pwidget):
  2352. pwidget.edit_dialog.do_reload_all()
  2353. @pyqtSlot()
  2354. def slot_handleQuitCallback(self):
  2355. CustomMessageBox(self, QMessageBox.Warning, self.tr("Warning"), self.tr("JACK has been stopped or crashed.\nPlease start JACK and restart Carla"),
  2356. "You may want to save your session now...", QMessageBox.Ok, QMessageBox.Ok)
  2357. def add_plugin(self, btype, ptype, filename, label, extra_stuff, activate):
  2358. new_plugin_id = CarlaHost.add_plugin(btype, ptype, filename, label, extra_stuff)
  2359. if (new_plugin_id < 0):
  2360. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"),
  2361. toString(CarlaHost.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  2362. else:
  2363. pwidget = PluginWidget(self, new_plugin_id)
  2364. self.w_plugins.layout().addWidget(pwidget)
  2365. self.m_plugin_list[new_plugin_id] = pwidget
  2366. self.act_plugin_remove_all.setEnabled(True)
  2367. pwidget.peak_in.setRefreshRate(self.m_savedSettings["Main/RefreshInterval"])
  2368. pwidget.peak_out.setRefreshRate(self.m_savedSettings["Main/RefreshInterval"])
  2369. if (activate):
  2370. pwidget.set_active(True, True, True)
  2371. return new_plugin_id
  2372. def remove_plugin(self, plugin_id, showError):
  2373. pwidget = self.m_plugin_list[plugin_id]
  2374. pwidget.edit_dialog.close()
  2375. if (pwidget.gui_dialog):
  2376. pwidget.gui_dialog.close()
  2377. if (CarlaHost.remove_plugin(plugin_id)):
  2378. pwidget.close()
  2379. pwidget.deleteLater()
  2380. self.w_plugins.layout().removeWidget(pwidget)
  2381. self.m_plugin_list[plugin_id] = None
  2382. else:
  2383. if (showError):
  2384. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to remove plugin"),
  2385. toString(CarlaHost.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  2386. for i in range(MAX_PLUGINS):
  2387. if (self.m_plugin_list[i] != None):
  2388. self.act_plugin_remove_all.setEnabled(True)
  2389. break
  2390. else:
  2391. self.act_plugin_remove_all.setEnabled(False)
  2392. def get_extra_stuff(self, plugin):
  2393. ptype = plugin['type']
  2394. if (ptype == PLUGIN_LADSPA):
  2395. unique_id = plugin['unique_id']
  2396. for rdf_item in self.ladspa_rdf_list:
  2397. if (rdf_item.UniqueID == unique_id):
  2398. return pointer(rdf_item)
  2399. else:
  2400. return c_nullptr
  2401. elif (ptype == PLUGIN_DSSI):
  2402. if (plugin['hints'] & PLUGIN_HAS_GUI):
  2403. gui = findDSSIGUI(plugin['binary'], plugin['name'], plugin['label'])
  2404. if (gui):
  2405. return gui.encode("utf-8")
  2406. return c_nullptr
  2407. elif (ptype == PLUGIN_LV2):
  2408. p_uri = plugin['label'].encode("utf-8")
  2409. print("TEST", p_uri)
  2410. for rdf_item in self.lv2_rdf_list:
  2411. print(rdf_item.URI, p_uri)
  2412. if (rdf_item.URI == p_uri):
  2413. return pointer(rdf_item)
  2414. else:
  2415. return c_nullptr
  2416. #elif (ptype == PLUGIN_WINVST):
  2417. ## Store object so we can return a pointer
  2418. #if (self.winvst_info == None):
  2419. #self.winvst_info = WinVstBaseInfo()
  2420. #self.winvst_info.category = plugin['category']
  2421. #self.winvst_info.hints = plugin['hints']
  2422. #self.winvst_info.name = plugin['name']
  2423. #self.winvst_info.maker = plugin['maker']
  2424. #self.winvst_info.unique_id = long(plugin['id'])
  2425. #self.winvst_info.ains = plugin['audio.ins']
  2426. #self.winvst_info.aouts = plugin['audio.outs']
  2427. #return pointer(self.winvst_info)
  2428. else:
  2429. return c_nullptr
  2430. def save_project(self):
  2431. content = ("<?xml version='1.0' encoding='UTF-8'?>\n"
  2432. "<!DOCTYPE CARLA-PROJECT>\n"
  2433. "<CARLA-PROJECT VERSION='%s'>\n") % (VERSION)
  2434. first_plugin = True
  2435. for pwidget in self.m_plugin_list:
  2436. if (pwidget):
  2437. if (not first_plugin):
  2438. content += "\n"
  2439. content += " <Plugin>\n"
  2440. content += pwidget.getSaveXMLContent()
  2441. content += " </Plugin>\n"
  2442. first_plugin = False
  2443. content += "</CARLA-PROJECT>\n"
  2444. try:
  2445. open(self.m_project_filename, "w").write(content)
  2446. except:
  2447. QMessageBox.critical(self, self.tr("Error"), self.tr("Failed to save project file"))
  2448. def load_project(self):
  2449. try:
  2450. project_read = open(self.m_project_filename, "r").read()
  2451. except:
  2452. project_read = None
  2453. if not project_read:
  2454. QMessageBox.critical(self, self.tr("Error"), self.tr("Failed to load project file"))
  2455. return
  2456. xml = QDomDocument()
  2457. xml.setContent(project_read)
  2458. xml_node = xml.documentElement()
  2459. if (xml_node.tagName() != "CARLA-PROJECT"):
  2460. QMessageBox.critical(self, self.tr("Error"), self.tr("Not a valid Carla project file"))
  2461. return
  2462. x_ladspa_plugins = None
  2463. x_dssi_plugins = None
  2464. x_lv2_plugins = None
  2465. x_vst_plugins = None
  2466. x_sf2_plugins = None
  2467. x_failed_plugins = []
  2468. x_save_state_dicts = []
  2469. node = xml_node.firstChild()
  2470. while not node.isNull():
  2471. if (node.toElement().tagName() == "Plugin"):
  2472. x_save_state_dict = getStateDictFromXML(node)
  2473. x_save_state_dicts.append(x_save_state_dict)
  2474. node = node.nextSibling()
  2475. for x_save_state_dict in x_save_state_dicts:
  2476. ptype = x_save_state_dict['Type']
  2477. label = x_save_state_dict['Label']
  2478. binary = x_save_state_dict['Binary']
  2479. binaryS = getShortFileName(binary)
  2480. unique_id = x_save_state_dict['UniqueID']
  2481. if (ptype == "LADSPA"):
  2482. if (not x_ladspa_plugins): x_ladspa_plugins = toList(self.settings_db.value("Plugins/LADSPA", []))
  2483. x_plugins = x_ladspa_plugins
  2484. elif (ptype == "DSSI"):
  2485. if (not x_dssi_plugins): x_dssi_plugins = toList(self.settings_db.value("Plugins/DSSI", []))
  2486. x_plugins = x_dssi_plugins
  2487. elif (ptype == "LV2"):
  2488. if (not x_lv2_plugins): x_lv2_plugins = toList(self.settings_db.value("Plugins/LV2", []))
  2489. x_plugins = x_lv2_plugins
  2490. elif (ptype == "VST"):
  2491. if (not x_vst_plugins): x_vst_plugins = toList(self.settings_db.value("Plugins/VST", []))
  2492. x_plugins = x_vst_plugins
  2493. elif (ptype == "SoundFont"):
  2494. if (not x_sf2_plugins): x_sf2_plugins = toList(self.settings_db.value("Plugins/SF2", []))
  2495. x_plugins = x_sf2_plugins
  2496. else:
  2497. x_failed_plugins.append(x_save_state_dict['Name'])
  2498. continue
  2499. # Try UniqueID -> Label -> Binary (full) -> Binary (short)
  2500. plugin_ulB = None
  2501. plugin_ulb = None
  2502. plugin_ul = None
  2503. plugin_uB = None
  2504. plugin_ub = None
  2505. plugin_lB = None
  2506. plugin_lb = None
  2507. plugin_u = None
  2508. plugin_l = None
  2509. plugin_B = None
  2510. for _plugins in x_plugins:
  2511. for x_plugin in _plugins:
  2512. if (unique_id == x_plugin['unique_id'] and label == x_plugin['label'] and binary == x_plugin['binary']):
  2513. plugin_ulB = x_plugin
  2514. break
  2515. elif (unique_id == x_plugin['unique_id'] and label == x_plugin['label'] and binaryS == getShortFileName(x_plugin['binary'])):
  2516. plugin_ulb = x_plugin
  2517. elif (unique_id == x_plugin['unique_id'] and label == x_plugin['label']):
  2518. plugin_ul = x_plugin
  2519. elif (unique_id == x_plugin['unique_id'] and binary == x_plugin['binary']):
  2520. plugin_uB = x_plugin
  2521. elif (unique_id == x_plugin['unique_id'] and binaryS == getShortFileName(x_plugin['binary'])):
  2522. plugin_ub = x_plugin
  2523. elif (label == x_plugin['label'] and binary == x_plugin['binary']):
  2524. plugin_lB = x_plugin
  2525. elif (label == x_plugin['label'] and binaryS == getShortFileName(x_plugin['binary'])):
  2526. plugin_lb = x_plugin
  2527. elif (unique_id == x_plugin['unique_id']):
  2528. plugin_u = x_plugin
  2529. elif (label == x_plugin['label']):
  2530. plugin_l = x_plugin
  2531. elif (binary == x_plugin['binary']):
  2532. plugin_B = x_plugin
  2533. # LADSPA uses UniqueID or binary+label
  2534. if (ptype == "LADSPA"):
  2535. plugin_l = None
  2536. plugin_B = None
  2537. # DSSI uses binary+label (UniqueID ignored)
  2538. elif (ptype == "DSSI"):
  2539. plugin_ul = None
  2540. plugin_uB = None
  2541. plugin_ub = None
  2542. plugin_u = None
  2543. plugin_l = None
  2544. plugin_B = None
  2545. # LV2 uses URIs (label in this case)
  2546. elif (ptype == "LV2"):
  2547. plugin_uB = None
  2548. plugin_ub = None
  2549. plugin_u = None
  2550. plugin_B = None
  2551. # VST uses UniqueID
  2552. elif (ptype == "VST"):
  2553. plugin_lB = None
  2554. plugin_lb = None
  2555. plugin_l = None
  2556. plugin_B = None
  2557. # SoundFonts use binaries
  2558. elif (ptype == "SF2"):
  2559. plugin_ul = None
  2560. plugin_u = None
  2561. plugin_l = None
  2562. if (plugin_ulB):
  2563. plugin = plugin_ulB
  2564. elif (plugin_ulb):
  2565. plugin = plugin_ulb
  2566. elif (plugin_ul):
  2567. plugin = plugin_ul
  2568. elif (plugin_uB):
  2569. plugin = plugin_uB
  2570. elif (plugin_ub):
  2571. plugin = plugin_ub
  2572. elif (plugin_lB):
  2573. plugin = plugin_lB
  2574. elif (plugin_lb):
  2575. plugin = plugin_lb
  2576. elif (plugin_u):
  2577. plugin = plugin_u
  2578. elif (plugin_l):
  2579. plugin = plugin_l
  2580. elif (plugin_B):
  2581. plugin = plugin_B
  2582. else:
  2583. plugin = None
  2584. if (plugin):
  2585. btype = plugin['build']
  2586. ptype = plugin['type']
  2587. filename = plugin['binary']
  2588. label = plugin['label']
  2589. extra_stuff = self.get_extra_stuff(plugin)
  2590. new_plugin_id = self.add_plugin(btype, ptype, filename, label, extra_stuff, False)
  2591. if (new_plugin_id >= 0):
  2592. pwidget = self.m_plugin_list[new_plugin_id]
  2593. pwidget.loadStateDict(x_save_state_dict)
  2594. else:
  2595. x_failed_plugins.append(x_save_state_dict['Name'])
  2596. else:
  2597. x_failed_plugins.append(x_save_state_dict['Name'])
  2598. if (len(x_failed_plugins) > 0):
  2599. text = self.tr("The following plugins were not found or failed to initialize:\n")
  2600. for plugin in x_failed_plugins:
  2601. text += plugin
  2602. text += "\n"
  2603. self.statusBar().showMessage("State file loaded with errors")
  2604. QMessageBox.critical(self, self.tr("Error"), text)
  2605. else:
  2606. self.statusBar().showMessage("State file loaded sucessfully!")
  2607. def loadRDFs(self):
  2608. # Save RDF info for later
  2609. if (haveRDF):
  2610. SettingsDir = os.path.join(HOME, ".config", "Cadence")
  2611. fr_ladspa_file = os.path.join(SettingsDir, "ladspa_rdf.db")
  2612. if (os.path.exists(fr_ladspa_file)):
  2613. fr_ladspa = open(fr_ladspa_file, 'r')
  2614. if (fr_ladspa):
  2615. #try:
  2616. self.ladspa_rdf_list = ladspa_rdf.get_c_ladspa_rdfs(json.load(fr_ladspa))
  2617. #except:
  2618. #self.ladspa_rdf_list = []
  2619. fr_ladspa.close()
  2620. fr_lv2_file = os.path.join(SettingsDir, "lv2_rdf.db")
  2621. if (os.path.exists(fr_lv2_file)):
  2622. fr_lv2 = open(fr_lv2_file, 'r')
  2623. if (fr_lv2):
  2624. #try:
  2625. self.lv2_rdf_list = lv2_rdf.get_c_lv2_rdfs(json.load(fr_lv2))
  2626. #except:
  2627. #self.lv2_rdf_list = []
  2628. fr_lv2.close()
  2629. else:
  2630. self.ladspa_rdf_list = []
  2631. self.lv2_rdf_list = []
  2632. @pyqtSlot()
  2633. def slot_file_new(self):
  2634. self.slot_remove_all()
  2635. self.m_project_filename = None
  2636. self.setWindowTitle("Carla")
  2637. @pyqtSlot()
  2638. def slot_file_open(self):
  2639. file_filter = self.tr("Carla Project File (*.carxp)")
  2640. filename = QFileDialog.getOpenFileName(self, self.tr("Open Carla Project File"), self.m_savedSettings["Main/DefaultProjectFolder"], filter=file_filter)
  2641. if (filename):
  2642. self.m_project_filename = filename
  2643. self.slot_remove_all()
  2644. self.load_project()
  2645. self.setWindowTitle("Carla - %s" % (getShortFileName(self.m_project_filename)))
  2646. @pyqtSlot()
  2647. def slot_file_save(self, saveAs=False):
  2648. if (self.m_project_filename == None or saveAs):
  2649. file_filter = self.tr("Carla Project File (*.carxp)")
  2650. filename = QFileDialog.getSaveFileName(self, self.tr("Save Carla Project File"), self.m_savedSettings["Main/DefaultProjectFolder"], filter=file_filter)
  2651. if (filename):
  2652. self.m_project_filename = filename
  2653. self.save_project()
  2654. self.setWindowTitle("Carla - %s" % (getShortFileName(self.m_project_filename)))
  2655. else:
  2656. self.save_project()
  2657. @pyqtSlot()
  2658. def slot_file_save_as(self):
  2659. self.slot_file_save(True)
  2660. @pyqtSlot()
  2661. def slot_plugin_add(self):
  2662. dialog = PluginDatabaseW(self)
  2663. if (dialog.exec_()):
  2664. btype = dialog.ret_plugin['build']
  2665. ptype = dialog.ret_plugin['type']
  2666. filename = dialog.ret_plugin['binary']
  2667. label = dialog.ret_plugin['label']
  2668. extra_stuff = self.get_extra_stuff(dialog.ret_plugin)
  2669. self.add_plugin(btype, ptype, filename, label, extra_stuff, True)
  2670. @pyqtSlot()
  2671. def slot_remove_all(self):
  2672. for i in range(MAX_PLUGINS):
  2673. if (self.m_plugin_list[i]):
  2674. self.remove_plugin(i, False)
  2675. @pyqtSlot()
  2676. def slot_configureCarla(self):
  2677. dialog = SettingsW(self, "carla")
  2678. if (dialog.exec_()):
  2679. self.loadSettings(False)
  2680. for pwidget in self.m_plugin_list:
  2681. if (pwidget):
  2682. pwidget.peak_in.setRefreshRate(self.m_savedSettings["Main/RefreshInterval"])
  2683. pwidget.peak_out.setRefreshRate(self.m_savedSettings["Main/RefreshInterval"])
  2684. @pyqtSlot()
  2685. def slot_aboutCarla(self):
  2686. AboutW(self).exec_()
  2687. def saveSettings(self):
  2688. self.settings.setValue("Geometry", self.saveGeometry())
  2689. self.settings.setValue("ShowToolbar", self.toolBar.isVisible())
  2690. def loadSettings(self, geometry):
  2691. if (geometry):
  2692. self.restoreGeometry(self.settings.value("Geometry", ""))
  2693. show_toolbar = self.settings.value("ShowToolbar", True, type=bool)
  2694. self.act_settings_show_toolbar.setChecked(show_toolbar)
  2695. self.toolBar.setVisible(show_toolbar)
  2696. self.m_savedSettings = {
  2697. "Main/DefaultProjectFolder": self.settings.value("Main/DefaultProjectFolder", DEFAULT_PROJECT_FOLDER, type=str),
  2698. "Main/RefreshInterval": self.settings.value("Main/RefreshInterval", 120, type=int)
  2699. }
  2700. global LADSPA_PATH, DSSI_PATH, LV2_PATH, VST_PATH, SF2_PATH
  2701. LADSPA_PATH = toList(self.settings.value("Paths/LADSPA", LADSPA_PATH))
  2702. DSSI_PATH = toList(self.settings.value("Paths/DSSI", DSSI_PATH))
  2703. LV2_PATH = toList(self.settings.value("Paths/LV2", LV2_PATH))
  2704. VST_PATH = toList(self.settings.value("Paths/VST", VST_PATH))
  2705. SF2_PATH = toList(self.settings.value("Paths/SF2", SF2_PATH))
  2706. print(LV2_PATH)
  2707. def timerEvent(self, event):
  2708. if (event.timerId() == self.TIMER_GUI_STUFF):
  2709. for pwidget in self.m_plugin_list:
  2710. if (pwidget): pwidget.check_gui_stuff()
  2711. elif (event.timerId() == self.TIMER_GUI_STUFF2):
  2712. for pwidget in self.m_plugin_list:
  2713. if (pwidget): pwidget.check_gui_stuff2()
  2714. QMainWindow.timerEvent(self, event)
  2715. def closeEvent(self, event):
  2716. self.saveSettings()
  2717. self.slot_remove_all()
  2718. QMainWindow.closeEvent(self, event)
  2719. #--------------- main ------------------
  2720. if __name__ == '__main__':
  2721. # App initialization
  2722. app = QApplication(sys.argv)
  2723. app.setApplicationName("Carla")
  2724. app.setApplicationVersion(VERSION)
  2725. app.setOrganizationName("falkTX")
  2726. app.setWindowIcon(QIcon(":/scalable/carla.svg"))
  2727. #style = app.style().metaObject().className()
  2728. #force_parameters_style = (style in ("Bespin::Style",))
  2729. CarlaHost = Host()
  2730. # Create GUI and read settings
  2731. gui = CarlaMainW()
  2732. # Init backend
  2733. CarlaHost.set_option(OPTION_GLOBAL_JACK_CLIENT, 0, "")
  2734. if (not CarlaHost.carla_init("Carla")):
  2735. CustomMessageBox(None, QMessageBox.Critical, "Error", "Could not connect to JACK",
  2736. toString(CarlaHost.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  2737. sys.exit(1)
  2738. # Set-up custom signal handling
  2739. set_up_signals(gui)
  2740. # Show GUI
  2741. gui.show()
  2742. for i in range(len(app.arguments())):
  2743. if (i == 0): continue
  2744. try_path = app.arguments()[i]
  2745. if (os.path.exists(try_path)):
  2746. gui.m_project_filename = try_path
  2747. gui.load_project()
  2748. gui.setWindowTitle("Carla - %s" % (getShortFileName(try_path)))
  2749. # App-Loop
  2750. ret = app.exec_()
  2751. # Close Host
  2752. if (CarlaHost.carla_is_engine_running()):
  2753. if (not CarlaHost.carla_close()):
  2754. print(toString(CarlaHost.get_last_error()))
  2755. # Exit properly
  2756. sys.exit(ret)