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.

3149 lines
124KB

  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. else:
  707. self.ui.l_extended.setText(cString(Carla.host.get_extended_license_text()))
  708. 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)"))
  709. self.ui.l_osc_cmds.setText(""
  710. " /set_active <i-value>\n"
  711. " /set_drywet <f-value>\n"
  712. " /set_volume <f-value>\n"
  713. " /set_balance_left <f-value>\n"
  714. " /set_balance_right <f-value>\n"
  715. " /set_panning <f-value>\n"
  716. " /set_parameter_value <i-index> <f-value>\n"
  717. " /set_parameter_midi_cc <i-index> <i-cc>\n"
  718. " /set_parameter_midi_channel <i-index> <i-channel>\n"
  719. " /set_program <i-index>\n"
  720. " /set_midi_program <i-index>\n"
  721. " /note_on <i-note> <i-velo>\n"
  722. " /note_off <i-note>\n"
  723. )
  724. self.ui.l_example.setText("/Carla/2/set_parameter_value 5 1.0")
  725. self.ui.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>")
  726. self.ui.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  727. self.ui.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  728. self.ui.l_lv2.setText(self.tr("About 95&#37; complete (using custom extensions).<br/>"
  729. "Implemented Feature/Extensions:"
  730. "<ul>"
  731. "<li>http://lv2plug.in/ns/ext/atom</li>"
  732. "<li>http://lv2plug.in/ns/ext/buf-size</li>"
  733. "<li>http://lv2plug.in/ns/ext/data-access</li>"
  734. #"<li>http://lv2plug.in/ns/ext/dynmanifest</li>"
  735. "<li>http://lv2plug.in/ns/ext/event</li>"
  736. "<li>http://lv2plug.in/ns/ext/instance-access</li>"
  737. "<li>http://lv2plug.in/ns/ext/log</li>"
  738. "<li>http://lv2plug.in/ns/ext/midi</li>"
  739. "<li>http://lv2plug.in/ns/ext/options</li>"
  740. #"<li>http://lv2plug.in/ns/ext/parameters</li>"
  741. "<li>http://lv2plug.in/ns/ext/patch</li>"
  742. #"<li>http://lv2plug.in/ns/ext/port-groups</li>"
  743. "<li>http://lv2plug.in/ns/ext/port-props</li>"
  744. #"<li>http://lv2plug.in/ns/ext/presets</li>"
  745. "<li>http://lv2plug.in/ns/ext/state</li>"
  746. "<li>http://lv2plug.in/ns/ext/time</li>"
  747. "<li>http://lv2plug.in/ns/ext/uri-map</li>"
  748. "<li>http://lv2plug.in/ns/ext/urid</li>"
  749. "<li>http://lv2plug.in/ns/ext/worker</li>"
  750. "<li>http://lv2plug.in/ns/extensions/ui</li>"
  751. "<li>http://lv2plug.in/ns/extensions/units</li>"
  752. "<li>http://kxstudio.sf.net/ns/lv2ext/external-ui</li>"
  753. "<li>http://kxstudio.sf.net/ns/lv2ext/programs</li>"
  754. "<li>http://kxstudio.sf.net/ns/lv2ext/rtmempool</li>"
  755. "<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  756. "<li>http://ll-plugins.nongnu.org/lv2/ext/miditype</li>"
  757. "</ul>"))
  758. self.ui.l_vst.setText(self.tr("<p>About 85&#37; complete (missing vst bank/presets and some minor stuff)</p>"))
  759. #TODO
  760. self.ui.l_lv2.setText(self.tr("Not enabled for now"))
  761. def done(self, r):
  762. QDialog.done(self, r)
  763. self.close()
  764. # ------------------------------------------------------------------------------------------------------------
  765. # Plugin Parameter
  766. class PluginParameter(QWidget):
  767. def __init__(self, parent, pInfo, pluginId, tabIndex):
  768. QWidget.__init__(self, parent)
  769. self.ui = ui_carla_parameter.Ui_PluginParameter()
  770. self.ui.setupUi(self)
  771. pType = pInfo['type']
  772. pHints = pInfo['hints']
  773. self.fMidiControl = -1
  774. self.fMidiChannel = 1
  775. self.fParameterId = pInfo['index']
  776. self.fPluginId = pluginId
  777. self.fTabIndex = tabIndex
  778. self.ui.label.setText(pInfo['name'])
  779. self.ui.widget.setName(pInfo['name'])
  780. if pType == PARAMETER_INPUT:
  781. self.ui.widget.setMinimum(pInfo['minimum'])
  782. self.ui.widget.setMaximum(pInfo['maximum'])
  783. self.ui.widget.setDefault(pInfo['default'])
  784. self.ui.widget.setValue(pInfo['current'], False)
  785. self.ui.widget.setLabel(pInfo['unit'])
  786. self.ui.widget.setStep(pInfo['step'])
  787. self.ui.widget.setStepSmall(pInfo['stepSmall'])
  788. self.ui.widget.setStepLarge(pInfo['stepLarge'])
  789. self.ui.widget.setScalePoints(pInfo['scalePoints'], bool(pHints & PARAMETER_USES_SCALEPOINTS))
  790. if not pHints & PARAMETER_IS_ENABLED:
  791. self.ui.widget.setReadOnly(True)
  792. self.ui.sb_control.setEnabled(False)
  793. self.ui.sb_channel.setEnabled(False)
  794. elif not pHints & PARAMETER_IS_AUTOMABLE:
  795. self.ui.sb_control.setEnabled(False)
  796. self.ui.sb_channel.setEnabled(False)
  797. elif pType == PARAMETER_OUTPUT:
  798. self.ui.widget.setMinimum(pInfo['minimum'])
  799. self.ui.widget.setMaximum(pInfo['maximum'])
  800. self.ui.widget.setValue(pInfo['current'], False)
  801. self.ui.widget.setLabel(pInfo['unit'])
  802. self.ui.widget.setReadOnly(True)
  803. if not pHints & PARAMETER_IS_AUTOMABLE:
  804. self.ui.sb_control.setEnabled(False)
  805. self.ui.sb_channel.setEnabled(False)
  806. else:
  807. self.ui.widget.setVisible(False)
  808. self.ui.sb_control.setVisible(False)
  809. self.ui.sb_channel.setVisible(False)
  810. if pHints & PARAMETER_USES_CUSTOM_TEXT:
  811. self.ui.widget.setTextCallback(self._textCallBack)
  812. self.setMidiControl(pInfo['midiCC'])
  813. self.setMidiChannel(pInfo['midiChannel'])
  814. self.connect(self.ui.sb_control, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_controlSpinboxCustomMenu()"))
  815. self.connect(self.ui.sb_control, SIGNAL("valueChanged(int)"), SLOT("slot_controlSpinboxChanged(int)"))
  816. self.connect(self.ui.sb_channel, SIGNAL("valueChanged(int)"), SLOT("slot_channelSpinboxChanged(int)"))
  817. self.connect(self.ui.widget, SIGNAL("valueChanged(double)"), SLOT("slot_widgetValueChanged(double)"))
  818. self.ui.widget.updateAll()
  819. def setDefault(self, value):
  820. self.ui.widget.setDefault(value)
  821. def setValue(self, value, send=True):
  822. self.ui.widget.setValue(value, send)
  823. def setMidiControl(self, control):
  824. self.fMidiControl = control
  825. self.ui.sb_control.blockSignals(True)
  826. self.ui.sb_control.setValue(control)
  827. self.ui.sb_control.blockSignals(False)
  828. def setMidiChannel(self, channel):
  829. self.fMidiChannel = channel
  830. self.ui.sb_channel.blockSignals(True)
  831. self.ui.sb_channel.setValue(channel)
  832. self.ui.sb_channel.blockSignals(False)
  833. def setLabelWidth(self, width):
  834. self.ui.label.setMinimumWidth(width)
  835. self.ui.label.setMaximumWidth(width)
  836. def tabIndex(self):
  837. return self.fTabIndex
  838. @pyqtSlot()
  839. def slot_controlSpinboxCustomMenu(self):
  840. menu = QMenu(self)
  841. actNone = menu.addAction(self.tr("None"))
  842. if self.fMidiControl == -1:
  843. actNone.setCheckable(True)
  844. actNone.setChecked(True)
  845. for cc in MIDI_CC_LIST:
  846. action = menu.addAction(cc)
  847. if self.fMidiControl != -1 and int(cc.split(" ")[0], 16) == self.fMidiControl:
  848. action.setCheckable(True)
  849. action.setChecked(True)
  850. actSel = menu.exec_(QCursor.pos())
  851. if actSel:
  852. if actSel == actNone:
  853. self.ui.sb_control.setValue(-1)
  854. else:
  855. selControlStr = actSel.text()
  856. selControl = int(selControlStr.split(" ")[0], 16)
  857. self.ui.sb_control.setValue(selControl)
  858. @pyqtSlot(int)
  859. def slot_controlSpinboxChanged(self, control):
  860. if self.fMidiControl != control:
  861. self.emit(SIGNAL("midiControlChanged(int, int)"), self.fParameterId, control)
  862. self.fMidiControl = control
  863. @pyqtSlot(int)
  864. def slot_channelSpinboxChanged(self, channel):
  865. if self.fMidiChannel != channel:
  866. self.emit(SIGNAL("midiChannelChanged(int, int)"), self.fParameterId, channel)
  867. self.fMidiChannel = channel
  868. @pyqtSlot(float)
  869. def slot_widgetValueChanged(self, value):
  870. self.emit(SIGNAL("valueChanged(int, double)"), self.fParameterId, value)
  871. def _textCallBack(self):
  872. return cString(Carla.host.get_parameter_text(self.fPluginId, self.fParameterId))
  873. # ------------------------------------------------------------------------------------------------------------
  874. # Plugin Editor (Built-in)
  875. class PluginEdit(QDialog):
  876. def __init__(self, parent, pluginId):
  877. QDialog.__init__(self, Carla.gui)
  878. self.ui = ui_carla_edit.Ui_PluginEdit()
  879. self.ui.setupUi(self)
  880. self.fGeometry = QByteArray()
  881. self.fPluginId = pluginId
  882. self.fPuginInfo = None
  883. self.fRealParent = parent
  884. self.fCurrentProgram = -1
  885. self.fCurrentMidiProgram = -1
  886. self.fCurrentStateFilename = None
  887. self.fControlChannel = 0
  888. self.fParameterCount = 0
  889. self.fParameterList = [] # (type, id, widget)
  890. self.fParametersToUpdate = [] # (id, value)
  891. self.fTabIconOff = QIcon(":/bitmaps/led_off.png")
  892. self.fTabIconOn = QIcon(":/bitmaps/led_yellow.png")
  893. self.fTabIconCount = 0
  894. self.fTabIconTimers = []
  895. self.fScrollAreaSetup = False
  896. self.ui.dial_drywet.setPixmap(3)
  897. self.ui.dial_drywet.setLabel("Dry/Wet")
  898. self.ui.dial_vol.setPixmap(3)
  899. self.ui.dial_vol.setLabel("Volume")
  900. self.ui.dial_b_left.setPixmap(4)
  901. self.ui.dial_b_left.setLabel("L")
  902. self.ui.dial_b_right.setPixmap(4)
  903. self.ui.dial_b_right.setLabel("R")
  904. self.ui.dial_drywet.setCustomPaint(self.ui.dial_drywet.CUSTOM_PAINT_CARLA_WET)
  905. self.ui.dial_vol.setCustomPaint(self.ui.dial_vol.CUSTOM_PAINT_CARLA_VOL)
  906. self.ui.dial_b_left.setCustomPaint(self.ui.dial_b_left.CUSTOM_PAINT_CARLA_L)
  907. self.ui.dial_b_right.setCustomPaint(self.ui.dial_b_right.CUSTOM_PAINT_CARLA_R)
  908. self.ui.keyboard.setMode(self.ui.keyboard.HORIZONTAL)
  909. self.ui.keyboard.setOctaves(6)
  910. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  911. self.ui.scrollArea.ensureVisible(self.ui.keyboard.width() / 5, 0)
  912. self.ui.scrollArea.setEnabled(False)
  913. self.ui.scrollArea.setVisible(False)
  914. if Carla.isLocal:
  915. self.connect(self.ui.b_save_state, SIGNAL("clicked()"), SLOT("slot_saveState()"))
  916. self.connect(self.ui.b_load_state, SIGNAL("clicked()"), SLOT("slot_loadState()"))
  917. else:
  918. self.ui.b_load_state.setEnabled(False)
  919. self.ui.b_save_state.setEnabled(False)
  920. self.connect(self.ui.ch_fixed_buffer, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  921. self.connect(self.ui.ch_force_stereo, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  922. self.connect(self.ui.ch_map_program_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  923. self.connect(self.ui.ch_use_chunks, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  924. self.connect(self.ui.ch_send_control_changes, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  925. self.connect(self.ui.ch_send_channel_pressure, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  926. self.connect(self.ui.ch_send_note_aftertouch, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  927. self.connect(self.ui.ch_send_pitchbend, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  928. self.connect(self.ui.ch_send_all_sound_off, SIGNAL("clicked(bool)"), SLOT("slot_optionChanged(bool)"))
  929. self.connect(self.ui.dial_drywet, SIGNAL("valueChanged(int)"), SLOT("slot_dryWetChanged(int)"))
  930. self.connect(self.ui.dial_vol, SIGNAL("valueChanged(int)"), SLOT("slot_volumeChanged(int)"))
  931. self.connect(self.ui.dial_b_left, SIGNAL("valueChanged(int)"), SLOT("slot_balanceLeftChanged(int)"))
  932. self.connect(self.ui.dial_b_right, SIGNAL("valueChanged(int)"), SLOT("slot_balanceRightChanged(int)"))
  933. self.connect(self.ui.sb_ctrl_channel, SIGNAL("valueChanged(int)"), SLOT("slot_ctrlChannelChanged(int)"))
  934. self.connect(self.ui.dial_drywet, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  935. self.connect(self.ui.dial_vol, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  936. self.connect(self.ui.dial_b_left, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  937. self.connect(self.ui.dial_b_right, SIGNAL("customContextMenuRequested(QPoint)"), SLOT("slot_showCustomDialMenu()"))
  938. self.connect(self.ui.keyboard, SIGNAL("noteOn(int)"), SLOT("slot_noteOn(int)"))
  939. self.connect(self.ui.keyboard, SIGNAL("noteOff(int)"), SLOT("slot_noteOff(int)"))
  940. self.connect(self.ui.keyboard, SIGNAL("notesOn()"), SLOT("slot_notesOn()"))
  941. self.connect(self.ui.keyboard, SIGNAL("notesOff()"), SLOT("slot_notesOff()"))
  942. self.connect(self.ui.cb_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_programIndexChanged(int)"))
  943. self.connect(self.ui.cb_midi_programs, SIGNAL("currentIndexChanged(int)"), SLOT("slot_midiProgramIndexChanged(int)"))
  944. self.connect(self, SIGNAL("finished(int)"), SLOT("slot_finished()"))
  945. self.reloadAll()
  946. def reloadAll(self):
  947. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  948. self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"])
  949. self.fPluginInfo["name"] = cString(self.fPluginInfo["name"])
  950. self.fPluginInfo["label"] = cString(self.fPluginInfo["label"])
  951. self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"])
  952. self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"])
  953. self.reloadInfo()
  954. self.reloadParameters()
  955. self.reloadPrograms()
  956. if not self.ui.scrollArea.isEnabled():
  957. self.resize(self.width(), self.height()-self.ui.scrollArea.height())
  958. def reloadInfo(self):
  959. pluginName = cString(Carla.host.get_real_plugin_name(self.fPluginId))
  960. pluginType = self.fPluginInfo['type']
  961. pluginHints = self.fPluginInfo['hints']
  962. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  963. midiCountInfo = Carla.host.get_midi_port_count_info(self.fPluginId)
  964. paramCountInfo = Carla.host.get_parameter_count_info(self.fPluginId)
  965. if pluginType == PLUGIN_INTERNAL:
  966. self.ui.le_type.setText(self.tr("Internal"))
  967. elif pluginType == PLUGIN_LADSPA:
  968. self.ui.le_type.setText("LADSPA")
  969. elif pluginType == PLUGIN_DSSI:
  970. self.ui.le_type.setText("DSSI")
  971. elif pluginType == PLUGIN_LV2:
  972. self.ui.le_type.setText("LV2")
  973. elif pluginType == PLUGIN_VST:
  974. self.ui.le_type.setText("VST")
  975. elif pluginType == PLUGIN_VST3:
  976. self.ui.le_type.setText("VST3")
  977. elif pluginType == PLUGIN_GIG:
  978. self.ui.le_type.setText("GIG")
  979. elif pluginType == PLUGIN_SF2:
  980. self.ui.le_type.setText("SF2")
  981. elif pluginType == PLUGIN_SFZ:
  982. self.ui.le_type.setText("SFZ")
  983. else:
  984. self.ui.le_type.setText(self.tr("Unknown"))
  985. self.ui.le_name.setText(pluginName)
  986. self.ui.le_name.setToolTip(pluginName)
  987. self.ui.le_label.setText(self.fPluginInfo['label'])
  988. self.ui.le_label.setToolTip(self.fPluginInfo['label'])
  989. self.ui.le_maker.setText(self.fPluginInfo['maker'])
  990. self.ui.le_maker.setToolTip(self.fPluginInfo['maker'])
  991. self.ui.le_copyright.setText(self.fPluginInfo['copyright'])
  992. self.ui.le_copyright.setToolTip(self.fPluginInfo['copyright'])
  993. self.ui.le_unique_id.setText(str(self.fPluginInfo['uniqueId']))
  994. self.ui.le_unique_id.setToolTip(str(self.fPluginInfo['uniqueId']))
  995. self.ui.le_ains.setText(str(audioCountInfo['ins']))
  996. self.ui.le_aouts.setText(str(audioCountInfo['outs']))
  997. self.ui.le_params.setText(str(paramCountInfo['ins']))
  998. self.ui.label_plugin.setText("\n%s\n" % self.fPluginInfo['name'])
  999. self.setWindowTitle(self.fPluginInfo['name'])
  1000. if self.fPluginInfo['latency'] > 0:
  1001. self.ui.le_latency.setText("%i samples" % self.fPluginInfo['latency'])
  1002. else:
  1003. self.ui.le_latency.setText(self.tr("None"))
  1004. self.ui.dial_drywet.setEnabled(pluginHints & PLUGIN_CAN_DRYWET)
  1005. self.ui.dial_vol.setEnabled(pluginHints & PLUGIN_CAN_VOLUME)
  1006. self.ui.dial_b_left.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1007. self.ui.dial_b_right.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  1008. self.ui.ch_fixed_buffer.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FIXED_BUFFER)
  1009. self.ui.ch_fixed_buffer.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FIXED_BUFFER)
  1010. self.ui.ch_force_stereo.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FORCE_STEREO)
  1011. self.ui.ch_force_stereo.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FORCE_STEREO)
  1012. self.ui.ch_map_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1013. self.ui.ch_map_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  1014. self.ui.ch_use_chunks.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_USE_CHUNKS)
  1015. self.ui.ch_use_chunks.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_USE_CHUNKS)
  1016. self.ui.ch_send_control_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1017. self.ui.ch_send_control_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  1018. self.ui.ch_send_channel_pressure.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1019. self.ui.ch_send_channel_pressure.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  1020. self.ui.ch_send_note_aftertouch.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1021. self.ui.ch_send_note_aftertouch.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  1022. self.ui.ch_send_pitchbend.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1023. self.ui.ch_send_pitchbend.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PITCHBEND)
  1024. self.ui.ch_send_all_sound_off.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1025. self.ui.ch_send_all_sound_off.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  1026. # Show/hide keyboard
  1027. showKeyboard = (pluginHints & PLUGIN_IS_SYNTH) != 0 or (midiCountInfo['ins'] > 0 < midiCountInfo['outs'])
  1028. self.ui.scrollArea.setEnabled(showKeyboard)
  1029. self.ui.scrollArea.setVisible(showKeyboard)
  1030. # Force-Update parent for new hints
  1031. if self.fRealParent:
  1032. self.fRealParent.recheckPluginHints(pluginHints)
  1033. def reloadParameters(self):
  1034. parameterCount = Carla.host.get_parameter_count(self.fPluginId)
  1035. # Reset
  1036. self.fParameterCount = 0
  1037. self.fParameterList = []
  1038. self.fParametersToUpdate = []
  1039. self.fTabIconCount = 0
  1040. self.fTabIconTimers = []
  1041. # Remove all previous parameters
  1042. for i in range(self.ui.tabWidget.count()-1):
  1043. self.ui.tabWidget.widget(1).deleteLater()
  1044. self.ui.tabWidget.removeTab(1)
  1045. if parameterCount <= 0:
  1046. pass
  1047. elif parameterCount <= Carla.maxParameters:
  1048. paramInputListFull = []
  1049. paramOutputListFull = []
  1050. paramInputList = [] # ([params], width)
  1051. paramInputWidth = 0
  1052. paramOutputList = [] # ([params], width)
  1053. paramOutputWidth = 0
  1054. for i in range(parameterCount):
  1055. paramInfo = Carla.host.get_parameter_info(self.fPluginId, i)
  1056. paramData = Carla.host.get_parameter_data(self.fPluginId, i)
  1057. paramRanges = Carla.host.get_parameter_ranges(self.fPluginId, i)
  1058. if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT):
  1059. continue
  1060. parameter = {
  1061. 'type': paramData['type'],
  1062. 'hints': paramData['hints'],
  1063. 'name': cString(paramInfo['name']),
  1064. 'unit': cString(paramInfo['unit']),
  1065. 'scalePoints': [],
  1066. 'index': paramData['index'],
  1067. 'default': paramRanges['def'],
  1068. 'minimum': paramRanges['min'],
  1069. 'maximum': paramRanges['max'],
  1070. 'step': paramRanges['step'],
  1071. 'stepSmall': paramRanges['stepSmall'],
  1072. 'stepLarge': paramRanges['stepLarge'],
  1073. 'midiCC': paramData['midiCC'],
  1074. 'midiChannel': paramData['midiChannel'],
  1075. 'current': Carla.host.get_current_parameter_value(self.fPluginId, i)
  1076. }
  1077. for j in range(paramInfo['scalePointCount']):
  1078. scalePointInfo = Carla.host.get_parameter_scalepoint_info(self.fPluginId, i, j)
  1079. scalePointLabel = cString(scalePointInfo['label'])
  1080. scalePointLabel = scalePointLabel[:50] + (scalePointLabel[50:] and "...")
  1081. parameter['scalePoints'].append({
  1082. 'value': scalePointInfo['value'],
  1083. 'label': cString(scalePointInfo['label'])
  1084. })
  1085. parameter['name'] = parameter['name'][:30] + (parameter['name'][30:] and "...")
  1086. # -----------------------------------------------------------------
  1087. # Get width values, in packs of 10
  1088. if parameter['type'] == PARAMETER_INPUT:
  1089. paramInputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1090. if paramInputWidthTMP > paramInputWidth:
  1091. paramInputWidth = paramInputWidthTMP
  1092. paramInputList.append(parameter)
  1093. if len(paramInputList) == 10:
  1094. paramInputListFull.append((paramInputList, paramInputWidth))
  1095. paramInputList = []
  1096. paramInputWidth = 0
  1097. else:
  1098. paramOutputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  1099. if paramOutputWidthTMP > paramOutputWidth:
  1100. paramOutputWidth = paramOutputWidthTMP
  1101. paramOutputList.append(parameter)
  1102. if len(paramOutputList) == 10:
  1103. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1104. paramOutputList = []
  1105. paramOutputWidth = 0
  1106. # for i in range(parameterCount)
  1107. else:
  1108. # Final page width values
  1109. if 0 < len(paramInputList) < 10:
  1110. paramInputListFull.append((paramInputList, paramInputWidth))
  1111. if 0 < len(paramOutputList) < 10:
  1112. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  1113. # -----------------------------------------------------------------
  1114. # Create parameter widgets
  1115. self._createParameterWidgets(PARAMETER_INPUT, paramInputListFull, self.tr("Parameters"))
  1116. self._createParameterWidgets(PARAMETER_OUTPUT, paramOutputListFull, self.tr("Outputs"))
  1117. else: # > Carla.maxParameters
  1118. fakeName = self.tr("This plugin has too many parameters to display here!")
  1119. paramFakeListFull = []
  1120. paramFakeList = []
  1121. paramFakeWidth = QFontMetrics(self.font()).width(fakeName)
  1122. parameter = {
  1123. 'type': PARAMETER_UNKNOWN,
  1124. 'hints': 0,
  1125. 'name': fakeName,
  1126. 'unit': "",
  1127. 'scalePoints': [],
  1128. 'index': 0,
  1129. 'default': 0,
  1130. 'minimum': 0,
  1131. 'maximum': 0,
  1132. 'step': 0,
  1133. 'stepSmall': 0,
  1134. 'stepLarge': 0,
  1135. 'midiCC': -1,
  1136. 'midiChannel': 0,
  1137. 'current': 0.0
  1138. }
  1139. paramFakeList.append(parameter)
  1140. paramFakeListFull.append((paramFakeList, paramFakeWidth))
  1141. self._createParameterWidgets(PARAMETER_UNKNOWN, paramFakeListFull, self.tr("Information"))
  1142. def reloadPrograms(self):
  1143. # Programs
  1144. self.ui.cb_programs.blockSignals(True)
  1145. self.ui.cb_programs.clear()
  1146. programCount = Carla.host.get_program_count(self.fPluginId)
  1147. if programCount > 0:
  1148. self.ui.cb_programs.setEnabled(True)
  1149. self.ui.label_programs.setEnabled(True)
  1150. for i in range(programCount):
  1151. pName = cString(Carla.host.get_program_name(self.fPluginId, i))
  1152. pName = pName[:40] + (pName[40:] and "...")
  1153. self.ui.cb_programs.addItem(pName)
  1154. self.fCurrentProgram = Carla.host.get_current_program_index(self.fPluginId)
  1155. self.ui.cb_programs.setCurrentIndex(self.fCurrentProgram)
  1156. else:
  1157. self.fCurrentProgram = -1
  1158. self.ui.cb_programs.setEnabled(False)
  1159. self.ui.label_programs.setEnabled(False)
  1160. self.ui.cb_programs.blockSignals(False)
  1161. # MIDI Programs
  1162. self.ui.cb_midi_programs.blockSignals(True)
  1163. self.ui.cb_midi_programs.clear()
  1164. midiProgramCount = Carla.host.get_midi_program_count(self.fPluginId)
  1165. if midiProgramCount > 0:
  1166. self.ui.cb_midi_programs.setEnabled(True)
  1167. self.ui.label_midi_programs.setEnabled(True)
  1168. for i in range(midiProgramCount):
  1169. mpData = Carla.host.get_midi_program_data(self.fPluginId, i)
  1170. mpBank = int(mpData['bank'])
  1171. mpProg = int(mpData['program'])
  1172. mpName = cString(mpData['name'])
  1173. mpName = mpName[:40] + (mpName[40:] and "...")
  1174. self.ui.cb_midi_programs.addItem("%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  1175. self.fCurrentMidiProgram = Carla.host.get_current_midi_program_index(self.fPluginId)
  1176. self.ui.cb_midi_programs.setCurrentIndex(self.fCurrentMidiProgram)
  1177. else:
  1178. self.fCurrentMidiProgram = -1
  1179. self.ui.cb_midi_programs.setEnabled(False)
  1180. self.ui.label_midi_programs.setEnabled(False)
  1181. self.ui.cb_midi_programs.blockSignals(False)
  1182. # Automatically change to Midi Programs tab
  1183. if midiProgramCount > 0 and programCount == 0:
  1184. self.ui.tab_programs.setCurrentIndex(1)
  1185. def updateInfo(self):
  1186. # Update current program text
  1187. if self.ui.cb_programs.count() > 0:
  1188. pIndex = self.ui.cb_programs.currentIndex()
  1189. pName = cString(Carla.host.get_program_name(self.fPluginId, pIndex))
  1190. pName = pName[:40] + (pName[40:] and "...")
  1191. self.ui.cb_programs.setItemText(pIndex, pName)
  1192. # Update current midi program text
  1193. if self.ui.cb_midi_programs.count() > 0:
  1194. mpIndex = self.ui.cb_midi_programs.currentIndex()
  1195. mpData = Carla.host.get_midi_program_data(self.fPluginId, mpIndex)
  1196. mpBank = int(mpData['bank'])
  1197. mpProg = int(mpData['program'])
  1198. mpName = cString(mpData['name'])
  1199. mpName = mpName[:40] + (mpName[40:] and "...")
  1200. self.ui.cb_midi_programs.setItemText(mpIndex, "%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  1201. # Update all parameter values
  1202. for paramType, paramId, paramWidget in self.fParameterList:
  1203. paramWidget.setValue(Carla.host.get_current_parameter_value(self.fPluginId, paramId), False)
  1204. paramWidget.update()
  1205. def setParameterValue(self, parameterId, value):
  1206. for paramItem in self.fParametersToUpdate:
  1207. if paramItem[0] == parameterId:
  1208. paramItem[1] = value
  1209. break
  1210. else:
  1211. self.fParametersToUpdate.append([parameterId, value])
  1212. def setParameterDefault(self, parameterId, value):
  1213. for paramType, paramId, paramWidget in self.fParameterList:
  1214. if paramId == parameterId:
  1215. paramWidget.setDefault(value)
  1216. break
  1217. def setParameterMidiControl(self, parameterId, control):
  1218. for paramType, paramId, paramWidget in self.fParameterList:
  1219. if paramId == parameterId:
  1220. paramWidget.setMidiControl(control)
  1221. break
  1222. def setParameterMidiChannel(self, parameterId, channel):
  1223. for paramType, paramId, paramWidget in self.fParameterList:
  1224. if paramId == parameterId:
  1225. paramWidget.setMidiChannel(channel)
  1226. break
  1227. def setProgram(self, index):
  1228. self.ui.cb_programs.blockSignals(True)
  1229. self.ui.cb_programs.setCurrentIndex(index)
  1230. self.ui.cb_programs.blockSignals(False)
  1231. def setMidiProgram(self, index):
  1232. self.ui.cb_midi_programs.blockSignals(True)
  1233. self.ui.cb_midi_programs.setCurrentIndex(index)
  1234. self.ui.cb_midi_programs.blockSignals(False)
  1235. def sendNoteOn(self, channel, note):
  1236. if self.fControlChannel == channel:
  1237. self.ui.keyboard.sendNoteOn(note, False)
  1238. def sendNoteOff(self, channel, note):
  1239. if self.fControlChannel == channel:
  1240. self.ui.keyboard.sendNoteOff(note, False)
  1241. def setVisible(self, yesNo):
  1242. if yesNo:
  1243. if not self.fGeometry.isNull():
  1244. self.restoreGeometry(self.fGeometry)
  1245. else:
  1246. self.fGeometry = self.saveGeometry()
  1247. QDialog.setVisible(self, yesNo)
  1248. def idleSlow(self):
  1249. # Check Tab icons
  1250. for i in range(len(self.fTabIconTimers)):
  1251. if self.fTabIconTimers[i] == ICON_STATE_ON:
  1252. self.fTabIconTimers[i] = ICON_STATE_WAIT
  1253. elif self.fTabIconTimers[i] == ICON_STATE_WAIT:
  1254. self.fTabIconTimers[i] = ICON_STATE_OFF
  1255. elif self.fTabIconTimers[i] == ICON_STATE_OFF:
  1256. self.fTabIconTimers[i] = ICON_STATE_NULL
  1257. self.ui.tabWidget.setTabIcon(i+1, self.fTabIconOff)
  1258. # Check parameters needing update
  1259. for index, value in self.fParametersToUpdate:
  1260. if index == PARAMETER_DRYWET:
  1261. self.ui.dial_drywet.blockSignals(True)
  1262. self.ui.dial_drywet.setValue(value * 1000)
  1263. self.ui.dial_drywet.blockSignals(False)
  1264. elif index == PARAMETER_VOLUME:
  1265. self.ui.dial_vol.blockSignals(True)
  1266. self.ui.dial_vol.setValue(value * 1000)
  1267. self.ui.dial_vol.blockSignals(False)
  1268. elif index == PARAMETER_BALANCE_LEFT:
  1269. self.ui.dial_b_left.blockSignals(True)
  1270. self.ui.dial_b_left.setValue(value * 1000)
  1271. self.ui.dial_b_left.blockSignals(False)
  1272. elif index == PARAMETER_BALANCE_RIGHT:
  1273. self.ui.dial_b_right.blockSignals(True)
  1274. self.ui.dial_b_right.setValue(value * 1000)
  1275. self.ui.dial_b_right.blockSignals(False)
  1276. elif index == PARAMETER_PANNING:
  1277. pass
  1278. #self.ui.dial_pan.blockSignals(True)
  1279. #self.ui.dial_pan.setValue(value * 1000, True, False)
  1280. #self.ui.dial_pan.blockSignals(False)
  1281. elif index == PARAMETER_CTRL_CHANNEL:
  1282. self.fControlChannel = int(value)
  1283. self.ui.sb_ctrl_channel.blockSignals(True)
  1284. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  1285. self.ui.sb_ctrl_channel.blockSignals(False)
  1286. self.ui.keyboard.allNotesOff()
  1287. elif index >= 0:
  1288. for paramType, paramId, paramWidget in self.fParameterList:
  1289. if paramId == index:
  1290. paramWidget.setValue(value, False)
  1291. if paramType == PARAMETER_INPUT:
  1292. tabIndex = paramWidget.tabIndex()
  1293. if self.fTabIconTimers[tabIndex-1] == ICON_STATE_NULL:
  1294. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOn)
  1295. self.fTabIconTimers[tabIndex-1] = ICON_STATE_ON
  1296. break
  1297. # Clear all parameters
  1298. self.fParametersToUpdate = []
  1299. # Update parameter outputs
  1300. for paramType, paramId, paramWidget in self.fParameterList:
  1301. if paramType == PARAMETER_OUTPUT:
  1302. value = Carla.host.get_current_parameter_value(self.fPluginId, paramId)
  1303. paramWidget.setValue(value, False)
  1304. @pyqtSlot()
  1305. def slot_saveState(self):
  1306. if self.fCurrentStateFilename:
  1307. askTry = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  1308. if askTry == QMessageBox.Ok:
  1309. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1310. self.fCurrentStateFilename = None
  1311. fileFilter = self.tr("Carla State File (*.carxs)")
  1312. filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Plugin State File"), filter=fileFilter)
  1313. if filenameTry:
  1314. if not filenameTry.endswith(".carxs"):
  1315. filenameTry += ".carxs"
  1316. self.fCurrentStateFilename = filenameTry
  1317. Carla.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1318. @pyqtSlot()
  1319. def slot_loadState(self):
  1320. fileFilter = self.tr("Carla State File (*.carxs)")
  1321. filenameTry = QFileDialog.getOpenFileName(self, self.tr("Open Plugin State File"), filter=fileFilter)
  1322. if filenameTry:
  1323. self.fCurrentStateFilename = filenameTry
  1324. Carla.host.load_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  1325. @pyqtSlot(bool)
  1326. def slot_optionChanged(self, clicked):
  1327. sender = self.sender()
  1328. if sender == self.ui.ch_fixed_buffer:
  1329. option = PLUGIN_OPTION_FIXED_BUFFER
  1330. elif sender == self.ui.ch_force_stereo:
  1331. option = PLUGIN_OPTION_FORCE_STEREO
  1332. elif sender == self.ui.ch_map_program_changes:
  1333. option = PLUGIN_OPTION_MAP_PROGRAM_CHANGES
  1334. elif sender == self.ui.ch_use_chunks:
  1335. option = PLUGIN_OPTION_USE_CHUNKS
  1336. elif sender == self.ui.ch_send_control_changes:
  1337. option = PLUGIN_OPTION_SEND_CONTROL_CHANGES
  1338. elif sender == self.ui.ch_send_channel_pressure:
  1339. option = PLUGIN_OPTION_SEND_CHANNEL_PRESSURE
  1340. elif sender == self.ui.ch_send_note_aftertouch:
  1341. option = PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH
  1342. elif sender == self.ui.ch_send_pitchbend:
  1343. option = PLUGIN_OPTION_SEND_PITCHBEND
  1344. elif sender == self.ui.ch_send_all_sound_off:
  1345. option = PLUGIN_OPTION_SEND_ALL_SOUND_OFF
  1346. else:
  1347. return
  1348. Carla.host.set_option(self.fPluginId, option, clicked)
  1349. @pyqtSlot(int)
  1350. def slot_dryWetChanged(self, value):
  1351. Carla.host.set_drywet(self.fPluginId, float(value)/1000)
  1352. @pyqtSlot(int)
  1353. def slot_volumeChanged(self, value):
  1354. Carla.host.set_volume(self.fPluginId, float(value)/1000)
  1355. @pyqtSlot(int)
  1356. def slot_balanceLeftChanged(self, value):
  1357. Carla.host.set_balance_left(self.fPluginId, float(value)/1000)
  1358. @pyqtSlot(int)
  1359. def slot_balanceRightChanged(self, value):
  1360. Carla.host.set_balance_right(self.fPluginId, float(value)/1000)
  1361. @pyqtSlot(int)
  1362. def slot_panningChanged(self, value):
  1363. Carla.host.set_panning(self.fPluginId, float(value)/1000)
  1364. @pyqtSlot(int)
  1365. def slot_ctrlChannelChanged(self, value):
  1366. self.fControlChannel = value-1
  1367. Carla.host.set_ctrl_channel(self.fPluginId, self.fControlChannel)
  1368. self.ui.keyboard.allNotesOff()
  1369. @pyqtSlot(int, float)
  1370. def slot_parameterValueChanged(self, parameterId, value):
  1371. Carla.host.set_parameter_value(self.fPluginId, parameterId, value)
  1372. @pyqtSlot(int, int)
  1373. def slot_parameterMidiControlChanged(self, parameterId, control):
  1374. Carla.host.set_parameter_midi_cc(self.fPluginId, parameterId, control)
  1375. @pyqtSlot(int, int)
  1376. def slot_parameterMidiChannelChanged(self, parameterId, channel):
  1377. Carla.host.set_parameter_midi_channel(self.fPluginId, parameterId, channel-1)
  1378. @pyqtSlot(int)
  1379. def slot_programIndexChanged(self, index):
  1380. if self.fCurrentProgram != index:
  1381. self.fCurrentProgram = index
  1382. Carla.host.set_program(self.fPluginId, index)
  1383. @pyqtSlot(int)
  1384. def slot_midiProgramIndexChanged(self, index):
  1385. if self.fCurrentMidiProgram != index:
  1386. self.fCurrentMidiProgram = index
  1387. Carla.host.set_midi_program(self.fPluginId, index)
  1388. @pyqtSlot(int)
  1389. def slot_noteOn(self, note):
  1390. if self.fControlChannel >= 0:
  1391. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 100)
  1392. @pyqtSlot(int)
  1393. def slot_noteOff(self, note):
  1394. if self.fControlChannel >= 0:
  1395. Carla.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 0)
  1396. @pyqtSlot()
  1397. def slot_notesOn(self):
  1398. if self.fRealParent:
  1399. self.fRealParent.ui.led_midi.setChecked(True)
  1400. @pyqtSlot()
  1401. def slot_notesOff(self):
  1402. if self.fRealParent:
  1403. self.fRealParent.ui.led_midi.setChecked(False)
  1404. @pyqtSlot()
  1405. def slot_finished(self):
  1406. if self.fRealParent:
  1407. self.fRealParent.editClosed()
  1408. @pyqtSlot()
  1409. def slot_showCustomDialMenu(self):
  1410. dialName = self.sender().objectName()
  1411. if dialName == "dial_drywet":
  1412. minimum = 0
  1413. maximum = 100
  1414. default = 100
  1415. label = "Dry/Wet"
  1416. elif dialName == "dial_vol":
  1417. minimum = 0
  1418. maximum = 127
  1419. default = 100
  1420. label = "Volume"
  1421. elif dialName == "dial_b_left":
  1422. minimum = -100
  1423. maximum = 100
  1424. default = -100
  1425. label = "Balance-Left"
  1426. elif dialName == "dial_b_right":
  1427. minimum = -100
  1428. maximum = 100
  1429. default = 100
  1430. label = "Balance-Right"
  1431. elif dialName == "dial_panning":
  1432. minimum = -100
  1433. maximum = 100
  1434. default = 0
  1435. label = "Panning"
  1436. else:
  1437. minimum = 0
  1438. maximum = 100
  1439. default = 100
  1440. label = "Unknown"
  1441. current = self.sender().value() / 10
  1442. menu = QMenu(self)
  1443. actReset = menu.addAction(self.tr("Reset (%i%%)" % default))
  1444. menu.addSeparator()
  1445. actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % minimum))
  1446. actCenter = menu.addAction(self.tr("Set to Center"))
  1447. actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % maximum))
  1448. menu.addSeparator()
  1449. actSet = menu.addAction(self.tr("Set value..."))
  1450. if label not in ("Balance-Left", "Balance-Right"):
  1451. menu.removeAction(actCenter)
  1452. actSelected = menu.exec_(QCursor.pos())
  1453. if actSelected == actSet:
  1454. valueTry = QInputDialog.getInteger(self, self.tr("Set value"), label, current, minimum, maximum, 1)
  1455. if valueTry[1]:
  1456. value = valueTry[0] * 10
  1457. else:
  1458. return
  1459. elif actSelected == actMinimum:
  1460. value = minimum * 10
  1461. elif actSelected == actMaximum:
  1462. value = maximum * 10
  1463. elif actSelected == actReset:
  1464. value = default * 10
  1465. elif actSelected == actCenter:
  1466. value = 0
  1467. else:
  1468. return
  1469. if label == "Dry/Wet":
  1470. self.ui.dial_drywet.setValue(value)
  1471. elif label == "Volume":
  1472. self.ui.dial_vol.setValue(value)
  1473. elif label == "Balance-Left":
  1474. self.ui.dial_b_left.setValue(value)
  1475. elif label == "Balance-Right":
  1476. self.ui.dial_b_right.setValue(value)
  1477. elif label == "Panning":
  1478. pass
  1479. #self.ui.dial_panning.setValue(value)
  1480. def _createParameterWidgets(self, paramType, paramListFull, tabPageName):
  1481. i = 1
  1482. for paramList, width in paramListFull:
  1483. if len(paramList) == 0:
  1484. break
  1485. tabIndex = self.ui.tabWidget.count()
  1486. tabPageContainer = QWidget(self.ui.tabWidget)
  1487. tabPageLayout = QVBoxLayout(tabPageContainer)
  1488. tabPageContainer.setLayout(tabPageLayout)
  1489. for paramInfo in paramList:
  1490. paramWidget = PluginParameter(tabPageContainer, paramInfo, self.fPluginId, tabIndex)
  1491. paramWidget.setLabelWidth(width)
  1492. tabPageLayout.addWidget(paramWidget)
  1493. self.fParameterList.append((paramType, paramInfo['index'], paramWidget))
  1494. if paramType == PARAMETER_INPUT:
  1495. self.connect(paramWidget, SIGNAL("valueChanged(int, double)"), SLOT("slot_parameterValueChanged(int, double)"))
  1496. self.connect(paramWidget, SIGNAL("midiControlChanged(int, int)"), SLOT("slot_parameterMidiControlChanged(int, int)"))
  1497. self.connect(paramWidget, SIGNAL("midiChannelChanged(int, int)"), SLOT("slot_parameterMidiChannelChanged(int, int)"))
  1498. tabPageLayout.addStretch()
  1499. self.ui.tabWidget.addTab(tabPageContainer, "%s (%i)" % (tabPageName, i))
  1500. i += 1
  1501. if paramType == PARAMETER_INPUT:
  1502. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOff)
  1503. self.fTabIconTimers.append(ICON_STATE_NULL)
  1504. def showEvent(self, event):
  1505. if not self.fScrollAreaSetup:
  1506. self.fScrollAreaSetup = True
  1507. minHeight = self.ui.scrollArea.height()+2
  1508. self.ui.scrollArea.setMinimumHeight(minHeight)
  1509. self.ui.scrollArea.setMaximumHeight(minHeight)
  1510. QDialog.showEvent(self, event)
  1511. def done(self, r):
  1512. QDialog.done(self, r)
  1513. self.close()
  1514. # ------------------------------------------------------------------------------------------------------------
  1515. # Plugin Widget
  1516. class PluginWidget(QFrame):
  1517. def __init__(self, parent, pluginId):
  1518. QFrame.__init__(self, parent)
  1519. self.ui = ui_carla_plugin.Ui_PluginWidget()
  1520. self.ui.setupUi(self)
  1521. self.fLastGreenLedState = False
  1522. self.fLastBlueLedState = False
  1523. self.fParameterIconTimer = ICON_STATE_NULL
  1524. self.fPluginId = pluginId
  1525. self.fPluginInfo = Carla.host.get_plugin_info(self.fPluginId)
  1526. self.fPluginInfo["binary"] = cString(self.fPluginInfo["binary"])
  1527. self.fPluginInfo["name"] = cString(self.fPluginInfo["name"])
  1528. self.fPluginInfo["label"] = cString(self.fPluginInfo["label"])
  1529. self.fPluginInfo["maker"] = cString(self.fPluginInfo["maker"])
  1530. self.fPluginInfo["copyright"] = cString(self.fPluginInfo["copyright"])
  1531. if Carla.processMode == PROCESS_MODE_CONTINUOUS_RACK:
  1532. self.fPeaksInputCount = 2
  1533. self.fPeaksOutputCount = 2
  1534. else:
  1535. audioCountInfo = Carla.host.get_audio_port_count_info(self.fPluginId)
  1536. self.fPeaksInputCount = int(audioCountInfo['ins'])
  1537. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  1538. if self.fPeaksInputCount > 2:
  1539. self.fPeaksInputCount = 2
  1540. if self.fPeaksOutputCount > 2:
  1541. self.fPeaksOutputCount = 2
  1542. # Background
  1543. self.fColorTop = QColor(60, 60, 60)
  1544. self.fColorBottom = QColor(47, 47, 47)
  1545. self.setStyleSheet("""
  1546. QLabel#label_name {
  1547. color: white;
  1548. }""")
  1549. # Colorify
  1550. #if self.m_pluginInfo['category'] == PLUGIN_CATEGORY_SYNTH:
  1551. #self.setWidgetColor(PALETTE_COLOR_WHITE)
  1552. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  1553. #self.setWidgetColor(PALETTE_COLOR_ORANGE)
  1554. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_EQ:
  1555. #self.setWidgetColor(PALETTE_COLOR_GREEN)
  1556. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  1557. #self.setWidgetColor(PALETTE_COLOR_BLUE)
  1558. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS:
  1559. #self.setWidgetColor(PALETTE_COLOR_PINK)
  1560. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR:
  1561. #self.setWidgetColor(PALETTE_COLOR_RED)
  1562. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_UTILITY:
  1563. #self.setWidgetColor(PALETTE_COLOR_YELLOW)
  1564. #elif self.m_pluginInfo['category'] == PLUGIN_CATEGORY_OTHER:
  1565. #self.setWidgetColor(PALETTE_COLOR_BROWN)
  1566. #else:
  1567. #self.setWidgetColor(PALETTE_COLOR_NONE)
  1568. self.ui.b_enable.setPixmaps(":/bitmaps/led_red.png", ":/bitmaps/led_green.png", ":/bitmaps/led_red.png")
  1569. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  1570. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  1571. self.ui.b_up.setPixmaps(":/bitmaps/button_up.png", ":/bitmaps/button_up.png", ":/bitmaps/button_up_hover.png")
  1572. self.ui.b_down.setPixmaps(":/bitmaps/button_down.png", ":/bitmaps/button_down.png", ":/bitmaps/button_down_hover.png")
  1573. self.ui.b_restore.setPixmaps(":/bitmaps/button_restore.png", ":/bitmaps/button_restore.png", ":/bitmaps/button_restore_hover.png")
  1574. self.ui.b_close.setPixmaps(":/bitmaps/button_close.png", ":/bitmaps/button_close_down.png", ":/bitmaps/button_close_hover.png")
  1575. # TODO
  1576. self.ui.b_up.setEnabled(False)
  1577. self.ui.b_down.setEnabled(False)
  1578. self.ui.b_restore.setEnabled(False)
  1579. self.ui.led_control.setColor(self.ui.led_control.YELLOW)
  1580. self.ui.led_control.setEnabled(False)
  1581. self.ui.led_midi.setColor(self.ui.led_midi.RED)
  1582. self.ui.led_midi.setEnabled(False)
  1583. self.ui.led_audio_in.setColor(self.ui.led_audio_in.GREEN)
  1584. self.ui.led_audio_in.setEnabled(False)
  1585. self.ui.led_audio_out.setColor(self.ui.led_audio_out.BLUE)
  1586. self.ui.led_audio_out.setEnabled(False)
  1587. self.ui.peak_in.setColor(self.ui.peak_in.GREEN)
  1588. self.ui.peak_in.setOrientation(self.ui.peak_in.HORIZONTAL)
  1589. self.ui.peak_out.setColor(self.ui.peak_in.BLUE)
  1590. self.ui.peak_out.setOrientation(self.ui.peak_out.HORIZONTAL)
  1591. self.ui.peak_in.setChannels(self.fPeaksInputCount)
  1592. self.ui.peak_out.setChannels(self.fPeaksOutputCount)
  1593. self.ui.label_name.setText(self.fPluginInfo['name'])
  1594. self.ui.edit_dialog = PluginEdit(self, self.fPluginId)
  1595. self.ui.edit_dialog.hide()
  1596. self.connect(self.ui.b_enable, SIGNAL("clicked(bool)"), SLOT("slot_setActive(bool)"))
  1597. self.connect(self.ui.b_gui, SIGNAL("clicked(bool)"), SLOT("slot_guiClicked(bool)"))
  1598. self.connect(self.ui.b_edit, SIGNAL("clicked(bool)"), SLOT("slot_editClicked(bool)"))
  1599. self.connect(self.ui.b_up, SIGNAL("clicked()"), SLOT("slot_upClicked()"))
  1600. self.connect(self.ui.b_down, SIGNAL("clicked()"), SLOT("slot_downClicked()"))
  1601. self.connect(self.ui.b_restore, SIGNAL("clicked()"), SLOT("slot_restoreClicked()"))
  1602. self.connect(self.ui.b_close, SIGNAL("clicked()"), SLOT("slot_closeClicked()"))
  1603. # FIXME
  1604. #self.setMaximumHeight(32)
  1605. def idleFast(self):
  1606. # Input peaks
  1607. if self.fPeaksInputCount > 0:
  1608. if self.fPeaksInputCount > 1:
  1609. peak1 = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1610. peak2 = Carla.host.get_input_peak_value(self.fPluginId, 2)
  1611. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1612. self.ui.peak_in.displayMeter(1, peak1)
  1613. self.ui.peak_in.displayMeter(2, peak2)
  1614. else:
  1615. peak = Carla.host.get_input_peak_value(self.fPluginId, 1)
  1616. ledState = bool(peak != 0.0)
  1617. self.ui.peak_in.displayMeter(1, peak)
  1618. if self.fLastGreenLedState != ledState:
  1619. self.fLastGreenLedState = ledState
  1620. self.ui.led_audio_in.setChecked(ledState)
  1621. # Output peaks
  1622. if self.fPeaksOutputCount > 0:
  1623. if self.fPeaksOutputCount > 1:
  1624. peak1 = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1625. peak2 = Carla.host.get_output_peak_value(self.fPluginId, 2)
  1626. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  1627. self.ui.peak_out.displayMeter(1, peak1)
  1628. self.ui.peak_out.displayMeter(2, peak2)
  1629. else:
  1630. peak = Carla.host.get_output_peak_value(self.fPluginId, 1)
  1631. ledState = bool(peak != 0.0)
  1632. self.ui.peak_out.displayMeter(1, peak)
  1633. if self.fLastBlueLedState != ledState:
  1634. self.fLastBlueLedState = ledState
  1635. self.ui.led_audio_out.setChecked(ledState)
  1636. def idleSlow(self):
  1637. # Parameter Activity LED
  1638. if self.fParameterIconTimer == ICON_STATE_ON:
  1639. self.fParameterIconTimer = ICON_STATE_WAIT
  1640. self.ui.led_control.setChecked(True)
  1641. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  1642. self.fParameterIconTimer = ICON_STATE_OFF
  1643. elif self.fParameterIconTimer == ICON_STATE_OFF:
  1644. self.fParameterIconTimer = ICON_STATE_NULL
  1645. self.ui.led_control.setChecked(False)
  1646. # Update edit dialog
  1647. self.ui.edit_dialog.idleSlow()
  1648. def editClosed(self):
  1649. self.ui.b_edit.setChecked(False)
  1650. def recheckPluginHints(self, hints):
  1651. self.fPluginInfo['hints'] = hints
  1652. self.ui.b_gui.setEnabled(hints & PLUGIN_HAS_GUI)
  1653. def setActive(self, active, sendGui=False, sendCallback=True):
  1654. if sendGui: self.ui.b_enable.setChecked(active)
  1655. if sendCallback: Carla.host.set_active(self.fPluginId, active)
  1656. if active:
  1657. self.ui.edit_dialog.ui.keyboard.allNotesOff()
  1658. def setParameterDefault(self, parameterId, value):
  1659. self.ui.edit_dialog.setParameterDefault(parameterId, value)
  1660. def setParameterValue(self, parameterId, value):
  1661. self.fParameterIconTimer = ICON_STATE_ON
  1662. if parameterId == PARAMETER_ACTIVE:
  1663. return self.setActive(bool(value), True, False)
  1664. self.ui.edit_dialog.setParameterValue(parameterId, value)
  1665. def setParameterMidiControl(self, parameterId, control):
  1666. self.ui.edit_dialog.setParameterMidiControl(parameterId, control)
  1667. def setParameterMidiChannel(self, parameterId, channel):
  1668. self.ui.edit_dialog.setParameterMidiChannel(parameterId, channel)
  1669. def setProgram(self, index):
  1670. self.fParameterIconTimer = ICON_STATE_ON
  1671. self.ui.edit_dialog.setProgram(index)
  1672. def setMidiProgram(self, index):
  1673. self.fParameterIconTimer = ICON_STATE_ON
  1674. self.ui.edit_dialog.setMidiProgram(index)
  1675. def sendNoteOn(self, channel, note):
  1676. self.ui.edit_dialog.sendNoteOn(channel, note)
  1677. def sendNoteOff(self, channel, note):
  1678. self.ui.edit_dialog.sendNoteOff(channel, note)
  1679. def setId(self, idx):
  1680. self.fPluginId = idx
  1681. self.ui.edit_dialog.fPluginId = idx
  1682. def setRefreshRate(self, rate):
  1683. self.ui.peak_in.setRefreshRate(rate)
  1684. self.ui.peak_out.setRefreshRate(rate)
  1685. def paintEvent(self, event):
  1686. painter = QPainter(self)
  1687. areaX = self.ui.led_control.x()
  1688. # bottom line
  1689. painter.setPen(self.fColorBottom)
  1690. painter.setBrush(self.fColorBottom)
  1691. painter.drawRect(0, self.height()-5, areaX, 5)
  1692. # top line
  1693. painter.drawLine(0, 0, areaX+40, 0)
  1694. # name -> leds arc
  1695. path = QPainterPath()
  1696. path.moveTo(areaX-80, self.height())
  1697. path.cubicTo(areaX+40, self.height()-5, areaX-40, 30, areaX+20, 0)
  1698. path.lineTo(areaX+20, self.height())
  1699. painter.drawPath(path)
  1700. # fill the rest
  1701. painter.drawRect(areaX+20, 0, self.width(), self.height())
  1702. #painter.drawLine(0, 3, self.width(), 3)
  1703. #painter.drawLine(0, self.height() - 4, self.width(), self.height() - 4)
  1704. #painter.setPen(self.m_color2)
  1705. #painter.drawLine(0, 2, self.width(), 2)
  1706. #painter.drawLine(0, self.height() - 3, self.width(), self.height() - 3)
  1707. #painter.setPen(self.m_color3)
  1708. #painter.drawLine(0, 1, self.width(), 1)
  1709. #painter.drawLine(0, self.height() - 2, self.width(), self.height() - 2)
  1710. #painter.setPen(self.m_color4)
  1711. #painter.drawLine(0, 0, self.width(), 0)
  1712. #painter.drawLine(0, self.height() - 1, self.width(), self.height() - 1)
  1713. QFrame.paintEvent(self, event)
  1714. @pyqtSlot(bool)
  1715. def slot_setActive(self, yesNo):
  1716. self.setActive(yesNo, False, True)
  1717. @pyqtSlot(bool)
  1718. def slot_guiClicked(self, show):
  1719. Carla.host.show_gui(self.fPluginId, show)
  1720. @pyqtSlot(bool)
  1721. def slot_editClicked(self, show):
  1722. self.ui.edit_dialog.setVisible(show)
  1723. @pyqtSlot()
  1724. def slot_upClicked(self):
  1725. pass
  1726. @pyqtSlot()
  1727. def slot_downClicked(self):
  1728. pass
  1729. @pyqtSlot()
  1730. def slot_restoreClicked(self):
  1731. pass
  1732. @pyqtSlot()
  1733. def slot_closeClicked(self):
  1734. Carla.host.remove_plugin(self.fPluginId)
  1735. # ------------------------------------------------------------------------------------------------------------
  1736. # Separate Thread for Plugin Search
  1737. class SearchPluginsThread(QThread):
  1738. def __init__(self, parent):
  1739. QThread.__init__(self, parent)
  1740. self.fCheckNative = False
  1741. self.fCheckPosix32 = False
  1742. self.fCheckPosix64 = False
  1743. self.fCheckWin32 = False
  1744. self.fCheckWin64 = False
  1745. self.fCheckLADSPA = False
  1746. self.fCheckDSSI = False
  1747. self.fCheckLV2 = False
  1748. self.fCheckVST = False
  1749. self.fCheckGIG = False
  1750. self.fCheckSF2 = False
  1751. self.fCheckSFZ = False
  1752. self.fToolNative = carla_discovery_native
  1753. self.fCurCount = 0
  1754. self.fCurPercentValue = 0
  1755. self.fLastCheckValue = 0
  1756. self.fSomethingChanged = False
  1757. def somethingChanged(self):
  1758. return self.fSomethingChanged
  1759. def skipPlugin(self):
  1760. # TODO - windows and mac support
  1761. apps = " carla-discovery"
  1762. apps += " carla-discovery-native"
  1763. apps += " carla-discovery-posix32"
  1764. apps += " carla-discovery-posix64"
  1765. apps += " carla-discovery-win32.exe"
  1766. apps += " carla-discovery-win64.exe"
  1767. if LINUX:
  1768. os.system("killall -KILL %s" % apps)
  1769. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  1770. self.fCheckNative = native
  1771. self.fCheckPosix32 = posix32
  1772. self.fCheckPosix64 = posix64
  1773. self.fCheckWin32 = win32
  1774. self.fCheckWin64 = win64
  1775. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst, gig, sf2, sfz):
  1776. self.fCheckLADSPA = ladspa
  1777. self.fCheckDSSI = dssi
  1778. self.fCheckLV2 = lv2
  1779. self.fCheckVST = vst
  1780. self.fCheckGIG = gig
  1781. self.fCheckSF2 = sf2
  1782. self.fCheckSFZ = sfz
  1783. def setSearchToolNative(self, tool):
  1784. self.fToolNative = tool
  1785. def run(self):
  1786. self.fCurCount = 0
  1787. pluginCount = 0
  1788. settingsDB = QSettings("falkTX", "CarlaPlugins")
  1789. if self.fCheckLADSPA: pluginCount += 1
  1790. if self.fCheckDSSI: pluginCount += 1
  1791. if self.fCheckLV2: pluginCount += 1
  1792. if self.fCheckVST: pluginCount += 1
  1793. if self.fCheckNative:
  1794. self.fCurCount += pluginCount
  1795. if self.fCheckPosix32:
  1796. self.fCurCount += pluginCount
  1797. if self.fCheckPosix64:
  1798. self.fCurCount += pluginCount
  1799. if self.fCheckWin32:
  1800. self.fCurCount += pluginCount
  1801. if self.fCheckWin64:
  1802. self.fCurCount += pluginCount
  1803. if self.fToolNative:
  1804. if self.fCheckGIG: self.fCurCount += 1
  1805. if self.fCheckSF2: self.fCurCount += 1
  1806. if self.fCheckSFZ: self.fCurCount += 1
  1807. else:
  1808. self.fCheckGIG = False
  1809. self.fCheckSF2 = False
  1810. self.fCheckSFZ = False
  1811. if self.fCurCount == 0:
  1812. return
  1813. self.fCurPercentValue = 100 / self.fCurCount
  1814. self.fLastCheckValue = 0
  1815. if HAIKU:
  1816. OS = "HAIKU"
  1817. elif LINUX:
  1818. OS = "LINUX"
  1819. elif MACOS:
  1820. OS = "MACOS"
  1821. elif WINDOWS:
  1822. OS = "WINDOWS"
  1823. else:
  1824. OS = "UNKNOWN"
  1825. if self.fCheckLADSPA:
  1826. checkValue = 0
  1827. if haveLRDF:
  1828. if self.fCheckNative: checkValue += 0.1
  1829. if self.fCheckPosix32: checkValue += 0.1
  1830. if self.fCheckPosix64: checkValue += 0.1
  1831. if self.fCheckWin32: checkValue += 0.1
  1832. if self.fCheckWin64: checkValue += 0.1
  1833. rdfPadValue = self.fCurPercentValue * checkValue
  1834. if self.fCheckNative:
  1835. self._checkLADSPA(OS, self.fToolNative)
  1836. settingsDB.setValue("Plugins/LADSPA_native", self.fLadspaPlugins)
  1837. settingsDB.sync()
  1838. if self.fCheckPosix32:
  1839. self._checkLADSPA(OS, carla_discovery_posix32)
  1840. settingsDB.setValue("Plugins/LADSPA_posix32", self.fLadspaPlugins)
  1841. settingsDB.sync()
  1842. if self.fCheckPosix64:
  1843. self._checkLADSPA(OS, carla_discovery_posix64)
  1844. settingsDB.setValue("Plugins/LADSPA_posix64", self.fLadspaPlugins)
  1845. settingsDB.sync()
  1846. if self.fCheckWin32:
  1847. self._checkLADSPA("WINDOWS", carla_discovery_win32, not WINDOWS)
  1848. settingsDB.setValue("Plugins/LADSPA_win32", self.fLadspaPlugins)
  1849. settingsDB.sync()
  1850. if self.fCheckWin64:
  1851. self._checkLADSPA("WINDOWS", carla_discovery_win64, not WINDOWS)
  1852. settingsDB.setValue("Plugins/LADSPA_win64", self.fLadspaPlugins)
  1853. settingsDB.sync()
  1854. if haveLRDF and checkValue > 0:
  1855. startValue = self.fLastCheckValue - rdfPadValue
  1856. self._pluginLook(startValue, "LADSPA RDFs...")
  1857. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  1858. SettingsDir = os.path.join(HOME, ".config", "falkTX")
  1859. fLadspa = open(os.path.join(SettingsDir, "ladspa_rdf.db"), 'w')
  1860. json.dump(ladspaRdfInfo, fLadspa)
  1861. fLadspa.close()
  1862. if self.fCheckDSSI:
  1863. if self.fCheckNative:
  1864. self._checkDSSI(OS, self.fToolNative)
  1865. settingsDB.setValue("Plugins/DSSI_native", self.fDssiPlugins)
  1866. settingsDB.sync()
  1867. if self.fCheckPosix32:
  1868. self._checkDSSI(OS, carla_discovery_posix32)
  1869. settingsDB.setValue("Plugins/DSSI_posix32", self.fDssiPlugins)
  1870. settingsDB.sync()
  1871. if self.fCheckPosix64:
  1872. self._checkDSSI(OS, carla_discovery_posix64)
  1873. settingsDB.setValue("Plugins/DSSI_posix64", self.fDssiPlugins)
  1874. settingsDB.sync()
  1875. if self.fCheckWin32:
  1876. self._checkDSSI("WINDOWS", carla_discovery_win32, not WINDOWS)
  1877. settingsDB.setValue("Plugins/DSSI_win32", self.fDssiPlugins)
  1878. settingsDB.sync()
  1879. if self.fCheckWin64:
  1880. self._checkDSSI("WINDOWS", carla_discovery_win64, not WINDOWS)
  1881. settingsDB.setValue("Plugins/DSSI_win64", self.fDssiPlugins)
  1882. settingsDB.sync()
  1883. if self.fCheckLV2:
  1884. if self.fCheckNative:
  1885. self._checkLV2(self.fToolNative)
  1886. settingsDB.setValue("Plugins/LV2_native", self.fLv2Plugins)
  1887. settingsDB.sync()
  1888. if self.fCheckPosix32:
  1889. self._checkLV2(carla_discovery_posix32)
  1890. settingsDB.setValue("Plugins/LV2_posix32", self.fLv2Plugins)
  1891. settingsDB.sync()
  1892. if self.fCheckPosix64:
  1893. self._checkLV2(carla_discovery_posix64)
  1894. settingsDB.setValue("Plugins/LV2_posix64", self.fLv2Plugins)
  1895. settingsDB.sync()
  1896. if self.fCheckWin32:
  1897. self._checkLV2(carla_discovery_win32, not WINDOWS)
  1898. settingsDB.setValue("Plugins/LV2_win32", self.fLv2Plugins)
  1899. settingsDB.sync()
  1900. if self.fCheckWin64:
  1901. self._checkLV2(carla_discovery_win64, not WINDOWS)
  1902. settingsDB.setValue("Plugins/LV2_win64", self.fLv2Plugins)
  1903. settingsDB.sync()
  1904. if self.fCheckVST:
  1905. if self.fCheckNative:
  1906. self._checkVST(OS, self.fToolNative)
  1907. settingsDB.setValue("Plugins/VST_native", self.fVstPlugins)
  1908. settingsDB.sync()
  1909. if self.fCheckPosix32:
  1910. self._checkVST(OS, carla_discovery_posix32)
  1911. settingsDB.setValue("Plugins/VST_posix32", self.fVstPlugins)
  1912. settingsDB.sync()
  1913. if self.fCheckPosix64:
  1914. self._checkVST(OS, carla_discovery_posix64)
  1915. settingsDB.setValue("Plugins/VST_posix64", self.fVstPlugins)
  1916. settingsDB.sync()
  1917. if self.fCheckWin32:
  1918. self._checkVST("WINDOWS", carla_discovery_win32, not WINDOWS)
  1919. settingsDB.setValue("Plugins/VST_win32", self.fVstPlugins)
  1920. settingsDB.sync()
  1921. if self.fCheckWin64:
  1922. self._checkVST("WINDOWS", carla_discovery_win64, not WINDOWS)
  1923. settingsDB.setValue("Plugins/VST_win64", self.fVstPlugins)
  1924. settingsDB.sync()
  1925. if self.fCheckGIG:
  1926. self._checkKIT(Carla.GIG_PATH, "gig")
  1927. settingsDB.setValue("Plugins/GIG", self.fKitPlugins)
  1928. settingsDB.sync()
  1929. if self.fCheckSF2:
  1930. self._checkKIT(Carla.SF2_PATH, "sf2")
  1931. settingsDB.setValue("Plugins/SF2", self.fKitPlugins)
  1932. settingsDB.sync()
  1933. if self.fCheckSFZ:
  1934. self._checkKIT(Carla.SFZ_PATH, "sfz")
  1935. settingsDB.setValue("Plugins/SFZ", self.fKitPlugins)
  1936. settingsDB.sync()
  1937. def _checkLADSPA(self, OS, tool, isWine=False):
  1938. ladspaBinaries = []
  1939. self.fLadspaPlugins = []
  1940. for iPATH in Carla.LADSPA_PATH:
  1941. binaries = findBinaries(iPATH, OS)
  1942. for binary in binaries:
  1943. if binary not in ladspaBinaries:
  1944. ladspaBinaries.append(binary)
  1945. ladspaBinaries.sort()
  1946. for i in range(len(ladspaBinaries)):
  1947. ladspa = ladspaBinaries[i]
  1948. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  1949. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  1950. plugins = checkPluginLADSPA(ladspa, tool, isWine)
  1951. if plugins:
  1952. self.fLadspaPlugins.append(plugins)
  1953. self.fSomethingChanged = True
  1954. self.fLastCheckValue += self.fCurPercentValue
  1955. def _checkDSSI(self, OS, tool, isWine=False):
  1956. dssiBinaries = []
  1957. self.fDssiPlugins = []
  1958. for iPATH in Carla.DSSI_PATH:
  1959. binaries = findBinaries(iPATH, OS)
  1960. for binary in binaries:
  1961. if binary not in dssiBinaries:
  1962. dssiBinaries.append(binary)
  1963. dssiBinaries.sort()
  1964. for i in range(len(dssiBinaries)):
  1965. dssi = dssiBinaries[i]
  1966. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  1967. self._pluginLook(self.fLastCheckValue + percent, dssi)
  1968. plugins = checkPluginDSSI(dssi, tool, isWine)
  1969. if plugins:
  1970. self.fDssiPlugins.append(plugins)
  1971. self.fSomethingChanged = True
  1972. self.fLastCheckValue += self.fCurPercentValue
  1973. def _checkLV2(self, tool, isWine=False):
  1974. lv2Bundles = []
  1975. self.fLv2Plugins = []
  1976. self._pluginLook(self.fLastCheckValue, "LV2 bundles...")
  1977. for iPATH in Carla.LV2_PATH:
  1978. bundles = findLV2Bundles(iPATH)
  1979. for bundle in bundles:
  1980. if bundle not in lv2Bundles:
  1981. lv2Bundles.append(bundle)
  1982. lv2Bundles.sort()
  1983. for i in range(len(lv2Bundles)):
  1984. lv2 = lv2Bundles[i]
  1985. percent = ( float(i) / len(lv2Bundles) ) * self.fCurPercentValue
  1986. self._pluginLook(self.fLastCheckValue + percent, lv2)
  1987. plugins = checkPluginLV2(lv2, tool, isWine)
  1988. if plugins:
  1989. self.fLv2Plugins.append(plugins)
  1990. self.fSomethingChanged = True
  1991. self.fLastCheckValue += self.fCurPercentValue
  1992. def _checkVST(self, OS, tool, isWine=False):
  1993. vstBinaries = []
  1994. self.fVstPlugins = []
  1995. for iPATH in Carla.VST_PATH:
  1996. binaries = findBinaries(iPATH, OS)
  1997. for binary in binaries:
  1998. if binary not in vstBinaries:
  1999. vstBinaries.append(binary)
  2000. vstBinaries.sort()
  2001. for i in range(len(vstBinaries)):
  2002. vst = vstBinaries[i]
  2003. percent = ( float(i) / len(vstBinaries) ) * self.fCurPercentValue
  2004. self._pluginLook(self.fLastCheckValue + percent, vst)
  2005. plugins = checkPluginVST(vst, tool, isWine)
  2006. if plugins:
  2007. self.fVstPlugins.append(plugins)
  2008. self.fSomethingChanged = True
  2009. self.fLastCheckValue += self.fCurPercentValue
  2010. def _checkKIT(self, kPATH, kType):
  2011. kitFiles = []
  2012. self.fKitPlugins = []
  2013. for iPATH in kPATH:
  2014. files = findSoundKits(iPATH, kType)
  2015. for file_ in files:
  2016. if file_ not in kitFiles:
  2017. kitFiles.append(file_)
  2018. kitFiles.sort()
  2019. for i in range(len(kitFiles)):
  2020. kit = kitFiles[i]
  2021. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  2022. self._pluginLook(self.fLastCheckValue + percent, kit)
  2023. if kType == "gig":
  2024. plugins = checkPluginGIG(kit, self.fToolNative)
  2025. elif kType == "sf2":
  2026. plugins = checkPluginSF2(kit, self.fToolNative)
  2027. elif kType == "sfz":
  2028. plugins = checkPluginSFZ(kit, self.fToolNative)
  2029. else:
  2030. plugins = None
  2031. if plugins:
  2032. self.fKitPlugins.append(plugins)
  2033. self.fSomethingChanged = True
  2034. self.fLastCheckValue += self.fCurPercentValue
  2035. def _pluginLook(self, percent, plugin):
  2036. self.emit(SIGNAL("PluginLook(int, QString)"), percent, plugin)
  2037. # ------------------------------------------------------------------------------------------------------------
  2038. # Plugin Refresh Dialog
  2039. class PluginRefreshW(QDialog):
  2040. def __init__(self, parent):
  2041. QDialog.__init__(self, parent)
  2042. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  2043. self.ui.setupUi(self)
  2044. self._loadSettings()
  2045. self.ui.b_skip.setVisible(False)
  2046. if HAIKU:
  2047. self.ui.ch_posix32.setText("Haiku 32bit")
  2048. self.ui.ch_posix64.setText("Haiku 64bit")
  2049. elif LINUX:
  2050. self.ui.ch_posix32.setText("Linux 32bit")
  2051. self.ui.ch_posix64.setText("Linux 64bit")
  2052. elif MACOS:
  2053. self.ui.ch_posix32.setText("MacOS 32bit")
  2054. self.ui.ch_posix64.setText("MacOS 64bit")
  2055. self.fThread = SearchPluginsThread(self)
  2056. if carla_discovery_posix32 and not WINDOWS:
  2057. self.ui.ico_posix32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2058. else:
  2059. self.ui.ico_posix32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2060. self.ui.ch_posix32.setChecked(False)
  2061. self.ui.ch_posix32.setEnabled(False)
  2062. if carla_discovery_posix64 and not WINDOWS:
  2063. self.ui.ico_posix64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2064. else:
  2065. self.ui.ico_posix64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2066. self.ui.ch_posix64.setChecked(False)
  2067. self.ui.ch_posix64.setEnabled(False)
  2068. if carla_discovery_win32:
  2069. self.ui.ico_win32.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2070. else:
  2071. self.ui.ico_win32.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2072. self.ui.ch_win32.setChecked(False)
  2073. self.ui.ch_win32.setEnabled(False)
  2074. if carla_discovery_win64:
  2075. self.ui.ico_win64.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2076. else:
  2077. self.ui.ico_win64.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2078. self.ui.ch_win64.setChecked(False)
  2079. self.ui.ch_win64.setEnabled(False)
  2080. if haveLRDF:
  2081. self.ui.ico_rdflib.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2082. else:
  2083. self.ui.ico_rdflib.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2084. hasNative = bool(carla_discovery_native)
  2085. hasNonNative = False
  2086. if WINDOWS:
  2087. if kIs64bit:
  2088. hasNative = bool(carla_discovery_win64)
  2089. hasNonNative = bool(carla_discovery_win32)
  2090. self.fThread.setSearchToolNative(carla_discovery_win64)
  2091. self.ui.ch_win64.setChecked(False)
  2092. self.ui.ch_win64.setVisible(False)
  2093. self.ui.ico_win64.setVisible(False)
  2094. self.ui.label_win64.setVisible(False)
  2095. else:
  2096. hasNative = bool(carla_discovery_win32)
  2097. hasNonNative = bool(carla_discovery_win64)
  2098. self.fThread.setSearchToolNative(carla_discovery_win32)
  2099. self.ui.ch_win32.setChecked(False)
  2100. self.ui.ch_win32.setVisible(False)
  2101. self.ui.ico_win32.setVisible(False)
  2102. self.ui.label_win32.setVisible(False)
  2103. elif LINUX or MACOS:
  2104. if kIs64bit:
  2105. hasNonNative = bool(carla_discovery_posix32 or carla_discovery_win32 or carla_discovery_win64)
  2106. self.ui.ch_posix64.setChecked(False)
  2107. self.ui.ch_posix64.setVisible(False)
  2108. self.ui.ico_posix64.setVisible(False)
  2109. self.ui.label_posix64.setVisible(False)
  2110. else:
  2111. hasNonNative = bool(carla_discovery_posix64 or carla_discovery_win32 or carla_discovery_win64)
  2112. self.ui.ch_posix32.setChecked(False)
  2113. self.ui.ch_posix32.setVisible(False)
  2114. self.ui.ico_posix32.setVisible(False)
  2115. self.ui.label_posix32.setVisible(False)
  2116. if hasNative:
  2117. self.ui.ico_native.setPixmap(getIcon("dialog-ok-apply").pixmap(16, 16))
  2118. else:
  2119. self.ui.ico_native.setPixmap(getIcon("dialog-error").pixmap(16, 16))
  2120. self.ui.ch_native.setChecked(False)
  2121. self.ui.ch_native.setEnabled(False)
  2122. self.ui.ch_gig.setChecked(False)
  2123. self.ui.ch_gig.setEnabled(False)
  2124. self.ui.ch_sf2.setChecked(False)
  2125. self.ui.ch_sf2.setEnabled(False)
  2126. self.ui.ch_sfz.setChecked(False)
  2127. self.ui.ch_sfz.setEnabled(False)
  2128. if not hasNonNative:
  2129. self.ui.ch_ladspa.setChecked(False)
  2130. self.ui.ch_ladspa.setEnabled(False)
  2131. self.ui.ch_dssi.setChecked(False)
  2132. self.ui.ch_dssi.setEnabled(False)
  2133. self.ui.ch_lv2.setChecked(False)
  2134. self.ui.ch_lv2.setEnabled(False)
  2135. self.ui.ch_vst.setChecked(False)
  2136. self.ui.ch_vst.setEnabled(False)
  2137. self.ui.b_start.setEnabled(False)
  2138. #TODO
  2139. self.ui.ch_lv2.setChecked(False)
  2140. self.connect(self.ui.b_start, SIGNAL("clicked()"), SLOT("slot_start()"))
  2141. self.connect(self.ui.b_skip, SIGNAL("clicked()"), SLOT("slot_skip()"))
  2142. self.connect(self.fThread, SIGNAL("PluginLook(int, QString)"), SLOT("slot_handlePluginLook(int, QString)"))
  2143. self.connect(self.fThread, SIGNAL("finished()"), SLOT("slot_handlePluginThreadFinished()"))
  2144. @pyqtSlot()
  2145. def slot_start(self):
  2146. self.ui.progressBar.setMinimum(0)
  2147. self.ui.progressBar.setMaximum(100)
  2148. self.ui.progressBar.setValue(0)
  2149. self.ui.b_start.setEnabled(False)
  2150. self.ui.b_skip.setVisible(True)
  2151. self.ui.b_close.setVisible(False)
  2152. 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())
  2153. 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(),
  2154. self.ui.ch_gig.isChecked(), self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  2155. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  2156. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, gig, sf2, sfz)
  2157. self.fThread.start()
  2158. @pyqtSlot()
  2159. def slot_skip(self):
  2160. self.fThread.skipPlugin()
  2161. @pyqtSlot(int, str)
  2162. def slot_handlePluginLook(self, percent, plugin):
  2163. self.ui.progressBar.setFormat("%s" % plugin)
  2164. self.ui.progressBar.setValue(percent)
  2165. @pyqtSlot()
  2166. def slot_handlePluginThreadFinished(self):
  2167. self.ui.progressBar.setMinimum(0)
  2168. self.ui.progressBar.setMaximum(1)
  2169. self.ui.progressBar.setValue(1)
  2170. self.ui.progressBar.setFormat(self.tr("Done"))
  2171. self.ui.b_start.setEnabled(True)
  2172. self.ui.b_skip.setVisible(False)
  2173. self.ui.b_close.setVisible(True)
  2174. def _saveSettings(self):
  2175. settings = QSettings()
  2176. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  2177. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  2178. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  2179. settings.setValue("PluginDatabase/SearchVST", self.ui.ch_vst.isChecked())
  2180. settings.setValue("PluginDatabase/SearchGIG", self.ui.ch_gig.isChecked())
  2181. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  2182. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  2183. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  2184. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  2185. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  2186. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  2187. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  2188. def _loadSettings(self):
  2189. settings = QSettings()
  2190. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/SearchLADSPA", True, type=bool))
  2191. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/SearchDSSI", True, type=bool))
  2192. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/SearchLV2", True, type=bool))
  2193. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/SearchVST", True, type=bool))
  2194. self.ui.ch_gig.setChecked(settings.value("PluginDatabase/SearchGIG", False, type=bool))
  2195. self.ui.ch_sf2.setChecked(settings.value("PluginDatabase/SearchSF2", False, type=bool))
  2196. self.ui.ch_sfz.setChecked(settings.value("PluginDatabase/SearchSFZ", False, type=bool))
  2197. self.ui.ch_native.setChecked(settings.value("PluginDatabase/SearchNative", True, type=bool))
  2198. self.ui.ch_posix32.setChecked(settings.value("PluginDatabase/SearchPOSIX32", False, type=bool))
  2199. self.ui.ch_posix64.setChecked(settings.value("PluginDatabase/SearchPOSIX64", False, type=bool))
  2200. self.ui.ch_win32.setChecked(settings.value("PluginDatabase/SearchWin32", False, type=bool))
  2201. self.ui.ch_win64.setChecked(settings.value("PluginDatabase/SearchWin64", False, type=bool))
  2202. def closeEvent(self, event):
  2203. if self.fThread.isRunning():
  2204. self.fThread.terminate()
  2205. self.fThread.wait()
  2206. self._saveSettings()
  2207. if self.fThread.somethingChanged():
  2208. self.accept()
  2209. else:
  2210. self.reject()
  2211. QDialog.closeEvent(self, event)
  2212. def done(self, r):
  2213. QDialog.done(self, r)
  2214. self.close()
  2215. # ------------------------------------------------------------------------------------------------------------
  2216. # Plugin Database Dialog
  2217. class PluginDatabaseW(QDialog):
  2218. def __init__(self, parent):
  2219. QDialog.__init__(self, parent)
  2220. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  2221. self.ui.setupUi(self)
  2222. self.fLastTableIndex = 0
  2223. self.fRetPlugin = None
  2224. self.fRealParent = parent
  2225. self.ui.b_add.setEnabled(False)
  2226. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  2227. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  2228. else:
  2229. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  2230. if not (LINUX or MACOS):
  2231. self.ui.ch_bridged_wine.setChecked(False)
  2232. self.ui.ch_bridged_wine.setEnabled(False)
  2233. self._loadSettings()
  2234. self.connect(self.ui.b_add, SIGNAL("clicked()"), SLOT("slot_addPlugin()"))
  2235. self.connect(self.ui.b_refresh, SIGNAL("clicked()"), SLOT("slot_refreshPlugins()"))
  2236. self.connect(self.ui.tb_filters, SIGNAL("clicked()"), SLOT("slot_maybeShowFilters()"))
  2237. self.connect(self.ui.tableWidget, SIGNAL("currentCellChanged(int, int, int, int)"), SLOT("slot_checkPlugin(int)"))
  2238. self.connect(self.ui.tableWidget, SIGNAL("cellDoubleClicked(int, int)"), SLOT("slot_addPlugin()"))
  2239. self.connect(self.ui.lineEdit, SIGNAL("textChanged(QString)"), SLOT("slot_checkFilters()"))
  2240. self.connect(self.ui.ch_effects, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2241. self.connect(self.ui.ch_instruments, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2242. self.connect(self.ui.ch_midi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2243. self.connect(self.ui.ch_other, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2244. self.connect(self.ui.ch_kits, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2245. self.connect(self.ui.ch_internal, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2246. self.connect(self.ui.ch_ladspa, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2247. self.connect(self.ui.ch_dssi, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2248. self.connect(self.ui.ch_lv2, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2249. self.connect(self.ui.ch_vst, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2250. self.connect(self.ui.ch_native, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2251. self.connect(self.ui.ch_bridged, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2252. self.connect(self.ui.ch_bridged_wine, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2253. self.connect(self.ui.ch_gui, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2254. self.connect(self.ui.ch_stereo, SIGNAL("clicked()"), SLOT("slot_checkFilters()"))
  2255. @pyqtSlot()
  2256. def slot_addPlugin(self):
  2257. if self.ui.tableWidget.currentRow() >= 0:
  2258. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).pluginData
  2259. self.accept()
  2260. else:
  2261. self.reject()
  2262. @pyqtSlot(int)
  2263. def slot_checkPlugin(self, row):
  2264. self.ui.b_add.setEnabled(row >= 0)
  2265. @pyqtSlot()
  2266. def slot_checkFilters(self):
  2267. self._checkFilters()
  2268. @pyqtSlot()
  2269. def slot_maybeShowFilters(self):
  2270. self._showFilters(not self.ui.frame.isVisible())
  2271. @pyqtSlot()
  2272. def slot_refreshPlugins(self):
  2273. if PluginRefreshW(self).exec_():
  2274. self._reAddPlugins()
  2275. if self.fRealParent:
  2276. self.fRealParent.loadRDFs()
  2277. def _checkFilters(self):
  2278. text = self.ui.lineEdit.text().lower()
  2279. hideEffects = not self.ui.ch_effects.isChecked()
  2280. hideInstruments = not self.ui.ch_instruments.isChecked()
  2281. hideMidi = not self.ui.ch_midi.isChecked()
  2282. hideOther = not self.ui.ch_other.isChecked()
  2283. hideInternal = not self.ui.ch_internal.isChecked()
  2284. hideLadspa = not self.ui.ch_ladspa.isChecked()
  2285. hideDssi = not self.ui.ch_dssi.isChecked()
  2286. hideLV2 = not self.ui.ch_lv2.isChecked()
  2287. hideVST = not self.ui.ch_vst.isChecked()
  2288. hideKits = not self.ui.ch_kits.isChecked()
  2289. hideNative = not self.ui.ch_native.isChecked()
  2290. hideBridged = not self.ui.ch_bridged.isChecked()
  2291. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  2292. hideNonGui = self.ui.ch_gui.isChecked()
  2293. hideNonStereo = self.ui.ch_stereo.isChecked()
  2294. if HAIKU or LINUX or MACOS:
  2295. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  2296. wineBins = [BINARY_WIN32, BINARY_WIN64]
  2297. elif WINDOWS:
  2298. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  2299. wineBins = []
  2300. else:
  2301. nativeBins = []
  2302. wineBins = []
  2303. rowCount = self.ui.tableWidget.rowCount()
  2304. for i in range(rowCount):
  2305. self.ui.tableWidget.showRow(i)
  2306. plugin = self.ui.tableWidget.item(i, 0).pluginData
  2307. aIns = plugin['audio.ins']
  2308. aOuts = plugin['audio.outs']
  2309. mIns = plugin['midi.ins']
  2310. mOuts = plugin['midi.outs']
  2311. ptype = self.ui.tableWidget.item(i, 12).text()
  2312. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  2313. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  2314. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  2315. isKit = bool(ptype in ("GIG", "SF2", "SFZ"))
  2316. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  2317. isNative = bool(plugin['build'] == BINARY_NATIVE)
  2318. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  2319. hasGui = bool(plugin['hints'] & PLUGIN_HAS_GUI)
  2320. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  2321. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  2322. if (hideEffects and isEffect):
  2323. self.ui.tableWidget.hideRow(i)
  2324. elif (hideInstruments and isSynth):
  2325. self.ui.tableWidget.hideRow(i)
  2326. elif (hideMidi and isMidi):
  2327. self.ui.tableWidget.hideRow(i)
  2328. elif (hideOther and isOther):
  2329. self.ui.tableWidget.hideRow(i)
  2330. elif (hideKits and isKit):
  2331. self.ui.tableWidget.hideRow(i)
  2332. elif (hideInternal and ptype == self.tr("Internal")):
  2333. self.ui.tableWidget.hideRow(i)
  2334. elif (hideLadspa and ptype == "LADSPA"):
  2335. self.ui.tableWidget.hideRow(i)
  2336. elif (hideDssi and ptype == "DSSI"):
  2337. self.ui.tableWidget.hideRow(i)
  2338. elif (hideLV2 and ptype == "LV2"):
  2339. self.ui.tableWidget.hideRow(i)
  2340. elif (hideVST and ptype == "VST"):
  2341. self.ui.tableWidget.hideRow(i)
  2342. elif (hideNative and isNative):
  2343. self.ui.tableWidget.hideRow(i)
  2344. elif (hideBridged and isBridged):
  2345. self.ui.tableWidget.hideRow(i)
  2346. elif (hideBridgedWine and isBridgedWine):
  2347. self.ui.tableWidget.hideRow(i)
  2348. elif (hideNonGui and not hasGui):
  2349. self.ui.tableWidget.hideRow(i)
  2350. elif (hideNonStereo and not isStereo):
  2351. self.ui.tableWidget.hideRow(i)
  2352. elif (text and not (
  2353. text in self.ui.tableWidget.item(i, 0).text().lower() or
  2354. text in self.ui.tableWidget.item(i, 1).text().lower() or
  2355. text in self.ui.tableWidget.item(i, 2).text().lower() or
  2356. text in self.ui.tableWidget.item(i, 3).text().lower() or
  2357. text in self.ui.tableWidget.item(i, 13).text().lower())):
  2358. self.ui.tableWidget.hideRow(i)
  2359. def _showFilters(self, yesNo):
  2360. self.ui.tb_filters.setArrowType(Qt.UpArrow if yesNo else Qt.DownArrow)
  2361. self.ui.frame.setVisible(yesNo)
  2362. def _reAddPlugins(self):
  2363. settingsDB = QSettings("falkTX", "CarlaPlugins")
  2364. rowCount = self.ui.tableWidget.rowCount()
  2365. for x in range(rowCount):
  2366. self.ui.tableWidget.removeRow(0)
  2367. self.fLastTableIndex = 0
  2368. self.ui.tableWidget.setSortingEnabled(False)
  2369. internalCount = 0
  2370. ladspaCount = 0
  2371. dssiCount = 0
  2372. lv2Count = 0
  2373. vstCount = 0
  2374. kitCount = 0
  2375. # ---------------------------------------------------------------------------
  2376. # Internal
  2377. internalPlugins = toList(settingsDB.value("Plugins/Internal", []))
  2378. for plugins in internalPlugins:
  2379. for plugin in plugins:
  2380. internalCount += 1
  2381. if (not Carla.isControl) and internalCount != Carla.host.get_internal_plugin_count():
  2382. internalCount = Carla.host.get_internal_plugin_count()
  2383. internalPlugins = []
  2384. for i in range(Carla.host.get_internal_plugin_count()):
  2385. descInfo = Carla.host.get_internal_plugin_info(i)
  2386. plugins = checkPluginInternal(descInfo)
  2387. if plugins:
  2388. internalPlugins.append(plugins)
  2389. settingsDB.setValue("Plugins/Internal", internalPlugins)
  2390. for plugins in internalPlugins:
  2391. for plugin in plugins:
  2392. self._addPluginToTable(plugin, self.tr("Internal"))
  2393. # ---------------------------------------------------------------------------
  2394. # LADSPA
  2395. ladspaPlugins = []
  2396. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", []))
  2397. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", []))
  2398. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", []))
  2399. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", []))
  2400. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", []))
  2401. for plugins in ladspaPlugins:
  2402. for plugin in plugins:
  2403. self._addPluginToTable(plugin, "LADSPA")
  2404. ladspaCount += 1
  2405. # ---------------------------------------------------------------------------
  2406. # DSSI
  2407. dssiPlugins = []
  2408. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", []))
  2409. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", []))
  2410. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", []))
  2411. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", []))
  2412. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", []))
  2413. for plugins in dssiPlugins:
  2414. for plugin in plugins:
  2415. self._addPluginToTable(plugin, "DSSI")
  2416. dssiCount += 1
  2417. # ---------------------------------------------------------------------------
  2418. # LV2
  2419. lv2Plugins = []
  2420. lv2Plugins += toList(settingsDB.value("Plugins/LV2_native", []))
  2421. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix32", []))
  2422. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix64", []))
  2423. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win32", []))
  2424. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win64", []))
  2425. for plugins in lv2Plugins:
  2426. for plugin in plugins:
  2427. self._addPluginToTable(plugin, "LV2")
  2428. lv2Count += 1
  2429. # ---------------------------------------------------------------------------
  2430. # VST
  2431. vstPlugins = []
  2432. vstPlugins += toList(settingsDB.value("Plugins/VST_native", []))
  2433. vstPlugins += toList(settingsDB.value("Plugins/VST_posix32", []))
  2434. vstPlugins += toList(settingsDB.value("Plugins/VST_posix64", []))
  2435. vstPlugins += toList(settingsDB.value("Plugins/VST_win32", []))
  2436. vstPlugins += toList(settingsDB.value("Plugins/VST_win64", []))
  2437. for plugins in vstPlugins:
  2438. for plugin in plugins:
  2439. self._addPluginToTable(plugin, "VST")
  2440. vstCount += 1
  2441. # ---------------------------------------------------------------------------
  2442. # Kits
  2443. gigs = toList(settingsDB.value("Plugins/GIG", []))
  2444. sf2s = toList(settingsDB.value("Plugins/SF2", []))
  2445. sfzs = toList(settingsDB.value("Plugins/SFZ", []))
  2446. for gig in gigs:
  2447. for gig_i in gig:
  2448. self._addPluginToTable(gig_i, "GIG")
  2449. kitCount += 1
  2450. for sf2 in sf2s:
  2451. for sf2_i in sf2:
  2452. self._addPluginToTable(sf2_i, "SF2")
  2453. kitCount += 1
  2454. for sfz in sfzs:
  2455. for sfz_i in sfz:
  2456. self._addPluginToTable(sfz_i, "SFZ")
  2457. kitCount += 1
  2458. # ---------------------------------------------------------------------------
  2459. self.ui.tableWidget.setSortingEnabled(True)
  2460. self.ui.tableWidget.sortByColumn(0, Qt.AscendingOrder)
  2461. 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)))
  2462. self._checkFilters()
  2463. def _addPluginToTable(self, plugin, ptype):
  2464. index = self.fLastTableIndex
  2465. if plugin['build'] == BINARY_NATIVE:
  2466. bridgeText = self.tr("No")
  2467. else:
  2468. typeText = self.tr("Unknown")
  2469. if LINUX or MACOS:
  2470. if plugin['build'] == BINARY_POSIX32:
  2471. typeText = "32bit"
  2472. elif plugin['build'] == BINARY_POSIX64:
  2473. typeText = "64bit"
  2474. elif plugin['build'] == BINARY_WIN32:
  2475. typeText = "Windows 32bit"
  2476. elif plugin['build'] == BINARY_WIN64:
  2477. typeText = "Windows 64bit"
  2478. elif WINDOWS:
  2479. if plugin['build'] == BINARY_WIN32:
  2480. typeText = "32bit"
  2481. elif plugin['build'] == BINARY_WIN64:
  2482. typeText = "64bit"
  2483. bridgeText = self.tr("Yes (%s)" % typeText)
  2484. self.ui.tableWidget.insertRow(index)
  2485. self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(str(plugin['name'])))
  2486. self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(str(plugin['label'])))
  2487. self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(str(plugin['maker'])))
  2488. self.ui.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['uniqueId'])))
  2489. self.ui.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins'])))
  2490. self.ui.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs'])))
  2491. self.ui.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins'])))
  2492. self.ui.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs'])))
  2493. self.ui.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total'])))
  2494. self.ui.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_GUI) else self.tr("No")))
  2495. self.ui.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No")))
  2496. self.ui.tableWidget.setItem(index, 11, QTableWidgetItem(bridgeText))
  2497. self.ui.tableWidget.setItem(index, 12, QTableWidgetItem(ptype))
  2498. self.ui.tableWidget.setItem(index, 13, QTableWidgetItem(str(plugin['binary'])))
  2499. self.ui.tableWidget.item(self.fLastTableIndex, 0).pluginData = plugin
  2500. self.fLastTableIndex += 1
  2501. def _saveSettings(self):
  2502. settings = QSettings()
  2503. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  2504. settings.setValue("PluginDatabase/TableGeometry", self.ui.tableWidget.horizontalHeader().saveState())
  2505. settings.setValue("PluginDatabase/ShowFilters", (self.ui.tb_filters.arrowType() == Qt.UpArrow))
  2506. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  2507. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  2508. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  2509. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  2510. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  2511. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  2512. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  2513. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  2514. settings.setValue("PluginDatabase/ShowVST", self.ui.ch_vst.isChecked())
  2515. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  2516. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  2517. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  2518. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  2519. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  2520. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  2521. def _loadSettings(self):
  2522. settings = QSettings()
  2523. self.restoreGeometry(settings.value("PluginDatabase/Geometry", ""))
  2524. self.ui.tableWidget.horizontalHeader().restoreState(settings.value("PluginDatabase/TableGeometry", ""))
  2525. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool))
  2526. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool))
  2527. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool))
  2528. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool))
  2529. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool))
  2530. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool))
  2531. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool))
  2532. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool))
  2533. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST", True, type=bool))
  2534. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool))
  2535. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool))
  2536. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool))
  2537. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool))
  2538. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool))
  2539. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool))
  2540. self._showFilters(settings.value("PluginDatabase/ShowFilters", False, type=bool))
  2541. self._reAddPlugins()
  2542. def closeEvent(self, event):
  2543. self._saveSettings()
  2544. QDialog.closeEvent(self, event)
  2545. def done(self, r):
  2546. QDialog.done(self, r)
  2547. self.close()