Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3187 lines
126KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Common Carla code
  4. # Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the GPL.txt file
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. import os
  20. import json
  21. import sys
  22. from copy import deepcopy
  23. from subprocess import Popen, PIPE
  24. from PyQt4.QtCore import pyqtSlot, qWarning, Qt, QByteArray, QSettings, QThread, QTimer, SIGNAL, SLOT
  25. from PyQt4.QtGui import QColor, QCursor, QDialog, QIcon, QInputDialog, QFileDialog, QFontMetrics, QFrame, QMenu
  26. from PyQt4.QtGui import QMessageBox, QPainter, QPainterPath, QTableWidgetItem, QVBoxLayout, QWidget
  27. # ------------------------------------------------------------------------------------------------------------
  28. # Imports (Custom)
  29. import ui_carla_about
  30. import ui_carla_database
  31. import ui_carla_edit
  32. import ui_carla_parameter
  33. import ui_carla_plugin
  34. import ui_carla_refresh
  35. from carla_backend import *
  36. # ------------------------------------------------------------------------------------------------------------
  37. # Try Import LADSPA-RDF
  38. try:
  39. import ladspa_rdf
  40. haveLRDF = True
  41. except:
  42. print("LRDF Support not available (LADSPA-RDF will be disabled)")
  43. haveLRDF = False
  44. # ------------------------------------------------------------------------------------------------------------
  45. # Try Import Signal
  46. try:
  47. from signal import signal, SIGINT, SIGTERM, SIGUSR1
  48. haveSignal = True
  49. except:
  50. haveSignal = False
  51. # ------------------------------------------------------------------------------------------------------------
  52. # Platform specific stuff
  53. if MACOS:
  54. from PyQt4.QtGui import qt_mac_set_menubar_icons
  55. qt_mac_set_menubar_icons(False)
  56. elif WINDOWS:
  57. WINDIR = os.getenv("WINDIR")
  58. # ------------------------------------------------------------------------------------------------------------
  59. # Set Version
  60. VERSION = "0.5.0"
  61. # ------------------------------------------------------------------------------------------------------------
  62. # Set TMP
  63. TMP = os.getenv("TMP")
  64. if TMP is None:
  65. if WINDOWS:
  66. qWarning("TMP variable not set")
  67. TMP = os.path.join(WINDIR, "temp")
  68. else:
  69. TMP = "/tmp"
  70. # ------------------------------------------------------------------------------------------------------------
  71. # Set HOME
  72. HOME = os.getenv("HOME")
  73. if HOME is None:
  74. HOME = os.path.expanduser("~")
  75. if LINUX or MACOS:
  76. qWarning("HOME variable not set")
  77. if not os.path.exists(HOME):
  78. qWarning("HOME does not exist")
  79. HOME = TMP
  80. # ------------------------------------------------------------------------------------------------------------
  81. # Set PATH
  82. PATH = os.getenv("PATH")
  83. if PATH is None:
  84. qWarning("PATH variable not set")
  85. if MACOS:
  86. PATH = ("/opt/local/bin", "/usr/local/bin", "/usr/bin", "/bin")
  87. elif WINDOWS:
  88. PATH = (os.path.join(WINDIR, "system32"), WINDIR)
  89. else:
  90. PATH = ("/usr/local/bin", "/usr/bin", "/bin")
  91. else:
  92. PATH = PATH.split(os.pathsep)
  93. # ------------------------------------------------------------------------------------------------------------
  94. # Carla object
  95. class CarlaObject(object):
  96. __slots__ = [
  97. 'host',
  98. 'gui',
  99. 'isControl',
  100. 'isLocal',
  101. 'processMode',
  102. 'maxParameters',
  103. 'LADSPA_PATH',
  104. 'DSSI_PATH',
  105. 'LV2_PATH',
  106. 'VST_PATH',
  107. 'GIG_PATH',
  108. 'SF2_PATH',
  109. 'SFZ_PATH'
  110. ]
  111. Carla = CarlaObject()
  112. Carla.host = None
  113. Carla.gui = None
  114. Carla.isControl = False
  115. Carla.isLocal = True
  116. Carla.processMode = PROCESS_MODE_CONTINUOUS_RACK
  117. Carla.maxParameters = MAX_RACK_PLUGINS
  118. # ------------------------------------------------------------------------------------------------------------
  119. # Carla GUI defines
  120. ICON_STATE_NULL = 0
  121. ICON_STATE_WAIT = 1
  122. ICON_STATE_OFF = 2
  123. ICON_STATE_ON = 3
  124. PALETTE_COLOR_NONE = 0
  125. PALETTE_COLOR_WHITE = 1
  126. PALETTE_COLOR_RED = 2
  127. PALETTE_COLOR_GREEN = 3
  128. PALETTE_COLOR_BLUE = 4
  129. PALETTE_COLOR_YELLOW = 5
  130. PALETTE_COLOR_ORANGE = 6
  131. PALETTE_COLOR_BROWN = 7
  132. PALETTE_COLOR_PINK = 8
  133. # ------------------------------------------------------------------------------------------------------------
  134. # Static MIDI CC list
  135. MIDI_CC_LIST = (
  136. #"0x00 Bank Select",
  137. "0x01 Modulation",
  138. "0x02 Breath",
  139. "0x03 (Undefined)",
  140. "0x04 Foot",
  141. "0x05 Portamento",
  142. #"0x06 (Data Entry MSB)",
  143. "0x07 Volume",
  144. "0x08 Balance",
  145. "0x09 (Undefined)",
  146. "0x0A Pan",
  147. "0x0B Expression",
  148. "0x0C FX Control 1",
  149. "0x0D FX Control 2",
  150. "0x0E (Undefined)",
  151. "0x0F (Undefined)",
  152. "0x10 General Purpose 1",
  153. "0x11 General Purpose 2",
  154. "0x12 General Purpose 3",
  155. "0x13 General Purpose 4",
  156. "0x14 (Undefined)",
  157. "0x15 (Undefined)",
  158. "0x16 (Undefined)",
  159. "0x17 (Undefined)",
  160. "0x18 (Undefined)",
  161. "0x19 (Undefined)",
  162. "0x1A (Undefined)",
  163. "0x1B (Undefined)",
  164. "0x1C (Undefined)",
  165. "0x1D (Undefined)",
  166. "0x1E (Undefined)",
  167. "0x1F (Undefined)",
  168. #"0x20 *Bank Select",
  169. #"0x21 *Modulation",
  170. #"0x22 *Breath",
  171. #"0x23 *(Undefined)",
  172. #"0x24 *Foot",
  173. #"0x25 *Portamento",
  174. #"0x26 *(Data Entry MSB)",
  175. #"0x27 *Volume",
  176. #"0x28 *Balance",
  177. #"0x29 *(Undefined)",
  178. #"0x2A *Pan",
  179. #"0x2B *Expression",
  180. #"0x2C *FX *Control 1",
  181. #"0x2D *FX *Control 2",
  182. #"0x2E *(Undefined)",
  183. #"0x2F *(Undefined)",
  184. #"0x30 *General Purpose 1",
  185. #"0x31 *General Purpose 2",
  186. #"0x32 *General Purpose 3",
  187. #"0x33 *General Purpose 4",
  188. #"0x34 *(Undefined)",
  189. #"0x35 *(Undefined)",
  190. #"0x36 *(Undefined)",
  191. #"0x37 *(Undefined)",
  192. #"0x38 *(Undefined)",
  193. #"0x39 *(Undefined)",
  194. #"0x3A *(Undefined)",
  195. #"0x3B *(Undefined)",
  196. #"0x3C *(Undefined)",
  197. #"0x3D *(Undefined)",
  198. #"0x3E *(Undefined)",
  199. #"0x3F *(Undefined)",
  200. #"0x40 Damper On/Off", # <63 off, >64 on
  201. #"0x41 Portamento On/Off", # <63 off, >64 on
  202. #"0x42 Sostenuto On/Off", # <63 off, >64 on
  203. #"0x43 Soft Pedal On/Off", # <63 off, >64 on
  204. #"0x44 Legato Footswitch", # <63 Normal, >64 Legato
  205. #"0x45 Hold 2", # <63 off, >64 on
  206. "0x46 Control 1 [Variation]",
  207. "0x47 Control 2 [Timbre]",
  208. "0x48 Control 3 [Release]",
  209. "0x49 Control 4 [Attack]",
  210. "0x4A Control 5 [Brightness]",
  211. "0x4B Control 6 [Decay]",
  212. "0x4C Control 7 [Vib Rate]",
  213. "0x4D Control 8 [Vib Depth]",
  214. "0x4E Control 9 [Vib Delay]",
  215. "0x4F Control 10 [Undefined]",
  216. "0x50 General Purpose 5",
  217. "0x51 General Purpose 6",
  218. "0x52 General Purpose 7",
  219. "0x53 General Purpose 8",
  220. "0x54 Portamento Control",
  221. "0x5B FX 1 Depth [Reverb]",
  222. "0x5C FX 2 Depth [Tremolo]",
  223. "0x5D FX 3 Depth [Chorus]",
  224. "0x5E FX 4 Depth [Detune]",
  225. "0x5F FX 5 Depth [Phaser]"
  226. )
  227. # ------------------------------------------------------------------------------------------------------------
  228. # Default Plugin Folders
  229. if WINDOWS:
  230. splitter = ";"
  231. APPDATA = os.getenv("APPDATA")
  232. PROGRAMFILES = os.getenv("PROGRAMFILES")
  233. PROGRAMFILESx86 = os.getenv("PROGRAMFILES(x86)")
  234. COMMONPROGRAMFILES = os.getenv("COMMONPROGRAMFILES")
  235. # Small integrity tests
  236. if not APPDATA:
  237. print("APPDATA variable not set, cannot continue")
  238. sys.exit(1)
  239. if not PROGRAMFILES:
  240. print("PROGRAMFILES variable not set, cannot continue")
  241. sys.exit(1)
  242. if not COMMONPROGRAMFILES:
  243. print("COMMONPROGRAMFILES variable not set, cannot continue")
  244. sys.exit(1)
  245. DEFAULT_LADSPA_PATH = ";".join((os.path.join(APPDATA, "LADSPA"),
  246. os.path.join(PROGRAMFILES, "LADSPA")))
  247. DEFAULT_DSSI_PATH = ";".join((os.path.join(APPDATA, "DSSI"),
  248. os.path.join(PROGRAMFILES, "DSSI")))
  249. DEFAULT_LV2_PATH = ";".join((os.path.join(APPDATA, "LV2"),
  250. os.path.join(COMMONPROGRAMFILES, "LV2")))
  251. DEFAULT_VST_PATH = ";".join((os.path.join(PROGRAMFILES, "VstPlugins"),
  252. os.path.join(PROGRAMFILES, "Steinberg", "VstPlugins")))
  253. DEFAULT_GIG_PATH = ";".join((os.path.join(APPDATA, "GIG"),))
  254. DEFAULT_SF2_PATH = ";".join((os.path.join(APPDATA, "SF2"),))
  255. DEFAULT_SFZ_PATH = ";".join((os.path.join(APPDATA, "SFZ"),))
  256. if PROGRAMFILESx86:
  257. DEFAULT_LADSPA_PATH += ";"+os.path.join(PROGRAMFILESx86, "LADSPA")
  258. DEFAULT_DSSI_PATH += ";"+os.path.join(PROGRAMFILESx86, "DSSI")
  259. DEFAULT_VST_PATH += ";"+os.path.join(PROGRAMFILESx86, "VstPlugins")
  260. DEFAULT_VST_PATH += ";"+os.path.join(PROGRAMFILESx86, "Steinberg", "VstPlugins")
  261. elif HAIKU:
  262. splitter = ":"
  263. DEFAULT_LADSPA_PATH = ":".join((os.path.join(HOME, ".ladspa"),
  264. os.path.join("/", "boot", "common", "add-ons", "ladspa")))
  265. DEFAULT_DSSI_PATH = ":".join((os.path.join(HOME, ".dssi"),
  266. os.path.join("/", "boot", "common", "add-ons", "dssi")))
  267. DEFAULT_LV2_PATH = ":".join((os.path.join(HOME, ".lv2"),
  268. os.path.join("/", "boot", "common", "add-ons", "lv2")))
  269. DEFAULT_VST_PATH = ":".join((os.path.join(HOME, ".vst"),
  270. os.path.join("/", "boot", "common", "add-ons", "vst")))
  271. # TODO
  272. DEFAULT_GIG_PATH = ""
  273. DEFAULT_SF2_PATH = ""
  274. DEFAULT_SFZ_PATH = ""
  275. elif MACOS:
  276. splitter = ":"
  277. DEFAULT_LADSPA_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LADSPA"),
  278. os.path.join("/", "Library", "Audio", "Plug-Ins", "LADSPA")))
  279. DEFAULT_DSSI_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "DSSI"),
  280. os.path.join("/", "Library", "Audio", "Plug-Ins", "DSSI")))
  281. DEFAULT_LV2_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "LV2"),
  282. os.path.join("/", "Library", "Audio", "Plug-Ins", "LV2")))
  283. DEFAULT_VST_PATH = ":".join((os.path.join(HOME, "Library", "Audio", "Plug-Ins", "VST"),
  284. os.path.join("/", "Library", "Audio", "Plug-Ins", "VST")))
  285. # TODO
  286. DEFAULT_GIG_PATH = ""
  287. DEFAULT_SF2_PATH = ""
  288. DEFAULT_SFZ_PATH = ""
  289. else:
  290. splitter = ":"
  291. DEFAULT_LADSPA_PATH = ":".join((os.path.join(HOME, ".ladspa"),
  292. os.path.join("/", "usr", "lib", "ladspa"),
  293. os.path.join("/", "usr", "local", "lib", "ladspa")))
  294. DEFAULT_DSSI_PATH = ":".join((os.path.join(HOME, ".dssi"),
  295. os.path.join("/", "usr", "lib", "dssi"),
  296. os.path.join("/", "usr", "local", "lib", "dssi")))
  297. DEFAULT_LV2_PATH = ":".join((os.path.join(HOME, ".lv2"),
  298. os.path.join("/", "usr", "lib", "lv2"),
  299. os.path.join("/", "usr", "local", "lib", "lv2")))
  300. DEFAULT_VST_PATH = ":".join((os.path.join(HOME, ".vst"),
  301. os.path.join("/", "usr", "lib", "vst"),
  302. os.path.join("/", "usr", "local", "lib", "vst")))
  303. DEFAULT_GIG_PATH = ":".join((os.path.join(HOME, ".sounds"),
  304. os.path.join("/", "usr", "share", "sounds", "gig")))
  305. DEFAULT_SF2_PATH = ":".join((os.path.join(HOME, ".sounds"),
  306. os.path.join("/", "usr", "share", "sounds", "sf2")))
  307. DEFAULT_SFZ_PATH = ":".join((os.path.join(HOME, ".sounds"),
  308. os.path.join("/", "usr", "share", "sounds", "sfz")))
  309. # ------------------------------------------------------------------------------------------------------------
  310. # Default Plugin Folders (set)
  311. readEnvVars = True
  312. if WINDOWS:
  313. # Check if running Wine. If yes, ignore env vars
  314. from winreg import ConnectRegistry, OpenKey, CloseKey, HKEY_CURRENT_USER
  315. reg = ConnectRegistry(None, HKEY_CURRENT_USER)
  316. try:
  317. key = OpenKey(reg, r"SOFTWARE\Wine")
  318. CloseKey(key)
  319. readEnvVars = False
  320. except:
  321. pass
  322. CloseKey(reg)
  323. del reg
  324. if readEnvVars:
  325. Carla.LADSPA_PATH = os.getenv("LADSPA_PATH", DEFAULT_LADSPA_PATH).split(splitter)
  326. Carla.DSSI_PATH = os.getenv("DSSI_PATH", DEFAULT_DSSI_PATH).split(splitter)
  327. Carla.LV2_PATH = os.getenv("LV2_PATH", DEFAULT_LV2_PATH).split(splitter)
  328. Carla.VST_PATH = os.getenv("VST_PATH", DEFAULT_VST_PATH).split(splitter)
  329. Carla.GIG_PATH = os.getenv("GIG_PATH", DEFAULT_GIG_PATH).split(splitter)
  330. Carla.SF2_PATH = os.getenv("SF2_PATH", DEFAULT_SF2_PATH).split(splitter)
  331. Carla.SFZ_PATH = os.getenv("SFZ_PATH", DEFAULT_SFZ_PATH).split(splitter)
  332. if haveLRDF:
  333. LADSPA_RDF_PATH_env = os.getenv("LADSPA_RDF_PATH")
  334. if LADSPA_RDF_PATH_env:
  335. ladspa_rdf.set_rdf_path(LADSPA_RDF_PATH_env.split(splitter))
  336. del LADSPA_RDF_PATH_env
  337. else:
  338. Carla.LADSPA_PATH = DEFAULT_LADSPA_PATH.split(splitter)
  339. Carla.DSSI_PATH = DEFAULT_DSSI_PATH.split(splitter)
  340. Carla.LV2_PATH = DEFAULT_LV2_PATH.split(splitter)
  341. Carla.VST_PATH = DEFAULT_VST_PATH.split(splitter)
  342. Carla.GIG_PATH = DEFAULT_GIG_PATH.split(splitter)
  343. Carla.SF2_PATH = DEFAULT_SF2_PATH.split(splitter)
  344. Carla.SFZ_PATH = DEFAULT_SFZ_PATH.split(splitter)
  345. # ------------------------------------------------------------------------------------------------------------
  346. # Search for Carla library and tools
  347. global carla_library_path
  348. carla_library_path = ""
  349. carla_discovery_native = ""
  350. carla_discovery_posix32 = ""
  351. carla_discovery_posix64 = ""
  352. carla_discovery_win32 = ""
  353. carla_discovery_win64 = ""
  354. carla_bridge_native = ""
  355. carla_bridge_posix32 = ""
  356. carla_bridge_posix64 = ""
  357. carla_bridge_win32 = ""
  358. carla_bridge_win64 = ""
  359. carla_bridge_lv2_gtk2 = ""
  360. carla_bridge_lv2_gtk3 = ""
  361. carla_bridge_lv2_qt4 = ""
  362. carla_bridge_lv2_qt5 = ""
  363. carla_bridge_lv2_cocoa = ""
  364. carla_bridge_lv2_windows = ""
  365. carla_bridge_lv2_x11 = ""
  366. carla_bridge_vst_cocoa = ""
  367. carla_bridge_vst_hwnd = ""
  368. carla_bridge_vst_x11 = ""
  369. if WINDOWS:
  370. carla_libname = "libcarla_standalone.dll"
  371. elif MACOS:
  372. carla_libname = "libcarla_standalone.dylib"
  373. else:
  374. carla_libname = "libcarla_standalone.so"
  375. CWD = sys.path[0]
  376. # make it work with cxfreeze
  377. if CWD.endswith("%scarla" % os.sep):
  378. CWD = CWD.rsplit("%scarla" % os.sep, 1)[0]
  379. elif CWD.endswith("carla.exe"):
  380. CWD = CWD.rsplit("carla.exe", 1)[0]
  381. # find carla_library_path
  382. if os.path.exists(os.path.join(CWD, "backend", carla_libname)):
  383. carla_library_path = os.path.join(CWD, "backend", carla_libname)
  384. else:
  385. if WINDOWS:
  386. CARLA_PATH = (os.path.join(PROGRAMFILES, "Carla"),)
  387. elif MACOS:
  388. CARLA_PATH = ("/opt/local/lib", "/usr/local/lib/", "/usr/lib")
  389. else:
  390. CARLA_PATH = ("/usr/local/lib/", "/usr/lib")
  391. for path in CARLA_PATH:
  392. if os.path.exists(os.path.join(path, "carla", carla_libname)):
  393. carla_library_path = os.path.join(path, "carla", carla_libname)
  394. break
  395. # find tool
  396. def findTool(tdir, tname):
  397. if os.path.exists(os.path.join(CWD, tdir, tname)):
  398. return os.path.join(CWD, tdir, tname)
  399. for p in PATH:
  400. if os.path.exists(os.path.join(p, tname)):
  401. return os.path.join(p, tname)
  402. return ""
  403. # find windows tools
  404. carla_discovery_win32 = findTool("discovery", "carla-discovery-win32.exe")
  405. carla_discovery_win64 = findTool("discovery", "carla-discovery-win64.exe")
  406. carla_bridge_win32 = findTool("bridges", "carla-bridge-win32.exe")
  407. carla_bridge_win64 = findTool("bridges", "carla-bridge-win64.exe")
  408. # find native and posix tools
  409. if not WINDOWS:
  410. carla_discovery_native = findTool("discovery", "carla-discovery-native")
  411. carla_discovery_posix32 = findTool("discovery", "carla-discovery-posix32")
  412. carla_discovery_posix64 = findTool("discovery", "carla-discovery-posix64")
  413. carla_bridge_native = findTool("bridges", "carla-bridge-native")
  414. carla_bridge_posix32 = findTool("bridges", "carla-bridge-posix32")
  415. carla_bridge_posix64 = findTool("bridges", "carla-bridge-posix64")
  416. # find windows only tools
  417. if WINDOWS:
  418. carla_bridge_lv2_windows = findTool("bridges", "carla-bridge-lv2-windows.exe")
  419. carla_bridge_vst_hwnd = findTool("bridges", "carla-bridge-vst-hwnd.exe")
  420. # find mac os only tools
  421. elif MACOS:
  422. carla_bridge_lv2_cocoa = findTool("bridges", "carla-bridge-lv2-cocoa")
  423. carla_bridge_vst_cocoa = findTool("bridges", "carla-bridge-vst-cocoa")
  424. # find generic tools
  425. else:
  426. carla_bridge_lv2_gtk2 = findTool("bridges", "carla-bridge-lv2-gtk2")
  427. carla_bridge_lv2_gtk3 = findTool("bridges", "carla-bridge-lv2-gtk3")
  428. carla_bridge_lv2_qt4 = findTool("bridges", "carla-bridge-lv2-qt4")
  429. carla_bridge_lv2_qt5 = findTool("bridges", "carla-bridge-lv2-qt5")
  430. # find linux only tools
  431. if LINUX:
  432. carla_bridge_lv2_x11 = os.path.join("bridges", "carla-bridge-lv2-x11")
  433. carla_bridge_vst_x11 = os.path.join("bridges", "carla-bridge-vst-x11")
  434. # ------------------------------------------------------------------------------------------------------------
  435. # Convert a ctypes c_char_p into a python string
  436. def cString(value):
  437. if not value:
  438. return ""
  439. if isinstance(value, str):
  440. return value
  441. return value.decode("utf-8", errors="ignore")
  442. # ------------------------------------------------------------------------------------------------------------
  443. # Check if a value is a number (float support)
  444. def isNumber(value):
  445. try:
  446. float(value)
  447. return True
  448. except:
  449. return False
  450. # ------------------------------------------------------------------------------------------------------------
  451. # Convert a value to a list
  452. def toList(value):
  453. if value is None:
  454. return []
  455. elif not isinstance(value, list):
  456. return [value]
  457. else:
  458. return value
  459. # ------------------------------------------------------------------------------------------------------------
  460. # Get Icon from user theme, using our own as backup (Oxygen)
  461. def getIcon(icon, size=16):
  462. return QIcon.fromTheme(icon, QIcon(":/%ix%i/%s.png" % (size, size, icon)))
  463. # ------------------------------------------------------------------------------------------------------------
  464. # Signal handler
  465. def signalHandler(sig, frame):
  466. if Carla.gui is None:
  467. return
  468. if sig in (SIGINT, SIGTERM):
  469. Carla.gui.emit(SIGNAL("SIGTERM()"))
  470. elif sig == SIGUSR1:
  471. Carla.gui.emit(SIGNAL("SIGUSR1()"))
  472. def setUpSignals():
  473. if not haveSignal:
  474. return
  475. signal(SIGINT, signalHandler)
  476. signal(SIGTERM, signalHandler)
  477. signal(SIGUSR1, signalHandler)
  478. # ------------------------------------------------------------------------------------------------------------
  479. # QLineEdit and QPushButton combo
  480. def getAndSetPath(self_, currentPath, lineEdit):
  481. newPath = QFileDialog.getExistingDirectory(self_, self_.tr("Set Path"), currentPath, QFileDialog.ShowDirsOnly)
  482. if newPath:
  483. lineEdit.setText(newPath)
  484. return newPath
  485. # ------------------------------------------------------------------------------------------------------------
  486. # Custom MessageBox
  487. def CustomMessageBox(self_, icon, title, text, extraText="", buttons=QMessageBox.Yes|QMessageBox.No, defButton=QMessageBox.No):
  488. msgBox = QMessageBox(self_)
  489. msgBox.setIcon(icon)
  490. msgBox.setWindowTitle(title)
  491. msgBox.setText(text)
  492. msgBox.setInformativeText(extraText)
  493. msgBox.setStandardButtons(buttons)
  494. msgBox.setDefaultButton(defButton)
  495. return msgBox.exec_()
  496. # ------------------------------------------------------------------------------------------------------------
  497. # Plugin Query (helper functions)
  498. def findBinaries(bPATH, OS):
  499. binaries = []
  500. if OS == "WINDOWS":
  501. extensions = (".dll",)
  502. elif OS == "MACOS":
  503. extensions = (".dylib", ".so")
  504. else:
  505. extensions = (".so", ".sO", ".SO", ".So")
  506. for root, dirs, files in os.walk(bPATH):
  507. for name in [name for name in files if name.endswith(extensions)]:
  508. binaries.append(os.path.join(root, name))
  509. return binaries
  510. def findLV2Bundles(bPATH):
  511. bundles = []
  512. for root, dirs, files in os.walk(bPATH):
  513. if os.path.exists(os.path.join(root, "manifest.ttl")):
  514. bundles.append(root)
  515. return bundles
  516. def findSoundKits(bPATH, stype):
  517. soundfonts = []
  518. if stype == "gig":
  519. extensions = (".gig", ".giG", ".gIG", ".GIG", ".GIg", ".Gig") if not WINDOWS else (".gig",)
  520. elif stype == "sf2":
  521. extensions = (".sf2", ".sF2", ".SF2", ".Sf2") if not WINDOWS else (".sf2",)
  522. elif stype == "sfz":
  523. extensions = (".sfz", ".sfZ", ".sFZ", ".SFZ", ".SFz", ".Sfz") if not WINDOWS else (".sfz",)
  524. else:
  525. return []
  526. for root, dirs, files in os.walk(bPATH):
  527. for name in [name for name in files if name.endswith(extensions)]:
  528. soundfonts.append(os.path.join(root, name))
  529. return soundfonts
  530. def findDSSIGUI(filename, name, label):
  531. pluginDir = filename.rsplit(".", 1)[0]
  532. shortName = os.path.basename(pluginDir)
  533. guiFilename = ""
  534. checkName = name.replace(" ", "_")
  535. checkLabel = label
  536. checkSName = shortName
  537. if checkName[-1] != "_": checkName += "_"
  538. if checkLabel[-1] != "_": checkLabel += "_"
  539. if checkSName[-1] != "_": checkSName += "_"
  540. for root, dirs, files in os.walk(pluginDir):
  541. guiFiles = files
  542. break
  543. else:
  544. guiFiles = []
  545. for guiFile in guiFiles:
  546. if guiFile.startswith(checkName) or guiFile.startswith(checkLabel) or guiFile.startswith(checkSName):
  547. guiFilename = os.path.join(pluginDir, guiFile)
  548. break
  549. return guiFilename
  550. # ------------------------------------------------------------------------------------------------------------
  551. # Plugin Query
  552. PLUGIN_QUERY_API_VERSION = 1
  553. PyPluginInfo = {
  554. 'API': PLUGIN_QUERY_API_VERSION,
  555. 'build': BINARY_NONE,
  556. 'type': PLUGIN_NONE,
  557. 'hints': 0x0,
  558. 'binary': "",
  559. 'name': "",
  560. 'label': "",
  561. 'maker': "",
  562. 'copyright': "",
  563. 'uniqueId': 0,
  564. 'audio.ins': 0,
  565. 'audio.outs': 0,
  566. 'audio.total': 0,
  567. 'midi.ins': 0,
  568. 'midi.outs': 0,
  569. 'midi.total': 0,
  570. 'parameters.ins': 0,
  571. 'parameters.outs': 0,
  572. 'parameters.total': 0,
  573. 'programs.total': 0
  574. }
  575. def runCarlaDiscovery(itype, stype, filename, tool, isWine=False):
  576. fakeLabel = os.path.basename(filename).rsplit(".", 1)[0]
  577. plugins = []
  578. command = []
  579. if LINUX or MACOS:
  580. command.append("env")
  581. command.append("LANG=C")
  582. if isWine:
  583. command.append("WINEDEBUG=-all")
  584. command.append(tool)
  585. command.append(stype)
  586. command.append(filename)
  587. Ps = Popen(command, stdout=PIPE)
  588. Ps.wait()
  589. output = Ps.stdout.read().decode("utf-8", errors="ignore").split("\n")
  590. pinfo = None
  591. for line in output:
  592. line = line.strip()
  593. if line == "carla-discovery::init::-----------":
  594. pinfo = deepcopy(PyPluginInfo)
  595. pinfo['type'] = itype
  596. pinfo['binary'] = filename
  597. elif line == "carla-discovery::end::------------":
  598. if pinfo != None:
  599. plugins.append(pinfo)
  600. pinfo = None
  601. elif line == "Segmentation fault":
  602. print("carla-discovery::crash::%s crashed during discovery" % filename)
  603. elif line.startswith("err:module:import_dll Library"):
  604. print(line)
  605. elif line.startswith("carla-discovery::error::"):
  606. print("%s - %s" % (line, filename))
  607. elif line.startswith("carla-discovery::"):
  608. if pinfo == None:
  609. continue
  610. prop, value = line.replace("carla-discovery::", "").split("::", 1)
  611. if prop == "name":
  612. pinfo['name'] = value if value else fakeLabel
  613. elif prop in ("label", "uri"):
  614. pinfo['label'] = value if value else fakeLabel
  615. elif prop == "maker":
  616. pinfo['maker'] = value
  617. elif prop == "copyright":
  618. pinfo['copyright'] = value
  619. elif prop == "uniqueId":
  620. if value.isdigit(): pinfo['uniqueId'] = int(value)
  621. elif prop == "hints":
  622. if value.isdigit(): pinfo['hints'] = int(value)
  623. elif prop == "audio.ins":
  624. if value.isdigit(): pinfo['audio.ins'] = int(value)
  625. elif prop == "audio.outs":
  626. if value.isdigit(): pinfo['audio.outs'] = int(value)
  627. elif prop == "audio.total":
  628. if value.isdigit(): pinfo['audio.total'] = int(value)
  629. elif prop == "midi.ins":
  630. if value.isdigit(): pinfo['midi.ins'] = int(value)
  631. elif prop == "midi.outs":
  632. if value.isdigit(): pinfo['midi.outs'] = int(value)
  633. elif prop == "midi.total":
  634. if value.isdigit(): pinfo['midi.total'] = int(value)
  635. elif prop == "parameters.ins":
  636. if value.isdigit(): pinfo['parameters.ins'] = int(value)
  637. elif prop == "parameters.outs":
  638. if value.isdigit(): pinfo['parameters.outs'] = int(value)
  639. elif prop == "parameters.total":
  640. if value.isdigit(): pinfo['parameters.total'] = int(value)
  641. elif prop == "programs.total":
  642. if value.isdigit(): pinfo['programs.total'] = int(value)
  643. elif prop == "build":
  644. if value.isdigit(): pinfo['build'] = int(value)
  645. # Additional checks
  646. for pinfo in plugins:
  647. if itype == PLUGIN_DSSI:
  648. if findDSSIGUI(pinfo['binary'], pinfo['name'], pinfo['label']):
  649. pinfo['hints'] |= PLUGIN_HAS_GUI
  650. return plugins
  651. def checkPluginInternal(desc):
  652. plugins = []
  653. pinfo = deepcopy(PyPluginInfo)
  654. pinfo['build'] = BINARY_NATIVE
  655. pinfo['type'] = PLUGIN_INTERNAL
  656. pinfo['hints'] = int(desc['hints'])
  657. pinfo['name'] = cString(desc['name'])
  658. pinfo['label'] = cString(desc['label'])
  659. pinfo['maker'] = cString(desc['maker'])
  660. pinfo['copyright'] = cString(desc['copyright'])
  661. pinfo['audio.ins'] = int(desc['audioIns'])
  662. pinfo['audio.outs'] = int(desc['audioOuts'])
  663. pinfo['audio.total'] = pinfo['audio.ins'] + pinfo['audio.outs']
  664. pinfo['midi.ins'] = int(desc['midiIns'])
  665. pinfo['midi.outs'] = int(desc['midiOuts'])
  666. pinfo['midi.total'] = pinfo['midi.ins'] + pinfo['midi.outs']
  667. pinfo['parameters.ins'] = int(desc['parameterIns'])
  668. pinfo['parameters.outs'] = int(desc['parameterOuts'])
  669. pinfo['parameters.total'] = pinfo['parameters.ins'] + pinfo['parameters.outs']
  670. plugins.append(pinfo)
  671. return plugins
  672. def checkPluginLADSPA(filename, tool, isWine=False):
  673. return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, isWine)
  674. def checkPluginDSSI(filename, tool, isWine=False):
  675. return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, isWine)
  676. def checkPluginLV2(filename, tool, isWine=False):
  677. return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, isWine)
  678. def checkPluginVST(filename, tool, isWine=False):
  679. return runCarlaDiscovery(PLUGIN_VST, "VST", filename, tool, isWine)
  680. def checkPluginGIG(filename, tool):
  681. return runCarlaDiscovery(PLUGIN_GIG, "GIG", filename, tool)
  682. def checkPluginSF2(filename, tool):
  683. return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool)
  684. def checkPluginSFZ(filename, tool):
  685. return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool)
  686. # ------------------------------------------------------------------------------------------------------------
  687. # Carla About dialog
  688. class CarlaAboutW(QDialog):
  689. def __init__(self, parent):
  690. QDialog.__init__(self, parent)
  691. self.ui = ui_carla_about.Ui_CarlaAboutW()
  692. self.ui.setupUi(self)
  693. if Carla.isControl:
  694. extraInfo = " - <b>%s</b>" % self.tr("OSC Bridge Version")
  695. else:
  696. extraInfo = ""
  697. self.ui.l_about.setText(self.tr(""
  698. "<br>Version %s"
  699. "<br>Carla is a Multi-Plugin Host for JACK%s.<br>"
  700. "<br>Copyright (C) 2011-2013 falkTX<br>"
  701. "" % (VERSION, extraInfo)))
  702. if Carla.isControl:
  703. self.ui.l_extended.hide()
  704. self.ui.tabWidget.removeTab(1)
  705. self.ui.tabWidget.removeTab(1)
  706. self.adjustSize()
  707. else:
  708. self.ui.l_extended.setText(cString(Carla.host.get_extended_license_text()))
  709. self.ui.le_osc_url.setText(cString(Carla.host.get_host_osc_url()) if Carla.host.is_engine_running() else self.tr("(Engine not running)"))
  710. self.ui.l_osc_cmds.setText(""
  711. " /set_active <i-value>\n"
  712. " /set_drywet <f-value>\n"
  713. " /set_volume <f-value>\n"
  714. " /set_balance_left <f-value>\n"
  715. " /set_balance_right <f-value>\n"
  716. " /set_panning <f-value>\n"
  717. " /set_parameter_value <i-index> <f-value>\n"
  718. " /set_parameter_midi_cc <i-index> <i-cc>\n"
  719. " /set_parameter_midi_channel <i-index> <i-channel>\n"
  720. " /set_program <i-index>\n"
  721. " /set_midi_program <i-index>\n"
  722. " /note_on <i-note> <i-velo>\n"
  723. " /note_off <i-note>\n"
  724. )
  725. self.ui.l_example.setText("/Carla/2/set_parameter_value 5 1.0")
  726. self.ui.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>")
  727. self.ui.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  728. self.ui.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  729. self.ui.l_lv2.setText(self.tr("About 95&#37; complete (using custom extensions).<br/>"
  730. "Implemented Feature/Extensions:"
  731. "<ul>"
  732. "<li>http://lv2plug.in/ns/ext/atom</li>"
  733. "<li>http://lv2plug.in/ns/ext/buf-size</li>"
  734. "<li>http://lv2plug.in/ns/ext/data-access</li>"
  735. #"<li>http://lv2plug.in/ns/ext/dynmanifest</li>"
  736. "<li>http://lv2plug.in/ns/ext/event</li>"
  737. "<li>http://lv2plug.in/ns/ext/instance-access</li>"
  738. "<li>http://lv2plug.in/ns/ext/log</li>"
  739. "<li>http://lv2plug.in/ns/ext/midi</li>"
  740. "<li>http://lv2plug.in/ns/ext/options</li>"
  741. #"<li>http://lv2plug.in/ns/ext/parameters</li>"
  742. "<li>http://lv2plug.in/ns/ext/patch</li>"
  743. #"<li>http://lv2plug.in/ns/ext/port-groups</li>"
  744. "<li>http://lv2plug.in/ns/ext/port-props</li>"
  745. #"<li>http://lv2plug.in/ns/ext/presets</li>"
  746. "<li>http://lv2plug.in/ns/ext/state</li>"
  747. "<li>http://lv2plug.in/ns/ext/time</li>"
  748. "<li>http://lv2plug.in/ns/ext/uri-map</li>"
  749. "<li>http://lv2plug.in/ns/ext/urid</li>"
  750. "<li>http://lv2plug.in/ns/ext/worker</li>"
  751. "<li>http://lv2plug.in/ns/extensions/ui</li>"
  752. "<li>http://lv2plug.in/ns/extensions/units</li>"
  753. "<li>http://kxstudio.sf.net/ns/lv2ext/external-ui</li>"
  754. "<li>http://kxstudio.sf.net/ns/lv2ext/programs</li>"
  755. "<li>http://kxstudio.sf.net/ns/lv2ext/rtmempool</li>"
  756. "<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  757. "<li>http://ll-plugins.nongnu.org/lv2/ext/miditype</li>"
  758. "</ul>"))
  759. self.ui.l_vst.setText(self.tr("<p>About 85&#37; complete (missing vst bank/presets and some minor stuff)</p>"))
  760. #TODO
  761. self.ui.l_lv2.setText(self.tr("Not enabled for now"))
  762. def done(self, r):
  763. QDialog.done(self, r)
  764. self.close()
  765. # ------------------------------------------------------------------------------------------------------------
  766. # Plugin Parameter
  767. class PluginParameter(QWidget):
  768. def __init__(self, parent, pInfo, pluginId, tabIndex):
  769. QWidget.__init__(self, parent)
  770. self.ui = ui_carla_parameter.Ui_PluginParameter()
  771. self.ui.setupUi(self)
  772. pType = pInfo['type']
  773. pHints = pInfo['hints']
  774. self.fMidiControl = -1
  775. self.fMidiChannel = 1
  776. self.fParameterId = pInfo['index']
  777. self.fPluginId = pluginId
  778. self.fTabIndex = tabIndex
  779. self.ui.label.setText(pInfo['name'])
  780. self.ui.widget.setName(pInfo['name'])
  781. if pType == PARAMETER_INPUT:
  782. self.ui.widget.setMinimum(pInfo['minimum'])
  783. self.ui.widget.setMaximum(pInfo['maximum'])
  784. self.ui.widget.setDefault(pInfo['default'])
  785. self.ui.widget.setValue(pInfo['current'], False)
  786. self.ui.widget.setLabel(pInfo['unit'])
  787. self.ui.widget.setStep(pInfo['step'])
  788. self.ui.widget.setStepSmall(pInfo['stepSmall'])
  789. self.ui.widget.setStepLarge(pInfo['stepLarge'])
  790. self.ui.widget.setScalePoints(pInfo['scalePoints'], bool(pHints & PARAMETER_USES_SCALEPOINTS))
  791. if not pHints & PARAMETER_IS_ENABLED:
  792. self.ui.widget.setReadOnly(True)
  793. self.ui.sb_control.setEnabled(False)
  794. self.ui.sb_channel.setEnabled(False)
  795. elif not pHints & PARAMETER_IS_AUTOMABLE:
  796. self.ui.sb_control.setEnabled(False)
  797. self.ui.sb_channel.setEnabled(False)
  798. elif pType == PARAMETER_OUTPUT:
  799. self.ui.widget.setMinimum(pInfo['minimum'])
  800. self.ui.widget.setMaximum(pInfo['maximum'])
  801. self.ui.widget.setValue(pInfo['current'], False)
  802. self.ui.widget.setLabel(pInfo['unit'])
  803. self.ui.widget.setReadOnly(True)
  804. if not pHints & PARAMETER_IS_AUTOMABLE:
  805. self.ui.sb_control.setEnabled(False)
  806. self.ui.sb_channel.setEnabled(False)
  807. else:
  808. self.ui.widget.setVisible(False)
  809. self.ui.sb_control.setVisible(False)
  810. self.ui.sb_channel.setVisible(False)
  811. if pHints & PARAMETER_USES_CUSTOM_TEXT:
  812. self.ui.widget.setTextCallback(self._textCallBack)
  813. self.setMidiControl(pInfo['midiCC'])
  814. self.setMidiChannel(pInfo['midiChannel']+1)
  815. self.connect(self.ui.sb_control, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_controlSpinboxCustomMenu()"))
  816. self.connect(self.ui.sb_channel, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_channelSpinboxCustomMenu()"))
  817. self.connect(self.ui.sb_control, SIGNAL("valueChanged(int)"), SLOT("slot_controlSpinboxChanged(int)"))
  818. self.connect(self.ui.sb_channel, SIGNAL("valueChanged(int)"), SLOT("slot_channelSpinboxChanged(int)"))
  819. self.connect(self.ui.widget, SIGNAL("valueChanged(double)"), SLOT("slot_widgetValueChanged(double)"))
  820. self.ui.widget.updateAll()
  821. def setDefault(self, value):
  822. self.ui.widget.setDefault(value)
  823. def setValue(self, value, send=True):
  824. self.ui.widget.setValue(value, send)
  825. def setMidiControl(self, control):
  826. self.fMidiControl = control
  827. self.ui.sb_control.blockSignals(True)
  828. self.ui.sb_control.setValue(control)
  829. self.ui.sb_control.blockSignals(False)
  830. def setMidiChannel(self, channel):
  831. self.fMidiChannel = channel
  832. self.ui.sb_channel.blockSignals(True)
  833. self.ui.sb_channel.setValue(channel)
  834. self.ui.sb_channel.blockSignals(False)
  835. def setLabelWidth(self, width):
  836. self.ui.label.setMinimumWidth(width)
  837. self.ui.label.setMaximumWidth(width)
  838. def tabIndex(self):
  839. return self.fTabIndex
  840. @pyqtSlot()
  841. def slot_controlSpinboxCustomMenu(self):
  842. menu = QMenu(self)
  843. actNone = menu.addAction(self.tr("None"))
  844. if self.fMidiControl == -1:
  845. actNone.setCheckable(True)
  846. actNone.setChecked(True)
  847. for cc in MIDI_CC_LIST:
  848. action = menu.addAction(cc)
  849. if self.fMidiControl != -1 and int(cc.split(" ")[0], 16) == self.fMidiControl:
  850. action.setCheckable(True)
  851. action.setChecked(True)
  852. actSel = menu.exec_(QCursor.pos())
  853. if not actSel:
  854. return
  855. if actSel == actNone:
  856. self.ui.sb_control.setValue(-1)
  857. else:
  858. selControlStr = actSel.text()
  859. selControl = int(selControlStr.split(" ")[0], 16)
  860. self.ui.sb_control.setValue(selControl)
  861. @pyqtSlot()
  862. def slot_channelSpinboxCustomMenu(self):
  863. menu = QMenu(self)
  864. for i in range(1, 16+1):
  865. action = menu.addAction("%i" % i)
  866. if self.fMidiChannel == i:
  867. action.setCheckable(True)
  868. action.setChecked(True)
  869. actSel = menu.exec_(QCursor.pos())
  870. if actSel:
  871. selChannel = int(actSel.text())
  872. self.ui.sb_channel.setValue(selChannel)
  873. @pyqtSlot(int)
  874. def slot_controlSpinboxChanged(self, control):
  875. if self.fMidiControl != control:
  876. self.emit(SIGNAL("midiControlChanged(int, int)"), self.fParameterId, control)
  877. self.fMidiControl = control
  878. @pyqtSlot(int)
  879. def slot_channelSpinboxChanged(self, channel):
  880. if self.fMidiChannel != channel:
  881. self.emit(SIGNAL("midiChannelChanged(int, int)"), self.fParameterId, channel)
  882. self.fMidiChannel = channel
  883. @pyqtSlot(float)
  884. def slot_widgetValueChanged(self, value):
  885. self.emit(SIGNAL("valueChanged(int, double)"), self.fParameterId, value)
  886. def _textCallBack(self):
  887. return cString(Carla.host.get_parameter_text(self.fPluginId, self.fParameterId))
  888. # ------------------------------------------------------------------------------------------------------------
  889. # Plugin Editor (Built-in)
  890. class PluginEdit(QDialog):
  891. def __init__(self, parent, pluginId):
  892. QDialog.__init__(self, Carla.gui)
  893. self.ui = ui_carla_edit.Ui_PluginEdit()
  894. self.ui.setupUi(self)
  895. self.fGeometry = QByteArray()
  896. self.fPluginId = pluginId
  897. self.fPuginInfo = None
  898. self.fRealParent = parent
  899. self.fCurrentProgram = -1
  900. self.fCurrentMidiProgram = -1
  901. self.fCurrentStateFilename = None
  902. self.fControlChannel = 0
  903. self.fParameterCount = 0
  904. self.fParameterList = [] # (type, id, widget)
  905. self.fParametersToUpdate = [] # (id, value)
  906. self.fTabIconOff = QIcon(":/bitmaps/led_off.png")
  907. self.fTabIconOn = QIcon(":/bitmaps/led_yellow.png")
  908. self.fTabIconCount = 0
  909. self.fTabIconTimers = []
  910. self.fScrollAreaSetup = False
  911. self.ui.dial_drywet.setPixmap(3)
  912. self.ui.dial_drywet.setLabel("Dry/Wet")
  913. self.ui.dial_vol.setPixmap(3)
  914. self.ui.dial_vol.setLabel("Volume")
  915. self.ui.dial_b_left.setPixmap(4)
  916. self.ui.dial_b_left.setLabel("L")
  917. self.ui.dial_b_right.setPixmap(4)
  918. self.ui.dial_b_right.setLabel("R")
  919. self.ui.dial_drywet.setCustomPaint(self.ui.dial_drywet.CUSTOM_PAINT_CARLA_WET)
  920. self.ui.dial_vol.setCustomPaint(self.ui.dial_vol.CUSTOM_PAINT_CARLA_VOL)
  921. self.ui.dial_b_left.setCustomPaint(self.ui.dial_b_left.CUSTOM_PAINT_CARLA_L)
  922. self.ui.dial_b_right.setCustomPaint(self.ui.dial_b_right.CUSTOM_PAINT_CARLA_R)
  923. self.ui.keyboard.setMode(self.ui.keyboard.HORIZONTAL)
  924. self.ui.keyboard.setOctaves(6)
  925. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  926. self.ui.scrollArea.ensureVisible(self.ui.keyboard.width() / 5, 0)
  927. self.ui.scrollArea.setEnabled(False)
  928. self.ui.scrollArea.setVisible(False)
  929. if Carla.isLocal:
  930. self.connect(self.ui.b_save_state, SIGNAL("clicked()"), SLOT("slot_saveState()"))
  931. self.connect(self.ui.b_load_state, SIGNAL("clicked()"), SLOT("slot_loadState()"))
  932. else:
  933. self.ui.b_load_state.setEnabled(False)
  934. self.ui.b_save_state.setEnabled(False)
  935. self.connect(self.ui.ch_fixed_buffer, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  936. self.connect(self.ui.ch_force_stereo, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  937. self.connect(self.ui.ch_map_program_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  938. self.connect(self.ui.ch_use_chunks, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  939. self.connect(self.ui.ch_send_control_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  940. self.connect(self.ui.ch_send_channel_pressure, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  941. self.connect(self.ui.ch_send_note_aftertouch, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  942. self.connect(self.ui.ch_send_pitchbend, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  943. self.connect(self.ui.ch_send_all_sound_off, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  944. self.connect(self.ui.dial_drywet, SIGNAL("valueChanged(int)"), SLOT("slot_dryWetChanged(int)"))
  945. self.connect(self.ui.dial_vol, SIGNAL("valueChanged(int)"), SLOT("slot_volumeChanged(int)"))
  946. self.connect(self.ui.dial_b_left, SIGNAL("valueChanged(int)"), SLOT("slot_balanceLeftChanged(int)"))
  947. self.connect(self.ui.dial_b_right, SIGNAL("valueChanged(int)"), SLOT("slot_balanceRightChanged(int)"))
  948. self.connect(self.ui.sb_ctrl_channel, SIGNAL("valueChanged(int)"), SLOT("slot_ctrlChannelChanged(int)"))
  949. self.connect(self.ui.dial_drywet, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  950. self.connect(self.ui.dial_vol, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  951. self.connect(self.ui.dial_b_left, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  952. self.connect(self.ui.dial_b_right, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  953. self.connect(self.ui.keyboard, SIGNAL("noteOn(int)"), SLOT("slot_noteOn(int)"))
  954. self.connect(self.ui.keyboard, SIGNAL("noteOff(int)"), SLOT("slot_noteOff(int)"))
  955. self.connect(self.ui.keyboard, SIGNAL("notesOn()"), SLOT("slot_notesOn()"))
  956. self.connect(self.ui.keyboard, SIGNAL("notesOff()"), SLOT("slot_notesOff()"))
  957. self.connect(self.ui.cb_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_programIndexChanged(int)"))
  958. self.connect(self.ui.cb_midi_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_midiProgramIndexChanged(int)"))
  959. self.connect(self, SIGNAL("finished(int)"), SLOT("slot_finished()"))
  960. self.reloadAll()
  961. def reloadAll(self):
  962. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  963. self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"])
  964. self.fPluginInfo["name"] = cString(self.fPluginInfo["name"])
  965. self.fPluginInfo["label"] = cString(self.fPluginInfo["label"])
  966. self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"])
  967. self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"])
  968. self.reloadInfo()
  969. self.reloadParameters()
  970. self.reloadPrograms()
  971. if not self.ui.scrollArea.isEnabled():
  972. self.resize(self.width(), self.height()-self.ui.scrollArea.height())
  973. def reloadInfo(self):
  974. pluginName = cString(Carla.host.get_real_plugin_name(self.fPluginId))
  975. pluginType = self.fPluginInfo['type']
  976. pluginHints = self.fPluginInfo['hints']
  977. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  978. midiCountInfo = Carla.host.get_midi_port_count_info(self.fPluginId)
  979. paramCountInfo = Carla.host.get_parameter_count_info(self.fPluginId)
  980. if pluginType == PLUGIN_INTERNAL:
  981. self.ui.le_type.setText(self.tr("Internal"))
  982. elif pluginType == PLUGIN_LADSPA:
  983. self.ui.le_type.setText("LADSPA")
  984. elif pluginType == PLUGIN_DSSI:
  985. self.ui.le_type.setText("DSSI")
  986. elif pluginType == PLUGIN_LV2:
  987. self.ui.le_type.setText("LV2")
  988. elif pluginType == PLUGIN_VST:
  989. self.ui.le_type.setText("VST")
  990. elif pluginType == PLUGIN_VST3:
  991. self.ui.le_type.setText("VST3")
  992. elif pluginType == PLUGIN_GIG:
  993. self.ui.le_type.setText("GIG")
  994. elif pluginType == PLUGIN_SF2:
  995. self.ui.le_type.setText("SF2")
  996. elif pluginType == PLUGIN_SFZ:
  997. self.ui.le_type.setText("SFZ")
  998. else:
  999. self.ui.le_type.setText(self.tr("Unknown"))
  1000. self.ui.le_name.setText(pluginName)
  1001. self.ui.le_name.setToolTip(pluginName)
  1002. self.ui.le_label.setText(self.fPluginInfo['label'])
  1003. self.ui.le_label.setToolTip(self.fPluginInfo['label'])
  1004. self.ui.le_maker.setText(self.fPluginInfo['maker'])
  1005. self.ui.le_maker.setToolTip(self.fPluginInfo['maker'])
  1006. self.ui.le_copyright.setText(self.fPluginInfo['copyright'])
  1007. self.ui.le_copyright.setToolTip(self.fPluginInfo['copyright'])
  1008. self.ui.le_unique_id.setText(str(self.fPluginInfo['uniqueId']))
  1009. self.ui.le_unique_id.setToolTip(str(self.fPluginInfo['uniqueId']))
  1010. self.ui.le_ains.setText(str(audioCountInfo['ins']))
  1011. self.ui.le_aouts.setText(str(audioCountInfo['outs']))
  1012. self.ui.le_params.setText(str(paramCountInfo['ins']))
  1013. self.ui.label_plugin.setText("\n%s\n" % self.fPluginInfo['name'])
  1014. self.setWindowTitle(self.fPluginInfo['name'])
  1015. if self.fPluginInfo['latency'] > 0:
  1016. self.ui.le_latency.setText("%i samples" % self.fPluginInfo['latency'])
  1017. else:
  1018. self.ui.le_latency.setText(self.tr("None"))
  1019. self.ui.dial_drywet.setEnabled(pluginHints & PLUGIN_CAN_DRYWET)
  1020. self.ui.dial_vol.setEnabled(pluginHints & PLUGIN_CAN_VOLUME)
  1021. self.ui.dial_b_left.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1022. self.ui.dial_b_right.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1023. self.ui.ch_fixed_buffer.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FIXED_BUFFER)
  1024. self.ui.ch_fixed_buffer.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FIXED_BUFFER)
  1025. self.ui.ch_force_stereo.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FORCE_STEREO)
  1026. self.ui.ch_force_stereo.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FORCE_STEREO)
  1027. self.ui.ch_map_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1028. self.ui.ch_map_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1029. self.ui.ch_use_chunks.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_USE_CHUNKS)
  1030. self.ui.ch_use_chunks.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_USE_CHUNKS)
  1031. self.ui.ch_send_control_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1032. self.ui.ch_send_control_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1033. self.ui.ch_send_channel_pressure.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1034. self.ui.ch_send_channel_pressure.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1035. self.ui.ch_send_note_aftertouch.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1036. self.ui.ch_send_note_aftertouch.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1037. self.ui.ch_send_pitchbend.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1038. self.ui.ch_send_pitchbend.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1039. self.ui.ch_send_all_sound_off.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1040. self.ui.ch_send_all_sound_off.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1041. # Show/hide keyboard
  1042. showKeyboard = (pluginHints & PLUGIN_IS_SYNTH) != 0 or (midiCountInfo['ins'] > 0 < midiCountInfo['outs'])
  1043. self.ui.scrollArea.setEnabled(showKeyboard)
  1044. self.ui.scrollArea.setVisible(showKeyboard)
  1045. # Force-Update parent for new hints
  1046. if self.fRealParent:
  1047. self.fRealParent.recheckPluginHints(pluginHints)
  1048. def reloadParameters(self):
  1049. parameterCount = Carla.host.get_parameter_count(self.fPluginId)
  1050. # Reset
  1051. self.fParameterCount = 0
  1052. self.fParameterList = []
  1053. self.fParametersToUpdate = []
  1054. self.fTabIconCount = 0
  1055. self.fTabIconTimers = []
  1056. # Remove all previous parameters
  1057. for i in range(self.ui.tabWidget.count()-1):
  1058. self.ui.tabWidget.widget(1).deleteLater()
  1059. self.ui.tabWidget.removeTab(1)
  1060. if parameterCount <= 0:
  1061. pass
  1062. elif parameterCount <= Carla.maxParameters:
  1063. paramInputListFull = []
  1064. paramOutputListFull = []
  1065. paramInputList = [] # ([params], width)
  1066. paramInputWidth = 0
  1067. paramOutputList = [] # ([params], width)
  1068. paramOutputWidth = 0
  1069. for i in range(parameterCount):
  1070. paramInfo = Carla.host.get_parameter_info(self.fPluginId, i)
  1071. paramData = Carla.host.get_parameter_data(self.fPluginId, i)
  1072. paramRanges = Carla.host.get_parameter_ranges(self.fPluginId, i)
  1073. if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT):
  1074. continue
  1075. parameter = {
  1076. 'type': paramData['type'],
  1077. 'hints': paramData['hints'],
  1078. 'name': cString(paramInfo['name']),
  1079. 'unit': cString(paramInfo['unit']),
  1080. 'scalePoints': [],
  1081. 'index': paramData['index'],
  1082. 'default': paramRanges['def'],
  1083. 'minimum': paramRanges['min'],
  1084. 'maximum': paramRanges['max'],
  1085. 'step': paramRanges['step'],
  1086. 'stepSmall': paramRanges['stepSmall'],
  1087. 'stepLarge': paramRanges['stepLarge'],
  1088. 'midiCC': paramData['midiCC'],
  1089. 'midiChannel': paramData['midiChannel'],
  1090. 'current': Carla.host.get_current_parameter_value(self.fPluginId, i)
  1091. }
  1092. for j in range(paramInfo['scalePointCount']):
  1093. scalePointInfo = Carla.host.get_parameter_scalepoint_info(self.fPluginId, i, j)
  1094. scalePointLabel = cString(scalePointInfo['label'])
  1095. scalePointLabel = scalePointLabel[:50] + (scalePointLabel[50:] and "...")
  1096. parameter['scalePoints'].append({
  1097. 'value': scalePointInfo['value'],
  1098. 'label': cString(scalePointInfo['label'])
  1099. })
  1100. parameter['name'] = parameter['name'][:30] + (parameter['name'][30:] and "...")
  1101. # -----------------------------------------------------------------
  1102. # Get width values, in packs of 10
  1103. if parameter['type'] == PARAMETER_INPUT:
  1104. paramInputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1105. if paramInputWidthTMP > paramInputWidth:
  1106. paramInputWidth = paramInputWidthTMP
  1107. paramInputList.append(parameter)
  1108. if len(paramInputList) == 10:
  1109. paramInputListFull.append((paramInputList, paramInputWidth))
  1110. paramInputList = []
  1111. paramInputWidth = 0
  1112. else:
  1113. paramOutputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1114. if paramOutputWidthTMP > paramOutputWidth:
  1115. paramOutputWidth = paramOutputWidthTMP
  1116. paramOutputList.append(parameter)
  1117. if len(paramOutputList) == 10:
  1118. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1119. paramOutputList = []
  1120. paramOutputWidth = 0
  1121. # for i in range(parameterCount)
  1122. else:
  1123. # Final page width values
  1124. if 0 < len(paramInputList) < 10:
  1125. paramInputListFull.append((paramInputList, paramInputWidth))
  1126. if 0 < len(paramOutputList) < 10:
  1127. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1128. # -----------------------------------------------------------------
  1129. # Create parameter widgets
  1130. self._createParameterWidgets(PARAMETER_INPUT, paramInputListFull, self.tr("Parameters"))
  1131. self._createParameterWidgets(PARAMETER_OUTPUT, paramOutputListFull, self.tr("Outputs"))
  1132. else: # > Carla.maxParameters
  1133. fakeName = self.tr("This plugin has too many parameters to display here!")
  1134. paramFakeListFull = []
  1135. paramFakeList = []
  1136. paramFakeWidth = QFontMetrics(self.font()).width(fakeName)
  1137. parameter = {
  1138. 'type': PARAMETER_UNKNOWN,
  1139. 'hints': 0,
  1140. 'name': fakeName,
  1141. 'unit': "",
  1142. 'scalePoints': [],
  1143. 'index': 0,
  1144. 'default': 0,
  1145. 'minimum': 0,
  1146. 'maximum': 0,
  1147. 'step': 0,
  1148. 'stepSmall': 0,
  1149. 'stepLarge': 0,
  1150. 'midiCC': -1,
  1151. 'midiChannel': 0,
  1152. 'current': 0.0
  1153. }
  1154. paramFakeList.append(parameter)
  1155. paramFakeListFull.append((paramFakeList, paramFakeWidth))
  1156. self._createParameterWidgets(PARAMETER_UNKNOWN, paramFakeListFull, self.tr("Information"))
  1157. def reloadPrograms(self):
  1158. # Programs
  1159. self.ui.cb_programs.blockSignals(True)
  1160. self.ui.cb_programs.clear()
  1161. programCount = Carla.host.get_program_count(self.fPluginId)
  1162. if programCount > 0:
  1163. self.ui.cb_programs.setEnabled(True)
  1164. self.ui.label_programs.setEnabled(True)
  1165. for i in range(programCount):
  1166. pName = cString(Carla.host.get_program_name(self.fPluginId, i))
  1167. pName = pName[:40] + (pName[40:] and "...")
  1168. self.ui.cb_programs.addItem(pName)
  1169. self.fCurrentProgram = Carla.host.get_current_program_index(self.fPluginId)
  1170. self.ui.cb_programs.setCurrentIndex(self.fCurrentProgram)
  1171. else:
  1172. self.fCurrentProgram = -1
  1173. self.ui.cb_programs.setEnabled(False)
  1174. self.ui.label_programs.setEnabled(False)
  1175. self.ui.cb_programs.blockSignals(False)
  1176. # MIDI Programs
  1177. self.ui.cb_midi_programs.blockSignals(True)
  1178. self.ui.cb_midi_programs.clear()
  1179. midiProgramCount = Carla.host.get_midi_program_count(self.fPluginId)
  1180. if midiProgramCount > 0:
  1181. self.ui.cb_midi_programs.setEnabled(True)
  1182. self.ui.label_midi_programs.setEnabled(True)
  1183. for i in range(midiProgramCount):
  1184. mpData = Carla.host.get_midi_program_data(self.fPluginId, i)
  1185. mpBank = int(mpData['bank'])
  1186. mpProg = int(mpData['program'])
  1187. mpName = cString(mpData['name'])
  1188. mpName = mpName[:40] + (mpName[40:] and "...")
  1189. self.ui.cb_midi_programs.addItem("%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  1190. self.fCurrentMidiProgram = Carla.host.get_current_midi_program_index(self.fPluginId)
  1191. self.ui.cb_midi_programs.setCurrentIndex(self.fCurrentMidiProgram)
  1192. else:
  1193. self.fCurrentMidiProgram = -1
  1194. self.ui.cb_midi_programs.setEnabled(False)
  1195. self.ui.label_midi_programs.setEnabled(False)
  1196. self.ui.cb_midi_programs.blockSignals(False)
  1197. # Automatically change to Midi Programs tab
  1198. if midiProgramCount > 0 and programCount == 0:
  1199. self.ui.tab_programs.setCurrentIndex(1)
  1200. def updateInfo(self):
  1201. # Update current program text
  1202. if self.ui.cb_programs.count() > 0:
  1203. pIndex = self.ui.cb_programs.currentIndex()
  1204. pName = cString(Carla.host.get_program_name(self.fPluginId, pIndex))
  1205. pName = pName[:40] + (pName[40:] and "...")
  1206. self.ui.cb_programs.setItemText(pIndex, pName)
  1207. # Update current midi program text
  1208. if self.ui.cb_midi_programs.count() > 0:
  1209. mpIndex = self.ui.cb_midi_programs.currentIndex()
  1210. mpData = Carla.host.get_midi_program_data(self.fPluginId, mpIndex)
  1211. mpBank = int(mpData['bank'])
  1212. mpProg = int(mpData['program'])
  1213. mpName = cString(mpData['name'])
  1214. mpName = mpName[:40] + (mpName[40:] and "...")
  1215. self.ui.cb_midi_programs.setItemText(mpIndex, "%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  1216. # Update all parameter values
  1217. for paramType, paramId, paramWidget in self.fParameterList:
  1218. paramWidget.setValue(Carla.host.get_current_parameter_value(self.fPluginId, paramId), False)
  1219. paramWidget.update()
  1220. def setParameterValue(self, parameterId, value):
  1221. for paramItem in self.fParametersToUpdate:
  1222. if paramItem[0] == parameterId:
  1223. paramItem[1] = value
  1224. break
  1225. else:
  1226. self.fParametersToUpdate.append([parameterId, value])
  1227. def setParameterDefault(self, parameterId, value):
  1228. for paramType, paramId, paramWidget in self.fParameterList:
  1229. if paramId == parameterId:
  1230. paramWidget.setDefault(value)
  1231. break
  1232. def setParameterMidiControl(self, parameterId, control):
  1233. for paramType, paramId, paramWidget in self.fParameterList:
  1234. if paramId == parameterId:
  1235. paramWidget.setMidiControl(control)
  1236. break
  1237. def setParameterMidiChannel(self, parameterId, channel):
  1238. for paramType, paramId, paramWidget in self.fParameterList:
  1239. if paramId == parameterId:
  1240. paramWidget.setMidiChannel(channel)
  1241. break
  1242. def setProgram(self, index):
  1243. self.ui.cb_programs.blockSignals(True)
  1244. self.ui.cb_programs.setCurrentIndex(index)
  1245. self.ui.cb_programs.blockSignals(False)
  1246. def setMidiProgram(self, index):
  1247. self.ui.cb_midi_programs.blockSignals(True)
  1248. self.ui.cb_midi_programs.setCurrentIndex(index)
  1249. self.ui.cb_midi_programs.blockSignals(False)
  1250. def sendNoteOn(self, channel, note):
  1251. if self.fControlChannel == channel:
  1252. self.ui.keyboard.sendNoteOn(note, False)
  1253. def sendNoteOff(self, channel, note):
  1254. if self.fControlChannel == channel:
  1255. self.ui.keyboard.sendNoteOff(note, False)
  1256. def setVisible(self, yesNo):
  1257. if yesNo:
  1258. if not self.fGeometry.isNull():
  1259. self.restoreGeometry(self.fGeometry)
  1260. else:
  1261. self.fGeometry = self.saveGeometry()
  1262. QDialog.setVisible(self, yesNo)
  1263. def idleSlow(self):
  1264. # Check Tab icons
  1265. for i in range(len(self.fTabIconTimers)):
  1266. if self.fTabIconTimers[i] == ICON_STATE_ON:
  1267. self.fTabIconTimers[i] = ICON_STATE_WAIT
  1268. elif self.fTabIconTimers[i] == ICON_STATE_WAIT:
  1269. self.fTabIconTimers[i] = ICON_STATE_OFF
  1270. elif self.fTabIconTimers[i] == ICON_STATE_OFF:
  1271. self.fTabIconTimers[i] = ICON_STATE_NULL
  1272. self.ui.tabWidget.setTabIcon(i+1, self.fTabIconOff)
  1273. # Check parameters needing update
  1274. for index, value in self.fParametersToUpdate:
  1275. if index == PARAMETER_DRYWET:
  1276. self.ui.dial_drywet.blockSignals(True)
  1277. self.ui.dial_drywet.setValue(value * 1000)
  1278. self.ui.dial_drywet.blockSignals(False)
  1279. elif index == PARAMETER_VOLUME:
  1280. self.ui.dial_vol.blockSignals(True)
  1281. self.ui.dial_vol.setValue(value * 1000)
  1282. self.ui.dial_vol.blockSignals(False)
  1283. elif index == PARAMETER_BALANCE_LEFT:
  1284. self.ui.dial_b_left.blockSignals(True)
  1285. self.ui.dial_b_left.setValue(value * 1000)
  1286. self.ui.dial_b_left.blockSignals(False)
  1287. elif index == PARAMETER_BALANCE_RIGHT:
  1288. self.ui.dial_b_right.blockSignals(True)
  1289. self.ui.dial_b_right.setValue(value * 1000)
  1290. self.ui.dial_b_right.blockSignals(False)
  1291. elif index == PARAMETER_PANNING:
  1292. pass
  1293. #self.ui.dial_pan.blockSignals(True)
  1294. #self.ui.dial_pan.setValue(value * 1000, True, False)
  1295. #self.ui.dial_pan.blockSignals(False)
  1296. elif index == PARAMETER_CTRL_CHANNEL:
  1297. self.fControlChannel = int(value)
  1298. self.ui.sb_ctrl_channel.blockSignals(True)
  1299. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  1300. self.ui.sb_ctrl_channel.blockSignals(False)
  1301. self.ui.keyboard.allNotesOff()
  1302. elif index >= 0:
  1303. for paramType, paramId, paramWidget in self.fParameterList:
  1304. if paramId == index:
  1305. paramWidget.setValue(value, False)
  1306. if paramType == PARAMETER_INPUT:
  1307. tabIndex = paramWidget.tabIndex()
  1308. if self.fTabIconTimers[tabIndex-1] == ICON_STATE_NULL:
  1309. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOn)
  1310. self.fTabIconTimers[tabIndex-1] = ICON_STATE_ON
  1311. break
  1312. # Clear all parameters
  1313. self.fParametersToUpdate = []
  1314. # Update parameter outputs
  1315. for paramType, paramId, paramWidget in self.fParameterList:
  1316. if paramType == PARAMETER_OUTPUT:
  1317. value = Carla.host.get_current_parameter_value(self.fPluginId, paramId)
  1318. paramWidget.setValue(value, False)
  1319. @pyqtSlot()
  1320. def slot_saveState(self):
  1321. if self.fCurrentStateFilename:
  1322. askTry = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  1323. if askTry == QMessageBox.Ok:
  1324. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1325. self.fCurrentStateFilename = None
  1326. fileFilter = self.tr("Carla State File (*.carxs)")
  1327. filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Plugin State File"), filter=fileFilter)
  1328. if filenameTry:
  1329. if not filenameTry.endswith(".carxs"):
  1330. filenameTry += ".carxs"
  1331. self.fCurrentStateFilename = filenameTry
  1332. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1333. @pyqtSlot()
  1334. def slot_loadState(self):
  1335. fileFilter = self.tr("Carla State File (*.carxs)")
  1336. filenameTry = QFileDialog.getOpenFileName(self, self.tr("Open Plugin State File"), filter=fileFilter)
  1337. if filenameTry:
  1338. self.fCurrentStateFilename = filenameTry
  1339. Carla.host.load_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1340. @pyqtSlot(bool)
  1341. def slot_optionChanged(self, clicked):
  1342. sender = self.sender()
  1343. if sender == self.ui.ch_fixed_buffer:
  1344. option = PLUGIN_OPTION_FIXED_BUFFER
  1345. elif sender == self.ui.ch_force_stereo:
  1346. option = PLUGIN_OPTION_FORCE_STEREO
  1347. elif sender == self.ui.ch_map_program_changes:
  1348. option = PLUGIN_OPTION_MAP_PROGRAM_CHANGES
  1349. elif sender == self.ui.ch_use_chunks:
  1350. option = PLUGIN_OPTION_USE_CHUNKS
  1351. elif sender == self.ui.ch_send_control_changes:
  1352. option = PLUGIN_OPTION_SEND_CONTROL_CHANGES
  1353. elif sender == self.ui.ch_send_channel_pressure:
  1354. option = PLUGIN_OPTION_SEND_CHANNEL_PRESSURE
  1355. elif sender == self.ui.ch_send_note_aftertouch:
  1356. option = PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH
  1357. elif sender == self.ui.ch_send_pitchbend:
  1358. option = PLUGIN_OPTION_SEND_PITCHBEND
  1359. elif sender == self.ui.ch_send_all_sound_off:
  1360. option = PLUGIN_OPTION_SEND_ALL_SOUND_OFF
  1361. else:
  1362. return
  1363. Carla.host.set_option(self.fPluginId, option, clicked)
  1364. @pyqtSlot(int)
  1365. def slot_dryWetChanged(self, value):
  1366. Carla.host.set_drywet(self.fPluginId, float(value)/1000)
  1367. @pyqtSlot(int)
  1368. def slot_volumeChanged(self, value):
  1369. Carla.host.set_volume(self.fPluginId, float(value)/1000)
  1370. @pyqtSlot(int)
  1371. def slot_balanceLeftChanged(self, value):
  1372. Carla.host.set_balance_left(self.fPluginId, float(value)/1000)
  1373. @pyqtSlot(int)
  1374. def slot_balanceRightChanged(self, value):
  1375. Carla.host.set_balance_right(self.fPluginId, float(value)/1000)
  1376. @pyqtSlot(int)
  1377. def slot_panningChanged(self, value):
  1378. Carla.host.set_panning(self.fPluginId, float(value)/1000)
  1379. @pyqtSlot(int)
  1380. def slot_ctrlChannelChanged(self, value):
  1381. self.fControlChannel = value-1
  1382. Carla.host.set_ctrl_channel(self.fPluginId, self.fControlChannel)
  1383. self.ui.keyboard.allNotesOff()
  1384. @pyqtSlot(int, float)
  1385. def slot_parameterValueChanged(self, parameterId, value):
  1386. Carla.host.set_parameter_value(self.fPluginId, parameterId, value)
  1387. @pyqtSlot(int, int)
  1388. def slot_parameterMidiControlChanged(self, parameterId, control):
  1389. Carla.host.set_parameter_midi_cc(self.fPluginId, parameterId, control)
  1390. @pyqtSlot(int, int)
  1391. def slot_parameterMidiChannelChanged(self, parameterId, channel):
  1392. Carla.host.set_parameter_midi_channel(self.fPluginId, parameterId, channel-1)
  1393. @pyqtSlot(int)
  1394. def slot_programIndexChanged(self, index):
  1395. if self.fCurrentProgram != index:
  1396. self.fCurrentProgram = index
  1397. Carla.host.set_program(self.fPluginId, index)
  1398. @pyqtSlot(int)
  1399. def slot_midiProgramIndexChanged(self, index):
  1400. if self.fCurrentMidiProgram != index:
  1401. self.fCurrentMidiProgram = index
  1402. Carla.host.set_midi_program(self.fPluginId, index)
  1403. @pyqtSlot(int)
  1404. def slot_noteOn(self, note):
  1405. if self.fControlChannel >= 0:
  1406. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 100)
  1407. @pyqtSlot(int)
  1408. def slot_noteOff(self, note):
  1409. if self.fControlChannel >= 0:
  1410. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 0)
  1411. @pyqtSlot()
  1412. def slot_notesOn(self):
  1413. if self.fRealParent:
  1414. self.fRealParent.ui.led_midi.setChecked(True)
  1415. @pyqtSlot()
  1416. def slot_notesOff(self):
  1417. if self.fRealParent:
  1418. self.fRealParent.ui.led_midi.setChecked(False)
  1419. @pyqtSlot()
  1420. def slot_finished(self):
  1421. if self.fRealParent:
  1422. self.fRealParent.editClosed()
  1423. @pyqtSlot()
  1424. def slot_showCustomDialMenu(self):
  1425. dialName = self.sender().objectName()
  1426. if dialName == "dial_drywet":
  1427. minimum = 0
  1428. maximum = 100
  1429. default = 100
  1430. label = "Dry/Wet"
  1431. elif dialName == "dial_vol":
  1432. minimum = 0
  1433. maximum = 127
  1434. default = 100
  1435. label = "Volume"
  1436. elif dialName == "dial_b_left":
  1437. minimum = -100
  1438. maximum = 100
  1439. default = -100
  1440. label = "Balance-Left"
  1441. elif dialName == "dial_b_right":
  1442. minimum = -100
  1443. maximum = 100
  1444. default = 100
  1445. label = "Balance-Right"
  1446. elif dialName == "dial_panning":
  1447. minimum = -100
  1448. maximum = 100
  1449. default = 0
  1450. label = "Panning"
  1451. else:
  1452. minimum = 0
  1453. maximum = 100
  1454. default = 100
  1455. label = "Unknown"
  1456. current = self.sender().value() / 10
  1457. menu = QMenu(self)
  1458. actReset = menu.addAction(self.tr("Reset (%i%%)" % default))
  1459. menu.addSeparator()
  1460. actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % minimum))
  1461. actCenter = menu.addAction(self.tr("Set to Center"))
  1462. actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % maximum))
  1463. menu.addSeparator()
  1464. actSet = menu.addAction(self.tr("Set value..."))
  1465. if label not in ("Balance-Left", "Balance-Right"):
  1466. menu.removeAction(actCenter)
  1467. actSelected = menu.exec_(QCursor.pos())
  1468. if actSelected == actSet:
  1469. valueTry = QInputDialog.getInteger(self, self.tr("Set value"), label, current, minimum, maximum, 1)
  1470. if valueTry[1]:
  1471. value = valueTry[0] * 10
  1472. else:
  1473. return
  1474. elif actSelected == actMinimum:
  1475. value = minimum * 10
  1476. elif actSelected == actMaximum:
  1477. value = maximum * 10
  1478. elif actSelected == actReset:
  1479. value = default * 10
  1480. elif actSelected == actCenter:
  1481. value = 0
  1482. else:
  1483. return
  1484. if label == "Dry/Wet":
  1485. self.ui.dial_drywet.setValue(value)
  1486. elif label == "Volume":
  1487. self.ui.dial_vol.setValue(value)
  1488. elif label == "Balance-Left":
  1489. self.ui.dial_b_left.setValue(value)
  1490. elif label == "Balance-Right":
  1491. self.ui.dial_b_right.setValue(value)
  1492. elif label == "Panning":
  1493. pass
  1494. #self.ui.dial_panning.setValue(value)
  1495. def _createParameterWidgets(self, paramType, paramListFull, tabPageName):
  1496. i = 1
  1497. for paramList, width in paramListFull:
  1498. if len(paramList) == 0:
  1499. break
  1500. tabIndex = self.ui.tabWidget.count()
  1501. tabPageContainer = QWidget(self.ui.tabWidget)
  1502. tabPageLayout = QVBoxLayout(tabPageContainer)
  1503. tabPageContainer.setLayout(tabPageLayout)
  1504. for paramInfo in paramList:
  1505. paramWidget = PluginParameter(tabPageContainer, paramInfo, self.fPluginId, tabIndex)
  1506. paramWidget.setLabelWidth(width)
  1507. tabPageLayout.addWidget(paramWidget)
  1508. self.fParameterList.append((paramType, paramInfo['index'], paramWidget))
  1509. if paramType == PARAMETER_INPUT:
  1510. self.connect(paramWidget, SIGNAL("valueChanged(int, double)"), SLOT("slot_parameterValueChanged(int, double)"))
  1511. self.connect(paramWidget, SIGNAL("midiControlChanged(int, int)"), SLOT("slot_parameterMidiControlChanged(int, int)"))
  1512. self.connect(paramWidget, SIGNAL("midiChannelChanged(int, int)"), SLOT("slot_parameterMidiChannelChanged(int, int)"))
  1513. tabPageLayout.addStretch()
  1514. self.ui.tabWidget.addTab(tabPageContainer, "%s (%i)" % (tabPageName, i))
  1515. i += 1
  1516. if paramType == PARAMETER_INPUT:
  1517. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOff)
  1518. self.fTabIconTimers.append(ICON_STATE_NULL)
  1519. def showEvent(self, event):
  1520. if not self.fScrollAreaSetup:
  1521. self.fScrollAreaSetup = True
  1522. minHeight = self.ui.scrollArea.height()+2
  1523. self.ui.scrollArea.setMinimumHeight(minHeight)
  1524. self.ui.scrollArea.setMaximumHeight(minHeight)
  1525. QDialog.showEvent(self, event)
  1526. def done(self, r):
  1527. QDialog.done(self, r)
  1528. self.close()
  1529. # ------------------------------------------------------------------------------------------------------------
  1530. # Plugin Widget
  1531. class PluginWidget(QFrame):
  1532. def __init__(self, parent, pluginId):
  1533. QFrame.__init__(self, parent)
  1534. self.ui = ui_carla_plugin.Ui_PluginWidget()
  1535. self.ui.setupUi(self)
  1536. self.fLastGreenLedState = False
  1537. self.fLastBlueLedState = False
  1538. self.fParameterIconTimer = ICON_STATE_NULL
  1539. self.fPluginId = pluginId
  1540. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  1541. self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"])
  1542. self.fPluginInfo["name"] = cString(self.fPluginInfo["name"])
  1543. self.fPluginInfo["label"] = cString(self.fPluginInfo["label"])
  1544. self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"])
  1545. self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"])
  1546. if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK:
  1547. self.fPeaksInputCount = 2
  1548. self.fPeaksOutputCount = 2
  1549. else:
  1550. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  1551. self.fPeaksInputCount = int(audioCountInfo['ins'])
  1552. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  1553. if self.fPeaksInputCount > 2:
  1554. self.fPeaksInputCount = 2
  1555. if self.fPeaksOutputCount > 2:
  1556. self.fPeaksOutputCount = 2
  1557. # Background
  1558. self.fColorTop = QColor(60, 60, 60)
  1559. self.fColorBottom = QColor(47, 47, 47)
  1560. self.fColorSeprtr = QColor(70, 70, 70)
  1561. self.setStyleSheet("""
  1562. QLabel#label_name {
  1563. color: #BBB;
  1564. }""")
  1565. # Colorify
  1566. #if self.m_pluginInfo['category'] == PLUGIN_CATEGORY_SYNTH:
  1567. #self.setWidgetColor(PALETTE_COLOR_WHITE)
  1568. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  1569. #self.setWidgetColor(PALETTE_COLOR_ORANGE)
  1570. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_EQ:
  1571. #self.setWidgetColor(PALETTE_COLOR_GREEN)
  1572. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  1573. #self.setWidgetColor(PALETTE_COLOR_BLUE)
  1574. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS:
  1575. #self.setWidgetColor(PALETTE_COLOR_PINK)
  1576. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR:
  1577. #self.setWidgetColor(PALETTE_COLOR_RED)
  1578. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_UTILITY:
  1579. #self.setWidgetColor(PALETTE_COLOR_YELLOW)
  1580. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_OTHER:
  1581. #self.setWidgetColor(PALETTE_COLOR_BROWN)
  1582. #else:
  1583. #self.setWidgetColor(PALETTE_COLOR_NONE)
  1584. self.ui.b_enable.setPixmaps(":/bitmaps/led_red.png", ":/bitmaps/led_green.png", ":/bitmaps/led_red.png")
  1585. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  1586. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1587. self.ui.led_control.setColor(self.ui.led_control.YELLOW)
  1588. self.ui.led_control.setEnabled(False)
  1589. self.ui.led_midi.setColor(self.ui.led_midi.RED)
  1590. self.ui.led_midi.setEnabled(False)
  1591. self.ui.led_audio_in.setColor(self.ui.led_audio_in.GREEN)
  1592. self.ui.led_audio_in.setEnabled(False)
  1593. self.ui.led_audio_out.setColor(self.ui.led_audio_out.BLUE)
  1594. self.ui.led_audio_out.setEnabled(False)
  1595. self.ui.peak_in.setColor(self.ui.peak_in.GREEN)
  1596. self.ui.peak_in.setChannels(self.fPeaksInputCount)
  1597. self.ui.peak_in.setOrientation(self.ui.peak_in.HORIZONTAL)
  1598. self.ui.peak_out.setColor(self.ui.peak_in.BLUE)
  1599. self.ui.peak_out.setChannels(self.fPeaksOutputCount)
  1600. self.ui.peak_out.setOrientation(self.ui.peak_out.HORIZONTAL)
  1601. self.ui.label_name.setText(self.fPluginInfo['name'])
  1602. self.ui.edit_dialog = PluginEdit(self, self.fPluginId)
  1603. self.ui.edit_dialog.hide()
  1604. self.connect(self, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomMenu()"))
  1605. self.connect(self.ui.b_enable, SIGNAL("clicked(bool)"), SLOT("slot_setActive(bool)"))
  1606. self.connect(self.ui.b_gui, SIGNAL("clicked(bool)"), SLOT("slot_guiClicked(bool)"))
  1607. self.connect(self.ui.b_edit, SIGNAL("clicked(bool)"), SLOT("slot_editClicked(bool)"))
  1608. self.setMinimumHeight(32)
  1609. self.setMaximumHeight(32)
  1610. def idleFast(self):
  1611. # Input peaks
  1612. if self.fPeaksInputCount > 0:
  1613. if self.fPeaksInputCount > 1:
  1614. peak1 = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1615. peak2 = Carla.host.get_input_peak_value(self.fPluginId, 2)
  1616. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1617. self.ui.peak_in.displayMeter(1, peak1)
  1618. self.ui.peak_in.displayMeter(2, peak2)
  1619. else:
  1620. peak = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1621. ledState = bool(peak != 0.0)
  1622. self.ui.peak_in.displayMeter(1, peak)
  1623. if self.fLastGreenLedState != ledState:
  1624. self.fLastGreenLedState = ledState
  1625. self.ui.led_audio_in.setChecked(ledState)
  1626. # Output peaks
  1627. if self.fPeaksOutputCount > 0:
  1628. if self.fPeaksOutputCount > 1:
  1629. peak1 = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1630. peak2 = Carla.host.get_output_peak_value(self.fPluginId, 2)
  1631. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1632. self.ui.peak_out.displayMeter(1, peak1)
  1633. self.ui.peak_out.displayMeter(2, peak2)
  1634. else:
  1635. peak = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1636. ledState = bool(peak != 0.0)
  1637. self.ui.peak_out.displayMeter(1, peak)
  1638. if self.fLastBlueLedState != ledState:
  1639. self.fLastBlueLedState = ledState
  1640. self.ui.led_audio_out.setChecked(ledState)
  1641. def idleSlow(self):
  1642. # Parameter Activity LED
  1643. if self.fParameterIconTimer == ICON_STATE_ON:
  1644. self.fParameterIconTimer = ICON_STATE_WAIT
  1645. self.ui.led_control.setChecked(True)
  1646. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  1647. self.fParameterIconTimer = ICON_STATE_OFF
  1648. elif self.fParameterIconTimer == ICON_STATE_OFF:
  1649. self.fParameterIconTimer = ICON_STATE_NULL
  1650. self.ui.led_control.setChecked(False)
  1651. # Update edit dialog
  1652. self.ui.edit_dialog.idleSlow()
  1653. def editClosed(self):
  1654. self.ui.b_edit.setChecked(False)
  1655. def recheckPluginHints(self, hints):
  1656. self.fPluginInfo['hints'] = hints
  1657. self.ui.b_gui.setEnabled(hints & PLUGIN_HAS_GUI)
  1658. def setActive(self, active, sendGui=False, sendCallback=True):
  1659. if sendGui: self.ui.b_enable.setChecked(active)
  1660. if sendCallback: Carla.host.set_active(self.fPluginId, active)
  1661. if active:
  1662. self.ui.edit_dialog.ui.keyboard.allNotesOff()
  1663. def setParameterDefault(self, parameterId, value):
  1664. self.ui.edit_dialog.setParameterDefault(parameterId, value)
  1665. def setParameterValue(self, parameterId, value):
  1666. self.fParameterIconTimer = ICON_STATE_ON
  1667. if parameterId == PARAMETER_ACTIVE:
  1668. return self.setActive(bool(value), True, False)
  1669. self.ui.edit_dialog.setParameterValue(parameterId, value)
  1670. def setParameterMidiControl(self, parameterId, control):
  1671. self.ui.edit_dialog.setParameterMidiControl(parameterId, control)
  1672. def setParameterMidiChannel(self, parameterId, channel):
  1673. self.ui.edit_dialog.setParameterMidiChannel(parameterId, channel)
  1674. def setProgram(self, index):
  1675. self.fParameterIconTimer = ICON_STATE_ON
  1676. self.ui.edit_dialog.setProgram(index)
  1677. def setMidiProgram(self, index):
  1678. self.fParameterIconTimer = ICON_STATE_ON
  1679. self.ui.edit_dialog.setMidiProgram(index)
  1680. def sendNoteOn(self, channel, note):
  1681. self.ui.edit_dialog.sendNoteOn(channel, note)
  1682. def sendNoteOff(self, channel, note):
  1683. self.ui.edit_dialog.sendNoteOff(channel, note)
  1684. def setId(self, idx):
  1685. self.fPluginId = idx
  1686. self.ui.edit_dialog.fPluginId = idx
  1687. def setRefreshRate(self, rate):
  1688. self.ui.peak_in.setRefreshRate(rate)
  1689. self.ui.peak_out.setRefreshRate(rate)
  1690. def paintEvent(self, event):
  1691. painter = QPainter(self)
  1692. painter.save()
  1693. areaX = self.ui.area_right.x()
  1694. painter.setPen(self.fColorSeprtr.lighter(110))
  1695. painter.setBrush(self.fColorBottom)
  1696. painter.setRenderHint(QPainter.Antialiasing, True)
  1697. # name -> leds arc
  1698. path = QPainterPath()
  1699. path.moveTo(areaX-20, self.height()-4)
  1700. path.cubicTo(areaX+5, self.height()-5, areaX-20, 4.75, areaX+20, 4.75)
  1701. path.lineTo(areaX+20, self.height()-5)
  1702. painter.drawPath(path)
  1703. painter.setPen(self.fColorSeprtr)
  1704. painter.setRenderHint(QPainter.Antialiasing, False)
  1705. # separator lines
  1706. painter.drawLine(0, self.height()-5, areaX-20, self.height()-5)
  1707. painter.drawLine(areaX+20, 4, self.width(), 4)
  1708. painter.setPen(self.fColorBottom)
  1709. painter.setBrush(self.fColorBottom)
  1710. # top, bottom and left lines
  1711. painter.drawLine(0, 0, self.width(), 0)
  1712. painter.drawRect(0, self.height()-4, areaX, 4)
  1713. painter.drawRoundedRect(areaX-20, self.height()-5, areaX+20, 5, 22, 22)
  1714. painter.drawLine(0, 0, 0, self.height())
  1715. # fill the rest
  1716. painter.drawRect(areaX+19, 5, self.width(), self.height())
  1717. # bottom 1px line
  1718. painter.setPen(self.fColorSeprtr)
  1719. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  1720. painter.restore()
  1721. QFrame.paintEvent(self, event)
  1722. @pyqtSlot()
  1723. def slot_showCustomMenu(self):
  1724. menu = QMenu(self)
  1725. actActive = menu.addAction(self.tr("Disable") if self.ui.b_enable.isChecked() else self.tr("Enable"))
  1726. menu.addSeparator()
  1727. actGui = menu.addAction(self.tr("Show GUI"))
  1728. actGui.setCheckable(True)
  1729. actGui.setChecked(self.ui.b_gui.isChecked())
  1730. actGui.setEnabled(self.ui.b_gui.isEnabled())
  1731. actEdit = menu.addAction(self.tr("Edit"))
  1732. actEdit.setCheckable(True)
  1733. actEdit.setChecked(self.ui.b_edit.isChecked())
  1734. menu.addSeparator()
  1735. actClone = menu.addAction(self.tr("Clone"))
  1736. actRemove = menu.addAction(self.tr("Remove"))
  1737. actSel = menu.exec_(QCursor.pos())
  1738. if not actSel:
  1739. return
  1740. if actSel == actActive:
  1741. self.setActive(not self.ui.b_enable.isChecked(), True, True)
  1742. elif actSel == actGui:
  1743. self.ui.b_gui.click()
  1744. elif actSel == actEdit:
  1745. self.ui.b_edit.click()
  1746. elif actSel == actClone:
  1747. if not Carla.host.clone_plugin(self.fPluginId):
  1748. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1749. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1750. elif actSel == actRemove:
  1751. if not Carla.host.remove_plugin(self.fPluginId):
  1752. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1753. cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok)
  1754. @pyqtSlot(bool)
  1755. def slot_setActive(self, yesNo):
  1756. self.setActive(yesNo, False, True)
  1757. @pyqtSlot(bool)
  1758. def slot_guiClicked(self, show):
  1759. Carla.host.show_gui(self.fPluginId, show)
  1760. @pyqtSlot(bool)
  1761. def slot_editClicked(self, show):
  1762. self.ui.edit_dialog.setVisible(show)
  1763. # ------------------------------------------------------------------------------------------------------------
  1764. # Separate Thread for Plugin Search
  1765. class SearchPluginsThread(QThread):
  1766. def __init__(self, parent):
  1767. QThread.__init__(self, parent)
  1768. self.fCheckNative = False
  1769. self.fCheckPosix32 = False
  1770. self.fCheckPosix64 = False
  1771. self.fCheckWin32 = False
  1772. self.fCheckWin64 = False
  1773. self.fCheckLADSPA = False
  1774. self.fCheckDSSI = False
  1775. self.fCheckLV2 = False
  1776. self.fCheckVST = False
  1777. self.fCheckGIG = False
  1778. self.fCheckSF2 = False
  1779. self.fCheckSFZ = False
  1780. self.fToolNative = carla_discovery_native
  1781. self.fCurCount = 0
  1782. self.fCurPercentValue = 0
  1783. self.fLastCheckValue = 0
  1784. self.fSomethingChanged = False
  1785. def somethingChanged(self):
  1786. return self.fSomethingChanged
  1787. def skipPlugin(self):
  1788. # TODO - windows and mac support
  1789. apps = " carla-discovery"
  1790. apps += " carla-discovery-native"
  1791. apps += " carla-discovery-posix32"
  1792. apps += " carla-discovery-posix64"
  1793. apps += " carla-discovery-win32.exe"
  1794. apps += " carla-discovery-win64.exe"
  1795. if LINUX:
  1796. os.system("killall -KILL %s" % apps)
  1797. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  1798. self.fCheckNative = native
  1799. self.fCheckPosix32 = posix32
  1800. self.fCheckPosix64 = posix64
  1801. self.fCheckWin32 = win32
  1802. self.fCheckWin64 = win64
  1803. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst, gig, sf2, sfz):
  1804. self.fCheckLADSPA = ladspa
  1805. self.fCheckDSSI = dssi
  1806. self.fCheckLV2 = lv2
  1807. self.fCheckVST = vst
  1808. self.fCheckGIG = gig
  1809. self.fCheckSF2 = sf2
  1810. self.fCheckSFZ = sfz
  1811. def setSearchToolNative(self, tool):
  1812. self.fToolNative = tool
  1813. def run(self):
  1814. self.fCurCount = 0
  1815. pluginCount = 0
  1816. settingsDB = QSettings("falkTX", "CarlaPlugins")
  1817. if self.fCheckLADSPA: pluginCount += 1
  1818. if self.fCheckDSSI: pluginCount += 1
  1819. if self.fCheckLV2: pluginCount += 1
  1820. if self.fCheckVST: pluginCount += 1
  1821. if self.fCheckNative:
  1822. self.fCurCount += pluginCount
  1823. if self.fCheckPosix32:
  1824. self.fCurCount += pluginCount
  1825. if self.fCheckPosix64:
  1826. self.fCurCount += pluginCount
  1827. if self.fCheckWin32:
  1828. self.fCurCount += pluginCount
  1829. if self.fCheckWin64:
  1830. self.fCurCount += pluginCount
  1831. if self.fToolNative:
  1832. if self.fCheckGIG: self.fCurCount += 1
  1833. if self.fCheckSF2: self.fCurCount += 1
  1834. if self.fCheckSFZ: self.fCurCount += 1
  1835. else:
  1836. self.fCheckGIG = False
  1837. self.fCheckSF2 = False
  1838. self.fCheckSFZ = False
  1839. if self.fCurCount == 0:
  1840. return
  1841. self.fCurPercentValue = 100 / self.fCurCount
  1842. self.fLastCheckValue = 0
  1843. if HAIKU:
  1844. OS = "HAIKU"
  1845. elif LINUX:
  1846. OS = "LINUX"
  1847. elif MACOS:
  1848. OS = "MACOS"
  1849. elif WINDOWS:
  1850. OS = "WINDOWS"
  1851. else:
  1852. OS = "UNKNOWN"
  1853. if self.fCheckLADSPA:
  1854. checkValue = 0
  1855. if haveLRDF:
  1856. if self.fCheckNative: checkValue += 0.1
  1857. if self.fCheckPosix32: checkValue += 0.1
  1858. if self.fCheckPosix64: checkValue += 0.1
  1859. if self.fCheckWin32: checkValue += 0.1
  1860. if self.fCheckWin64: checkValue += 0.1
  1861. rdfPadValue = self.fCurPercentValue * checkValue
  1862. if self.fCheckNative:
  1863. self._checkLADSPA(OS, self.fToolNative)
  1864. settingsDB.setValue("Plugins/LADSPA_native", self.fLadspaPlugins)
  1865. settingsDB.sync()
  1866. if self.fCheckPosix32:
  1867. self._checkLADSPA(OS, carla_discovery_posix32)
  1868. settingsDB.setValue("Plugins/LADSPA_posix32", self.fLadspaPlugins)
  1869. settingsDB.sync()
  1870. if self.fCheckPosix64:
  1871. self._checkLADSPA(OS, carla_discovery_posix64)
  1872. settingsDB.setValue("Plugins/LADSPA_posix64", self.fLadspaPlugins)
  1873. settingsDB.sync()
  1874. if self.fCheckWin32:
  1875. self._checkLADSPA("WINDOWS", carla_discovery_win32, not WINDOWS)
  1876. settingsDB.setValue("Plugins/LADSPA_win32", self.fLadspaPlugins)
  1877. settingsDB.sync()
  1878. if self.fCheckWin64:
  1879. self._checkLADSPA("WINDOWS", carla_discovery_win64, not WINDOWS)
  1880. settingsDB.setValue("Plugins/LADSPA_win64", self.fLadspaPlugins)
  1881. settingsDB.sync()
  1882. if haveLRDF and checkValue > 0:
  1883. startValue = self.fLastCheckValue - rdfPadValue
  1884. self._pluginLook(startValue, "LADSPA RDFs...")
  1885. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  1886. SettingsDir = os.path.join(HOME, ".config", "falkTX")
  1887. fLadspa = open(os.path.join(SettingsDir, "ladspa_rdf.db"), 'w')
  1888. json.dump(ladspaRdfInfo, fLadspa)
  1889. fLadspa.close()
  1890. if self.fCheckDSSI:
  1891. if self.fCheckNative:
  1892. self._checkDSSI(OS, self.fToolNative)
  1893. settingsDB.setValue("Plugins/DSSI_native", self.fDssiPlugins)
  1894. settingsDB.sync()
  1895. if self.fCheckPosix32:
  1896. self._checkDSSI(OS, carla_discovery_posix32)
  1897. settingsDB.setValue("Plugins/DSSI_posix32", self.fDssiPlugins)
  1898. settingsDB.sync()
  1899. if self.fCheckPosix64:
  1900. self._checkDSSI(OS, carla_discovery_posix64)
  1901. settingsDB.setValue("Plugins/DSSI_posix64", self.fDssiPlugins)
  1902. settingsDB.sync()
  1903. if self.fCheckWin32:
  1904. self._checkDSSI("WINDOWS", carla_discovery_win32, not WINDOWS)
  1905. settingsDB.setValue("Plugins/DSSI_win32", self.fDssiPlugins)
  1906. settingsDB.sync()
  1907. if self.fCheckWin64:
  1908. self._checkDSSI("WINDOWS", carla_discovery_win64, not WINDOWS)
  1909. settingsDB.setValue("Plugins/DSSI_win64", self.fDssiPlugins)
  1910. settingsDB.sync()
  1911. if self.fCheckLV2:
  1912. if self.fCheckNative:
  1913. self._checkLV2(self.fToolNative)
  1914. settingsDB.setValue("Plugins/LV2_native", self.fLv2Plugins)
  1915. settingsDB.sync()
  1916. if self.fCheckPosix32:
  1917. self._checkLV2(carla_discovery_posix32)
  1918. settingsDB.setValue("Plugins/LV2_posix32", self.fLv2Plugins)
  1919. settingsDB.sync()
  1920. if self.fCheckPosix64:
  1921. self._checkLV2(carla_discovery_posix64)
  1922. settingsDB.setValue("Plugins/LV2_posix64", self.fLv2Plugins)
  1923. settingsDB.sync()
  1924. if self.fCheckWin32:
  1925. self._checkLV2(carla_discovery_win32, not WINDOWS)
  1926. settingsDB.setValue("Plugins/LV2_win32", self.fLv2Plugins)
  1927. settingsDB.sync()
  1928. if self.fCheckWin64:
  1929. self._checkLV2(carla_discovery_win64, not WINDOWS)
  1930. settingsDB.setValue("Plugins/LV2_win64", self.fLv2Plugins)
  1931. settingsDB.sync()
  1932. if self.fCheckVST:
  1933. if self.fCheckNative:
  1934. self._checkVST(OS, self.fToolNative)
  1935. settingsDB.setValue("Plugins/VST_native", self.fVstPlugins)
  1936. settingsDB.sync()
  1937. if self.fCheckPosix32:
  1938. self._checkVST(OS, carla_discovery_posix32)
  1939. settingsDB.setValue("Plugins/VST_posix32", self.fVstPlugins)
  1940. settingsDB.sync()
  1941. if self.fCheckPosix64:
  1942. self._checkVST(OS, carla_discovery_posix64)
  1943. settingsDB.setValue("Plugins/VST_posix64", self.fVstPlugins)
  1944. settingsDB.sync()
  1945. if self.fCheckWin32:
  1946. self._checkVST("WINDOWS", carla_discovery_win32, not WINDOWS)
  1947. settingsDB.setValue("Plugins/VST_win32", self.fVstPlugins)
  1948. settingsDB.sync()
  1949. if self.fCheckWin64:
  1950. self._checkVST("WINDOWS", carla_discovery_win64, not WINDOWS)
  1951. settingsDB.setValue("Plugins/VST_win64", self.fVstPlugins)
  1952. settingsDB.sync()
  1953. if self.fCheckGIG:
  1954. self._checkKIT(Carla.GIG_PATH, "gig")
  1955. settingsDB.setValue("Plugins/GIG", self.fKitPlugins)
  1956. settingsDB.sync()
  1957. if self.fCheckSF2:
  1958. self._checkKIT(Carla.SF2_PATH, "sf2")
  1959. settingsDB.setValue("Plugins/SF2", self.fKitPlugins)
  1960. settingsDB.sync()
  1961. if self.fCheckSFZ:
  1962. self._checkKIT(Carla.SFZ_PATH, "sfz")
  1963. settingsDB.setValue("Plugins/SFZ", self.fKitPlugins)
  1964. settingsDB.sync()
  1965. def _checkLADSPA(self, OS, tool, isWine=False):
  1966. ladspaBinaries = []
  1967. self.fLadspaPlugins = []
  1968. for iPATH in Carla.LADSPA_PATH:
  1969. binaries = findBinaries(iPATH, OS)
  1970. for binary in binaries:
  1971. if binary not in ladspaBinaries:
  1972. ladspaBinaries.append(binary)
  1973. ladspaBinaries.sort()
  1974. for i in range(len(ladspaBinaries)):
  1975. ladspa = ladspaBinaries[i]
  1976. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  1977. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  1978. plugins = checkPluginLADSPA(ladspa, tool, isWine)
  1979. if plugins:
  1980. self.fLadspaPlugins.append(plugins)
  1981. self.fSomethingChanged = True
  1982. self.fLastCheckValue += self.fCurPercentValue
  1983. def _checkDSSI(self, OS, tool, isWine=False):
  1984. dssiBinaries = []
  1985. self.fDssiPlugins = []
  1986. for iPATH in Carla.DSSI_PATH:
  1987. binaries = findBinaries(iPATH, OS)
  1988. for binary in binaries:
  1989. if binary not in dssiBinaries:
  1990. dssiBinaries.append(binary)
  1991. dssiBinaries.sort()
  1992. for i in range(len(dssiBinaries)):
  1993. dssi = dssiBinaries[i]
  1994. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  1995. self._pluginLook(self.fLastCheckValue + percent, dssi)
  1996. plugins = checkPluginDSSI(dssi, tool, isWine)
  1997. if plugins:
  1998. self.fDssiPlugins.append(plugins)
  1999. self.fSomethingChanged = True
  2000. self.fLastCheckValue += self.fCurPercentValue
  2001. def _checkLV2(self, tool, isWine=False):
  2002. lv2Bundles = []
  2003. self.fLv2Plugins = []
  2004. self._pluginLook(self.fLastCheckValue, "LV2 bundles...")
  2005. for iPATH in Carla.LV2_PATH:
  2006. bundles = findLV2Bundles(iPATH)
  2007. for bundle in bundles:
  2008. if bundle not in lv2Bundles:
  2009. lv2Bundles.append(bundle)
  2010. lv2Bundles.sort()
  2011. for i in range(len(lv2Bundles)):
  2012. lv2 = lv2Bundles[i]
  2013. percent = ( float(i) / len(lv2Bundles) ) * self.fCurPercentValue
  2014. self._pluginLook(self.fLastCheckValue + percent, lv2)
  2015. plugins = checkPluginLV2(lv2, tool, isWine)
  2016. if plugins:
  2017. self.fLv2Plugins.append(plugins)
  2018. self.fSomethingChanged = True
  2019. self.fLastCheckValue += self.fCurPercentValue
  2020. def _checkVST(self, OS, tool, isWine=False):
  2021. vstBinaries = []
  2022. self.fVstPlugins = []
  2023. for iPATH in Carla.VST_PATH:
  2024. binaries = findBinaries(iPATH, OS)
  2025. for binary in binaries:
  2026. if binary not in vstBinaries:
  2027. vstBinaries.append(binary)
  2028. vstBinaries.sort()
  2029. for i in range(len(vstBinaries)):
  2030. vst = vstBinaries[i]
  2031. percent = ( float(i) / len(vstBinaries) ) * self.fCurPercentValue
  2032. self._pluginLook(self.fLastCheckValue + percent, vst)
  2033. plugins = checkPluginVST(vst, tool, isWine)
  2034. if plugins:
  2035. self.fVstPlugins.append(plugins)
  2036. self.fSomethingChanged = True
  2037. self.fLastCheckValue += self.fCurPercentValue
  2038. def _checkKIT(self, kPATH, kType):
  2039. kitFiles = []
  2040. self.fKitPlugins = []
  2041. for iPATH in kPATH:
  2042. files = findSoundKits(iPATH, kType)
  2043. for file_ in files:
  2044. if file_ not in kitFiles:
  2045. kitFiles.append(file_)
  2046. kitFiles.sort()
  2047. for i in range(len(kitFiles)):
  2048. kit = kitFiles[i]
  2049. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  2050. self._pluginLook(self.fLastCheckValue + percent, kit)
  2051. if kType == "gig":
  2052. plugins = checkPluginGIG(kit, self.fToolNative)
  2053. elif kType == "sf2":
  2054. plugins = checkPluginSF2(kit, self.fToolNative)
  2055. elif kType == "sfz":
  2056. plugins = checkPluginSFZ(kit, self.fToolNative)
  2057. else:
  2058. plugins = None
  2059. if plugins:
  2060. self.fKitPlugins.append(plugins)
  2061. self.fSomethingChanged = True
  2062. self.fLastCheckValue += self.fCurPercentValue
  2063. def _pluginLook(self, percent, plugin):
  2064. self.emit(SIGNAL("PluginLook(int, QString)"), percent, plugin)
  2065. # ------------------------------------------------------------------------------------------------------------
  2066. # Plugin Refresh Dialog
  2067. class PluginRefreshW(QDialog):
  2068. def __init__(self, parent):
  2069. QDialog.__init__(self, parent)
  2070. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  2071. self.ui.setupUi(self)
  2072. self._loadSettings()
  2073. self.ui.b_skip.setVisible(False)
  2074. if HAIKU:
  2075. self.ui.ch_posix32.setText("Haiku 32bit")
  2076. self.ui.ch_posix64.setText("Haiku 64bit")
  2077. elif LINUX:
  2078. self.ui.ch_posix32.setText("Linux 32bit")
  2079. self.ui.ch_posix64.setText("Linux 64bit")
  2080. elif MACOS:
  2081. self.ui.ch_posix32.setText("MacOS 32bit")
  2082. self.ui.ch_posix64.setText("MacOS 64bit")
  2083. self.fThread = SearchPluginsThread(self)
  2084. if carla_discovery_posix32 and not WINDOWS:
  2085. self.ui.ico_posix32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2086. else:
  2087. self.ui.ico_posix32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2088. self.ui.ch_posix32.setChecked(False)
  2089. self.ui.ch_posix32.setEnabled(False)
  2090. if carla_discovery_posix64 and not WINDOWS:
  2091. self.ui.ico_posix64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2092. else:
  2093. self.ui.ico_posix64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2094. self.ui.ch_posix64.setChecked(False)
  2095. self.ui.ch_posix64.setEnabled(False)
  2096. if carla_discovery_win32:
  2097. self.ui.ico_win32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2098. else:
  2099. self.ui.ico_win32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2100. self.ui.ch_win32.setChecked(False)
  2101. self.ui.ch_win32.setEnabled(False)
  2102. if carla_discovery_win64:
  2103. self.ui.ico_win64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2104. else:
  2105. self.ui.ico_win64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2106. self.ui.ch_win64.setChecked(False)
  2107. self.ui.ch_win64.setEnabled(False)
  2108. if haveLRDF:
  2109. self.ui.ico_rdflib.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2110. else:
  2111. self.ui.ico_rdflib.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2112. hasNative = bool(carla_discovery_native)
  2113. hasNonNative = False
  2114. if WINDOWS:
  2115. if kIs64bit:
  2116. hasNative = bool(carla_discovery_win64)
  2117. hasNonNative = bool(carla_discovery_win32)
  2118. self.fThread.setSearchToolNative(carla_discovery_win64)
  2119. self.ui.ch_win64.setChecked(False)
  2120. self.ui.ch_win64.setVisible(False)
  2121. self.ui.ico_win64.setVisible(False)
  2122. self.ui.label_win64.setVisible(False)
  2123. else:
  2124. hasNative = bool(carla_discovery_win32)
  2125. hasNonNative = bool(carla_discovery_win64)
  2126. self.fThread.setSearchToolNative(carla_discovery_win32)
  2127. self.ui.ch_win32.setChecked(False)
  2128. self.ui.ch_win32.setVisible(False)
  2129. self.ui.ico_win32.setVisible(False)
  2130. self.ui.label_win32.setVisible(False)
  2131. elif LINUX or MACOS:
  2132. if kIs64bit:
  2133. hasNonNative = bool(carla_discovery_posix32 or carla_discovery_win32 or carla_discovery_win64)
  2134. self.ui.ch_posix64.setChecked(False)
  2135. self.ui.ch_posix64.setVisible(False)
  2136. self.ui.ico_posix64.setVisible(False)
  2137. self.ui.label_posix64.setVisible(False)
  2138. else:
  2139. hasNonNative = bool(carla_discovery_posix64 or carla_discovery_win32 or carla_discovery_win64)
  2140. self.ui.ch_posix32.setChecked(False)
  2141. self.ui.ch_posix32.setVisible(False)
  2142. self.ui.ico_posix32.setVisible(False)
  2143. self.ui.label_posix32.setVisible(False)
  2144. if hasNative:
  2145. self.ui.ico_native.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2146. else:
  2147. self.ui.ico_native.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2148. self.ui.ch_native.setChecked(False)
  2149. self.ui.ch_native.setEnabled(False)
  2150. self.ui.ch_gig.setChecked(False)
  2151. self.ui.ch_gig.setEnabled(False)
  2152. self.ui.ch_sf2.setChecked(False)
  2153. self.ui.ch_sf2.setEnabled(False)
  2154. self.ui.ch_sfz.setChecked(False)
  2155. self.ui.ch_sfz.setEnabled(False)
  2156. if not hasNonNative:
  2157. self.ui.ch_ladspa.setChecked(False)
  2158. self.ui.ch_ladspa.setEnabled(False)
  2159. self.ui.ch_dssi.setChecked(False)
  2160. self.ui.ch_dssi.setEnabled(False)
  2161. self.ui.ch_lv2.setChecked(False)
  2162. self.ui.ch_lv2.setEnabled(False)
  2163. self.ui.ch_vst.setChecked(False)
  2164. self.ui.ch_vst.setEnabled(False)
  2165. self.ui.b_start.setEnabled(False)
  2166. #TODO
  2167. self.ui.ch_lv2.setChecked(False)
  2168. self.connect(self.ui.b_start, SIGNAL("clicked()"), SLOT("slot_start()"))
  2169. self.connect(self.ui.b_skip, SIGNAL("clicked()"), SLOT("slot_skip()"))
  2170. self.connect(self.fThread, SIGNAL("PluginLook(int, QString)"), SLOT("slot_handlePluginLook(int, QString)"))
  2171. self.connect(self.fThread, SIGNAL("finished()"), SLOT("slot_handlePluginThreadFinished()"))
  2172. @pyqtSlot()
  2173. def slot_start(self):
  2174. self.ui.progressBar.setMinimum(0)
  2175. self.ui.progressBar.setMaximum(100)
  2176. self.ui.progressBar.setValue(0)
  2177. self.ui.b_start.setEnabled(False)
  2178. self.ui.b_skip.setVisible(True)
  2179. self.ui.b_close.setVisible(False)
  2180. native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(), self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(), self.ui.ch_win32.isChecked(), self.ui.ch_win64.isChecked())
  2181. ladspa, dssi, lv2, vst, gig, sf2, sfz = (self.ui.ch_ladspa.isChecked(), self.ui.ch_dssi.isChecked(), self.ui.ch_lv2.isChecked(), self.ui.ch_vst.isChecked(),
  2182. self.ui.ch_gig.isChecked(), self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  2183. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  2184. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, gig, sf2, sfz)
  2185. self.fThread.start()
  2186. @pyqtSlot()
  2187. def slot_skip(self):
  2188. self.fThread.skipPlugin()
  2189. @pyqtSlot(int, str)
  2190. def slot_handlePluginLook(self, percent, plugin):
  2191. self.ui.progressBar.setFormat("%s" % plugin)
  2192. self.ui.progressBar.setValue(percent)
  2193. @pyqtSlot()
  2194. def slot_handlePluginThreadFinished(self):
  2195. self.ui.progressBar.setMinimum(0)
  2196. self.ui.progressBar.setMaximum(1)
  2197. self.ui.progressBar.setValue(1)
  2198. self.ui.progressBar.setFormat(self.tr("Done"))
  2199. self.ui.b_start.setEnabled(True)
  2200. self.ui.b_skip.setVisible(False)
  2201. self.ui.b_close.setVisible(True)
  2202. def _saveSettings(self):
  2203. settings = QSettings()
  2204. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  2205. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  2206. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  2207. settings.setValue("PluginDatabase/SearchVST", self.ui.ch_vst.isChecked())
  2208. settings.setValue("PluginDatabase/SearchGIG", self.ui.ch_gig.isChecked())
  2209. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  2210. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  2211. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  2212. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  2213. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  2214. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  2215. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  2216. def _loadSettings(self):
  2217. settings = QSettings()
  2218. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/SearchLADSPA", True, type=bool))
  2219. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/SearchDSSI", True, type=bool))
  2220. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/SearchLV2", True, type=bool))
  2221. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/SearchVST", True, type=bool))
  2222. self.ui.ch_gig.setChecked(settings.value("PluginDatabase/SearchGIG", False, type=bool))
  2223. self.ui.ch_sf2.setChecked(settings.value("PluginDatabase/SearchSF2", False, type=bool))
  2224. self.ui.ch_sfz.setChecked(settings.value("PluginDatabase/SearchSFZ", False, type=bool))
  2225. self.ui.ch_native.setChecked(settings.value("PluginDatabase/SearchNative", True, type=bool))
  2226. self.ui.ch_posix32.setChecked(settings.value("PluginDatabase/SearchPOSIX32", False, type=bool))
  2227. self.ui.ch_posix64.setChecked(settings.value("PluginDatabase/SearchPOSIX64", False, type=bool))
  2228. self.ui.ch_win32.setChecked(settings.value("PluginDatabase/SearchWin32", False, type=bool))
  2229. self.ui.ch_win64.setChecked(settings.value("PluginDatabase/SearchWin64", False, type=bool))
  2230. def closeEvent(self, event):
  2231. if self.fThread.isRunning():
  2232. self.fThread.terminate()
  2233. self.fThread.wait()
  2234. self._saveSettings()
  2235. if self.fThread.somethingChanged():
  2236. self.accept()
  2237. else:
  2238. self.reject()
  2239. QDialog.closeEvent(self, event)
  2240. def done(self, r):
  2241. QDialog.done(self, r)
  2242. self.close()
  2243. # ------------------------------------------------------------------------------------------------------------
  2244. # Plugin Database Dialog
  2245. class PluginDatabaseW(QDialog):
  2246. def __init__(self, parent):
  2247. QDialog.__init__(self, parent)
  2248. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  2249. self.ui.setupUi(self)
  2250. self.fLastTableIndex = 0
  2251. self.fRetPlugin = None
  2252. self.fRealParent = parent
  2253. self.ui.b_add.setEnabled(False)
  2254. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  2255. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  2256. else:
  2257. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  2258. if not (LINUX or MACOS):
  2259. self.ui.ch_bridged_wine.setChecked(False)
  2260. self.ui.ch_bridged_wine.setEnabled(False)
  2261. self._loadSettings()
  2262. self.connect(self.ui.b_add, SIGNAL("clicked()"), SLOT("slot_addPlugin()"))
  2263. self.connect(self.ui.b_refresh, SIGNAL("clicked()"), SLOT("slot_refreshPlugins()"))
  2264. self.connect(self.ui.tb_filters, SIGNAL("clicked()"), SLOT("slot_maybeShowFilters()"))
  2265. self.connect(self.ui.tableWidget, SIGNAL("currentCellChanged(int, int, int, int)"), SLOT("slot_checkPlugin(int)"))
  2266. self.connect(self.ui.tableWidget, SIGNAL("cellDoubleClicked(int, int)"), SLOT("slot_addPlugin()"))
  2267. self.connect(self.ui.lineEdit, SIGNAL("textChanged(QString)"), SLOT("slot_checkFilters()"))
  2268. self.connect(self.ui.ch_effects, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2269. self.connect(self.ui.ch_instruments, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2270. self.connect(self.ui.ch_midi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2271. self.connect(self.ui.ch_other, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2272. self.connect(self.ui.ch_kits, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2273. self.connect(self.ui.ch_internal, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2274. self.connect(self.ui.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2275. self.connect(self.ui.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2276. self.connect(self.ui.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2277. self.connect(self.ui.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2278. self.connect(self.ui.ch_native, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2279. self.connect(self.ui.ch_bridged, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2280. self.connect(self.ui.ch_bridged_wine, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2281. self.connect(self.ui.ch_gui, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2282. self.connect(self.ui.ch_stereo, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2283. @pyqtSlot()
  2284. def slot_addPlugin(self):
  2285. if self.ui.tableWidget.currentRow() >= 0:
  2286. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).pluginData
  2287. self.accept()
  2288. else:
  2289. self.reject()
  2290. @pyqtSlot(int)
  2291. def slot_checkPlugin(self, row):
  2292. self.ui.b_add.setEnabled(row >= 0)
  2293. @pyqtSlot()
  2294. def slot_checkFilters(self):
  2295. self._checkFilters()
  2296. @pyqtSlot()
  2297. def slot_maybeShowFilters(self):
  2298. self._showFilters(not self.ui.frame.isVisible())
  2299. @pyqtSlot()
  2300. def slot_refreshPlugins(self):
  2301. if PluginRefreshW(self).exec_():
  2302. self._reAddPlugins()
  2303. if self.fRealParent:
  2304. self.fRealParent.loadRDFs()
  2305. def _checkFilters(self):
  2306. text = self.ui.lineEdit.text().lower()
  2307. hideEffects = not self.ui.ch_effects.isChecked()
  2308. hideInstruments = not self.ui.ch_instruments.isChecked()
  2309. hideMidi = not self.ui.ch_midi.isChecked()
  2310. hideOther = not self.ui.ch_other.isChecked()
  2311. hideInternal = not self.ui.ch_internal.isChecked()
  2312. hideLadspa = not self.ui.ch_ladspa.isChecked()
  2313. hideDssi = not self.ui.ch_dssi.isChecked()
  2314. hideLV2 = not self.ui.ch_lv2.isChecked()
  2315. hideVST = not self.ui.ch_vst.isChecked()
  2316. hideKits = not self.ui.ch_kits.isChecked()
  2317. hideNative = not self.ui.ch_native.isChecked()
  2318. hideBridged = not self.ui.ch_bridged.isChecked()
  2319. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  2320. hideNonGui = self.ui.ch_gui.isChecked()
  2321. hideNonStereo = self.ui.ch_stereo.isChecked()
  2322. if HAIKU or LINUX or MACOS:
  2323. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  2324. wineBins = [BINARY_WIN32, BINARY_WIN64]
  2325. elif WINDOWS:
  2326. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  2327. wineBins = []
  2328. else:
  2329. nativeBins = []
  2330. wineBins = []
  2331. rowCount = self.ui.tableWidget.rowCount()
  2332. for i in range(rowCount):
  2333. self.ui.tableWidget.showRow(i)
  2334. plugin = self.ui.tableWidget.item(i, 0).pluginData
  2335. aIns = plugin['audio.ins']
  2336. aOuts = plugin['audio.outs']
  2337. mIns = plugin['midi.ins']
  2338. mOuts = plugin['midi.outs']
  2339. ptype = self.ui.tableWidget.item(i, 12).text()
  2340. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  2341. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  2342. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  2343. isKit = bool(ptype in ("GIG", "SF2", "SFZ"))
  2344. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  2345. isNative = bool(plugin['build'] == BINARY_NATIVE)
  2346. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  2347. hasGui = bool(plugin['hints'] & PLUGIN_HAS_GUI)
  2348. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  2349. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  2350. if (hideEffects and isEffect):
  2351. self.ui.tableWidget.hideRow(i)
  2352. elif (hideInstruments and isSynth):
  2353. self.ui.tableWidget.hideRow(i)
  2354. elif (hideMidi and isMidi):
  2355. self.ui.tableWidget.hideRow(i)
  2356. elif (hideOther and isOther):
  2357. self.ui.tableWidget.hideRow(i)
  2358. elif (hideKits and isKit):
  2359. self.ui.tableWidget.hideRow(i)
  2360. elif (hideInternal and ptype == self.tr("Internal")):
  2361. self.ui.tableWidget.hideRow(i)
  2362. elif (hideLadspa and ptype == "LADSPA"):
  2363. self.ui.tableWidget.hideRow(i)
  2364. elif (hideDssi and ptype == "DSSI"):
  2365. self.ui.tableWidget.hideRow(i)
  2366. elif (hideLV2 and ptype == "LV2"):
  2367. self.ui.tableWidget.hideRow(i)
  2368. elif (hideVST and ptype == "VST"):
  2369. self.ui.tableWidget.hideRow(i)
  2370. elif (hideNative and isNative):
  2371. self.ui.tableWidget.hideRow(i)
  2372. elif (hideBridged and isBridged):
  2373. self.ui.tableWidget.hideRow(i)
  2374. elif (hideBridgedWine and isBridgedWine):
  2375. self.ui.tableWidget.hideRow(i)
  2376. elif (hideNonGui and not hasGui):
  2377. self.ui.tableWidget.hideRow(i)
  2378. elif (hideNonStereo and not isStereo):
  2379. self.ui.tableWidget.hideRow(i)
  2380. elif (text and not (
  2381. text in self.ui.tableWidget.item(i, 0).text().lower() or
  2382. text in self.ui.tableWidget.item(i, 1).text().lower() or
  2383. text in self.ui.tableWidget.item(i, 2).text().lower() or
  2384. text in self.ui.tableWidget.item(i, 3).text().lower() or
  2385. text in self.ui.tableWidget.item(i, 13).text().lower())):
  2386. self.ui.tableWidget.hideRow(i)
  2387. def _showFilters(self, yesNo):
  2388. self.ui.tb_filters.setArrowType(Qt.UpArrow if yesNo else Qt.DownArrow)
  2389. self.ui.frame.setVisible(yesNo)
  2390. def _reAddPlugins(self):
  2391. settingsDB = QSettings("falkTX", "CarlaPlugins")
  2392. rowCount = self.ui.tableWidget.rowCount()
  2393. for x in range(rowCount):
  2394. self.ui.tableWidget.removeRow(0)
  2395. self.fLastTableIndex = 0
  2396. self.ui.tableWidget.setSortingEnabled(False)
  2397. internalCount = 0
  2398. ladspaCount = 0
  2399. dssiCount = 0
  2400. lv2Count = 0
  2401. vstCount = 0
  2402. kitCount = 0
  2403. # ---------------------------------------------------------------------------
  2404. # Internal
  2405. internalPlugins = toList(settingsDB.value("Plugins/Internal", []))
  2406. for plugins in internalPlugins:
  2407. for plugin in plugins:
  2408. internalCount += 1
  2409. if (not Carla.isControl) and internalCount != Carla.host.get_internal_plugin_count():
  2410. internalCount = Carla.host.get_internal_plugin_count()
  2411. internalPlugins = []
  2412. for i in range(Carla.host.get_internal_plugin_count()):
  2413. descInfo = Carla.host.get_internal_plugin_info(i)
  2414. plugins = checkPluginInternal(descInfo)
  2415. if plugins:
  2416. internalPlugins.append(plugins)
  2417. settingsDB.setValue("Plugins/Internal", internalPlugins)
  2418. for plugins in internalPlugins:
  2419. for plugin in plugins:
  2420. self._addPluginToTable(plugin, self.tr("Internal"))
  2421. # ---------------------------------------------------------------------------
  2422. # LADSPA
  2423. ladspaPlugins = []
  2424. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", []))
  2425. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", []))
  2426. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", []))
  2427. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", []))
  2428. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", []))
  2429. for plugins in ladspaPlugins:
  2430. for plugin in plugins:
  2431. self._addPluginToTable(plugin, "LADSPA")
  2432. ladspaCount += 1
  2433. # ---------------------------------------------------------------------------
  2434. # DSSI
  2435. dssiPlugins = []
  2436. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", []))
  2437. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", []))
  2438. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", []))
  2439. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", []))
  2440. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", []))
  2441. for plugins in dssiPlugins:
  2442. for plugin in plugins:
  2443. self._addPluginToTable(plugin, "DSSI")
  2444. dssiCount += 1
  2445. # ---------------------------------------------------------------------------
  2446. # LV2
  2447. lv2Plugins = []
  2448. lv2Plugins += toList(settingsDB.value("Plugins/LV2_native", []))
  2449. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix32", []))
  2450. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix64", []))
  2451. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win32", []))
  2452. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win64", []))
  2453. for plugins in lv2Plugins:
  2454. for plugin in plugins:
  2455. self._addPluginToTable(plugin, "LV2")
  2456. lv2Count += 1
  2457. # ---------------------------------------------------------------------------
  2458. # VST
  2459. vstPlugins = []
  2460. vstPlugins += toList(settingsDB.value("Plugins/VST_native", []))
  2461. vstPlugins += toList(settingsDB.value("Plugins/VST_posix32", []))
  2462. vstPlugins += toList(settingsDB.value("Plugins/VST_posix64", []))
  2463. vstPlugins += toList(settingsDB.value("Plugins/VST_win32", []))
  2464. vstPlugins += toList(settingsDB.value("Plugins/VST_win64", []))
  2465. for plugins in vstPlugins:
  2466. for plugin in plugins:
  2467. self._addPluginToTable(plugin, "VST")
  2468. vstCount += 1
  2469. # ---------------------------------------------------------------------------
  2470. # Kits
  2471. gigs = toList(settingsDB.value("Plugins/GIG", []))
  2472. sf2s = toList(settingsDB.value("Plugins/SF2", []))
  2473. sfzs = toList(settingsDB.value("Plugins/SFZ", []))
  2474. for gig in gigs:
  2475. for gig_i in gig:
  2476. self._addPluginToTable(gig_i, "GIG")
  2477. kitCount += 1
  2478. for sf2 in sf2s:
  2479. for sf2_i in sf2:
  2480. self._addPluginToTable(sf2_i, "SF2")
  2481. kitCount += 1
  2482. for sfz in sfzs:
  2483. for sfz_i in sfz:
  2484. self._addPluginToTable(sfz_i, "SFZ")
  2485. kitCount += 1
  2486. # ---------------------------------------------------------------------------
  2487. self.ui.tableWidget.setSortingEnabled(True)
  2488. self.ui.tableWidget.sortByColumn(0, Qt.AscendingOrder)
  2489. self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2, %i VST and %i Sound Kits" % (internalCount, ladspaCount, dssiCount, lv2Count, vstCount, kitCount)))
  2490. self._checkFilters()
  2491. def _addPluginToTable(self, plugin, ptype):
  2492. index = self.fLastTableIndex
  2493. if plugin['build'] == BINARY_NATIVE:
  2494. bridgeText = self.tr("No")
  2495. else:
  2496. typeText = self.tr("Unknown")
  2497. if LINUX or MACOS:
  2498. if plugin['build'] == BINARY_POSIX32:
  2499. typeText = "32bit"
  2500. elif plugin['build'] == BINARY_POSIX64:
  2501. typeText = "64bit"
  2502. elif plugin['build'] == BINARY_WIN32:
  2503. typeText = "Windows 32bit"
  2504. elif plugin['build'] == BINARY_WIN64:
  2505. typeText = "Windows 64bit"
  2506. elif WINDOWS:
  2507. if plugin['build'] == BINARY_WIN32:
  2508. typeText = "32bit"
  2509. elif plugin['build'] == BINARY_WIN64:
  2510. typeText = "64bit"
  2511. bridgeText = self.tr("Yes (%s)" % typeText)
  2512. self.ui.tableWidget.insertRow(index)
  2513. self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(str(plugin['name'])))
  2514. self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(str(plugin['label'])))
  2515. self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(str(plugin['maker'])))
  2516. self.ui.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['uniqueId'])))
  2517. self.ui.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins'])))
  2518. self.ui.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs'])))
  2519. self.ui.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins'])))
  2520. self.ui.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs'])))
  2521. self.ui.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total'])))
  2522. self.ui.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_GUI) else self.tr("No")))
  2523. self.ui.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No")))
  2524. self.ui.tableWidget.setItem(index, 11, QTableWidgetItem(bridgeText))
  2525. self.ui.tableWidget.setItem(index, 12, QTableWidgetItem(ptype))
  2526. self.ui.tableWidget.setItem(index, 13, QTableWidgetItem(str(plugin['binary'])))
  2527. self.ui.tableWidget.item(self.fLastTableIndex, 0).pluginData = plugin
  2528. self.fLastTableIndex += 1
  2529. def _saveSettings(self):
  2530. settings = QSettings()
  2531. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  2532. settings.setValue("PluginDatabase/TableGeometry", self.ui.tableWidget.horizontalHeader().saveState())
  2533. settings.setValue("PluginDatabase/ShowFilters", (self.ui.tb_filters.arrowType() == Qt.UpArrow))
  2534. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  2535. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  2536. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  2537. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  2538. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  2539. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  2540. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  2541. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  2542. settings.setValue("PluginDatabase/ShowVST", self.ui.ch_vst.isChecked())
  2543. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  2544. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  2545. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  2546. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  2547. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  2548. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  2549. def _loadSettings(self):
  2550. settings = QSettings()
  2551. self.restoreGeometry(settings.value("PluginDatabase/Geometry", ""))
  2552. self.ui.tableWidget.horizontalHeader().restoreState(settings.value("PluginDatabase/TableGeometry", ""))
  2553. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool))
  2554. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool))
  2555. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool))
  2556. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool))
  2557. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool))
  2558. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool))
  2559. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool))
  2560. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool))
  2561. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST", True, type=bool))
  2562. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool))
  2563. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool))
  2564. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool))
  2565. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool))
  2566. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool))
  2567. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool))
  2568. self._showFilters(settings.value("PluginDatabase/ShowFilters", False, type=bool))
  2569. self._reAddPlugins()
  2570. def closeEvent(self, event):
  2571. self._saveSettings()
  2572. QDialog.closeEvent(self, event)
  2573. def done(self, r):
  2574. QDialog.done(self, r)
  2575. self.close()