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.

3429 lines
133KB

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