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.

3200 lines
126KB

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