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.

3419 lines
134KB

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