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.

3381 lines
133KB

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