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.

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