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.

3288 lines
125KB

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