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.

3371 lines
132KB

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