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.

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