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.

3483 lines
134KB

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