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.

carla_skin.py 57KB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin/slot skin code
  4. # Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import Qt, QRectF
  24. from PyQt5.QtGui import QFont, QPen, QPixmap
  25. from PyQt5.QtWidgets import QFrame, QPushButton
  26. else:
  27. from PyQt4.QtCore import Qt, QRectF
  28. from PyQt4.QtGui import QFont, QFrame, QPen, QPixmap, QPushButton
  29. # ------------------------------------------------------------------------------------------------------------
  30. # Imports (Custom)
  31. import ui_carla_plugin_default
  32. import ui_carla_plugin_basic_fx
  33. import ui_carla_plugin_calf
  34. import ui_carla_plugin_zita
  35. import ui_carla_plugin_zynfx
  36. from carla_widgets import *
  37. from pixmapdial import PixmapDial
  38. # ------------------------------------------------------------------------------------------------------------
  39. # Try to "shortify" a parameter name
  40. def getParameterShortName(paramName):
  41. paramName = paramName.split("/",1)[0].split(" (",1)[0].split(" [",1)[0].strip()
  42. paramLow = paramName.lower()
  43. # Cut generic names
  44. if "bandwidth" in paramLow:
  45. paramName = paramName.replace("andwidth", "w")
  46. elif "distortion" in paramLow:
  47. paramName = paramName.replace("istortion", "ist")
  48. elif "frequency" in paramLow:
  49. paramName = paramName.replace("requency", "req")
  50. elif "output" in paramLow:
  51. paramName = paramName.replace("utput", "ut")
  52. elif "threshold" in paramLow:
  53. paramName = paramName.replace("hreshold", "hres")
  54. # Cut useless prefix
  55. elif paramLow.startswith("room "):
  56. paramName = paramName.split(" ",1)[1]
  57. # Cut useless suffix
  58. elif paramLow.endswith(" level"):
  59. paramName = paramName.rsplit(" ",1)[0]
  60. elif paramLow.endswith(" time"):
  61. paramName = paramName.rsplit(" ",1)[0]
  62. if len(paramName) > 8:
  63. paramName = paramName[:8]
  64. return paramName.strip()
  65. # ------------------------------------------------------------------------------------------------------------
  66. # Abstract plugin slot
  67. class AbstractPluginSlot(QFrame, PluginEditParentMeta):
  68. #class AbstractPluginSlot(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
  69. def __init__(self, parent, pluginId):
  70. QFrame.__init__(self, parent)
  71. # -------------------------------------------------------------
  72. # Get plugin info
  73. self.fPluginId = pluginId
  74. self.fPluginInfo = gCarla.host.get_plugin_info(self.fPluginId) if gCarla.host is not None else gFakePluginInfo
  75. if not gCarla.isLocal:
  76. self.fPluginInfo['hints'] &= ~PLUGIN_HAS_CUSTOM_UI
  77. # -------------------------------------------------------------
  78. # Internal stuff
  79. self.fIsActive = bool(gCarla.host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5) if gCarla.host is not None else True
  80. self.fIsSelected = False
  81. self.fLastGreenLedState = False
  82. self.fLastBlueLedState = False
  83. self.fParameterIconTimer = ICON_STATE_OFF
  84. self.fParameterList = [] # index, widget
  85. if gCarla.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK or gCarla.host is None:
  86. self.fPeaksInputCount = 2
  87. self.fPeaksOutputCount = 2
  88. else:
  89. audioCountInfo = gCarla.host.get_audio_port_count_info(self.fPluginId)
  90. self.fPeaksInputCount = int(audioCountInfo['ins'])
  91. self.fPeaksOutputCount = int(audioCountInfo['outs'])
  92. if self.fPeaksInputCount > 2:
  93. self.fPeaksInputCount = 2
  94. if self.fPeaksOutputCount > 2:
  95. self.fPeaksOutputCount = 2
  96. # -------------------------------------------------------------
  97. # Set-up GUI
  98. self.fEditDialog = PluginEdit(self, gCarla.host, self.fPluginId)
  99. # -------------------------------------------------------------
  100. # Set-up common widgets (as none)
  101. self.b_enable = None
  102. self.b_gui = None
  103. self.b_edit = None
  104. self.b_remove = None
  105. self.cb_presets = None
  106. self.label_name = None
  107. self.label_type = None
  108. self.led_control = None
  109. self.led_midi = None
  110. self.led_audio_in = None
  111. self.led_audio_out = None
  112. self.peak_in = None
  113. self.peak_out = None
  114. #------------------------------------------------------------------
  115. def ready(self):
  116. if self.b_enable is not None:
  117. self.b_enable.setChecked(self.fIsActive)
  118. self.b_enable.clicked.connect(self.slot_enableClicked)
  119. if self.b_gui is not None:
  120. self.b_gui.clicked.connect(self.slot_showCustomUi)
  121. self.b_gui.setEnabled(bool(self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI))
  122. if self.b_edit is None:
  123. # Edit dialog *must* be available
  124. self.b_edit = QPushButton(self)
  125. self.b_edit.setCheckable(True)
  126. self.b_edit.hide()
  127. self.b_edit.clicked.connect(self.slot_showEditDialog)
  128. if self.b_remove is not None:
  129. self.b_remove.clicked.connect(self.slot_removePlugin)
  130. if self.label_name is not None:
  131. self.label_name.setText(self.fPluginInfo['name'])
  132. if self.label_type is not None:
  133. self.label_type.setText(getPluginTypeAsString(self.fPluginInfo['type']))
  134. if self.led_control is not None:
  135. self.led_control.setColor(self.led_control.YELLOW)
  136. self.led_control.setEnabled(False)
  137. if self.led_midi is not None:
  138. self.led_midi.setColor(self.led_midi.RED)
  139. self.led_midi.setEnabled(False)
  140. if self.led_audio_in is not None:
  141. self.led_audio_in.setColor(self.led_audio_in.GREEN)
  142. self.led_audio_in.setEnabled(False)
  143. if self.led_audio_out is not None:
  144. self.led_audio_out.setColor(self.led_audio_out.BLUE)
  145. self.led_audio_out.setEnabled(False)
  146. if self.peak_in is not None:
  147. self.peak_in.setColor(self.peak_in.GREEN)
  148. self.peak_in.setChannels(self.fPeaksInputCount)
  149. self.peak_in.setOrientation(self.peak_in.HORIZONTAL)
  150. if self.peak_out is not None:
  151. self.peak_out.setColor(self.peak_in.BLUE)
  152. self.peak_out.setChannels(self.fPeaksOutputCount)
  153. self.peak_out.setOrientation(self.peak_out.HORIZONTAL)
  154. if gCarla.host is None:
  155. return
  156. for paramIndex, paramWidget in self.fParameterList:
  157. paramWidget.setContextMenuPolicy(Qt.CustomContextMenu)
  158. paramWidget.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  159. paramWidget.realValueChanged.connect(self.slot_parameterValueChanged)
  160. paramWidget.setValue(gCarla.host.get_internal_parameter_value(self.fPluginId, paramIndex))
  161. #------------------------------------------------------------------
  162. def getFixedHeight(self):
  163. return 32
  164. def getHints(self):
  165. return self.fPluginInfo['hints']
  166. def getPluginId(self):
  167. return self.fPluginId
  168. #------------------------------------------------------------------
  169. def setId(self, idx):
  170. self.fPluginId = idx
  171. self.fEditDialog.setId(idx)
  172. def setName(self, name):
  173. self.fEditDialog.setName(name)
  174. if self.label_name is not None:
  175. self.label_name.setText(name)
  176. def setSelected(self, yesNo):
  177. if self.fIsSelected == yesNo:
  178. return
  179. self.fIsSelected = yesNo
  180. self.update()
  181. #------------------------------------------------------------------
  182. def setActive(self, active, sendCallback=False, sendHost=True):
  183. self.fIsActive = active
  184. if sendCallback:
  185. self.fParameterIconTimer = ICON_STATE_ON
  186. self.activeChanged(active)
  187. if sendHost:
  188. gCarla.host.set_active(self.fPluginId, active)
  189. if active:
  190. self.fEditDialog.clearNotes()
  191. self.midiActivityChanged(False)
  192. # called from rack, checks if param is possible first
  193. def setInternalParameter(self, parameterId, value):
  194. if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
  195. return
  196. elif parameterId == PARAMETER_ACTIVE:
  197. return self.setActive(bool(value), True, True)
  198. elif parameterId == PARAMETER_DRYWET:
  199. if (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) == 0: return
  200. gCarla.host.set_drywet(self.fPluginId, value)
  201. elif parameterId == PARAMETER_VOLUME:
  202. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  203. gCarla.host.set_volume(self.fPluginId, value)
  204. elif parameterId == PARAMETER_BALANCE_LEFT:
  205. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  206. gCarla.host.set_balance_left(self.fPluginId, value)
  207. elif parameterId == PARAMETER_BALANCE_RIGHT:
  208. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  209. gCarla.host.set_balance_right(self.fPluginId, value)
  210. elif parameterId == PARAMETER_PANNING:
  211. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  212. gCarla.host.set_panning(self.fPluginId, value)
  213. elif parameterId == PARAMETER_CTRL_CHANNEL:
  214. gCarla.host.set_ctrl_channel(self.fPluginId, value)
  215. self.fEditDialog.setParameterValue(parameterId, value)
  216. #------------------------------------------------------------------
  217. def setParameterValue(self, parameterId, value, sendCallback):
  218. if parameterId == PARAMETER_ACTIVE:
  219. return self.setActive(bool(value), True, False)
  220. self.fEditDialog.setParameterValue(parameterId, value)
  221. if sendCallback:
  222. self.fParameterIconTimer = ICON_STATE_ON
  223. self.parameterValueChanged(parameterId, value)
  224. def setParameterDefault(self, parameterId, value):
  225. self.fEditDialog.setParameterDefault(parameterId, value)
  226. def setParameterMidiControl(self, parameterId, control):
  227. self.fEditDialog.setParameterMidiControl(parameterId, control)
  228. def setParameterMidiChannel(self, parameterId, channel):
  229. self.fEditDialog.setParameterMidiChannel(parameterId, channel)
  230. #------------------------------------------------------------------
  231. def setProgram(self, index, sendCallback):
  232. self.fEditDialog.setProgram(index)
  233. if sendCallback:
  234. self.fParameterIconTimer = ICON_STATE_ON
  235. self.programChanged(index)
  236. def setMidiProgram(self, index, sendCallback):
  237. self.fEditDialog.setMidiProgram(index)
  238. if sendCallback:
  239. self.fParameterIconTimer = ICON_STATE_ON
  240. self.midiProgramChanged(index)
  241. #------------------------------------------------------------------
  242. def setOption(self, option, yesNo):
  243. self.fEditDialog.setOption(option, yesNo)
  244. #------------------------------------------------------------------
  245. def sendNoteOn(self, channel, note):
  246. if self.fEditDialog.sendNoteOn(channel, note):
  247. self.midiActivityChanged(True)
  248. def sendNoteOff(self, channel, note):
  249. if self.fEditDialog.sendNoteOff(channel, note):
  250. self.midiActivityChanged(False)
  251. #------------------------------------------------------------------
  252. def activeChanged(self, onOff):
  253. self.fIsActive = onOff
  254. if self.b_enable is None:
  255. return
  256. self.b_enable.blockSignals(True)
  257. self.b_enable.setChecked(onOff)
  258. self.b_enable.blockSignals(False)
  259. def customUiStateChanged(self, state):
  260. if self.b_gui is None:
  261. return
  262. self.b_gui.blockSignals(True)
  263. if state == 0:
  264. self.b_gui.setChecked(False)
  265. self.b_gui.setEnabled(True)
  266. elif state == 1:
  267. self.b_gui.setChecked(True)
  268. self.b_gui.setEnabled(True)
  269. elif state == -1:
  270. self.b_gui.setChecked(False)
  271. self.b_gui.setEnabled(False)
  272. self.b_gui.blockSignals(False)
  273. def parameterActivityChanged(self, onOff):
  274. if self.led_control is None:
  275. return
  276. self.led_control.setChecked(onOff)
  277. def midiActivityChanged(self, onOff):
  278. if self.led_midi is None:
  279. return
  280. self.led_midi.setChecked(onOff)
  281. def optionChanged(self, option, yesNo):
  282. pass
  283. # -----------------------------------------------------------------
  284. # PluginEdit callbacks
  285. def editDialogChanged(self, visible):
  286. if self.b_edit is None:
  287. return
  288. self.b_edit.blockSignals(True)
  289. self.b_edit.setChecked(visible)
  290. self.b_edit.blockSignals(False)
  291. def pluginHintsChanged(self, hints):
  292. self.fPluginInfo['hints'] = hints
  293. self.ui.dial_drywet.setVisible(hints & PLUGIN_CAN_DRYWET)
  294. self.ui.dial_vol.setVisible(hints & PLUGIN_CAN_VOLUME)
  295. if self.b_gui is not None:
  296. self.b_gui.setEnabled(bool(hints & PLUGIN_HAS_CUSTOM_UI))
  297. def parameterValueChanged(self, parameterId, value):
  298. for paramIndex, paramWidget in self.fParameterList:
  299. if paramIndex != parameterId:
  300. continue
  301. paramWidget.blockSignals(True)
  302. paramWidget.setValue(value)
  303. paramWidget.blockSignals(False)
  304. break
  305. def programChanged(self, index):
  306. if self.cb_presets is None:
  307. return
  308. self.cb_presets.blockSignals(True)
  309. self.cb_presets.setCurrentIndex(index)
  310. self.cb_presets.blockSignals(False)
  311. def midiProgramChanged(self, index):
  312. if self.cb_presets is None:
  313. return
  314. self.cb_presets.blockSignals(True)
  315. self.cb_presets.setCurrentIndex(index)
  316. self.cb_presets.blockSignals(False)
  317. def notePressed(self, note):
  318. pass
  319. def noteReleased(self, note):
  320. pass
  321. #------------------------------------------------------------------
  322. def idleFast(self):
  323. # Input peaks
  324. if self.fPeaksInputCount > 0:
  325. if self.fPeaksInputCount > 1:
  326. peak1 = gCarla.host.get_input_peak_value(self.fPluginId, True)
  327. peak2 = gCarla.host.get_input_peak_value(self.fPluginId, False)
  328. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  329. if self.peak_in is not None:
  330. self.peak_in.displayMeter(1, peak1)
  331. self.peak_in.displayMeter(2, peak2)
  332. else:
  333. peak = gCarla.host.get_input_peak_value(self.fPluginId, True)
  334. ledState = bool(peak != 0.0)
  335. if self.peak_in is not None:
  336. self.peak_in.displayMeter(1, peak)
  337. if self.fLastGreenLedState != ledState and self.led_audio_in is not None:
  338. self.fLastGreenLedState = ledState
  339. self.led_audio_in.setChecked(ledState)
  340. # Output peaks
  341. if self.fPeaksOutputCount > 0:
  342. if self.fPeaksOutputCount > 1:
  343. peak1 = gCarla.host.get_output_peak_value(self.fPluginId, True)
  344. peak2 = gCarla.host.get_output_peak_value(self.fPluginId, False)
  345. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  346. if self.peak_out is not None:
  347. self.peak_out.displayMeter(1, peak1)
  348. self.peak_out.displayMeter(2, peak2)
  349. else:
  350. peak = gCarla.host.get_output_peak_value(self.fPluginId, True)
  351. ledState = bool(peak != 0.0)
  352. if self.peak_out is not None:
  353. self.peak_out.displayMeter(1, peak)
  354. if self.fLastBlueLedState != ledState and self.led_audio_out is not None:
  355. self.fLastBlueLedState = ledState
  356. self.led_audio_out.setChecked(ledState)
  357. def idleSlow(self):
  358. if self.fParameterIconTimer == ICON_STATE_ON:
  359. self.fParameterIconTimer = ICON_STATE_WAIT1
  360. self.parameterActivityChanged(True)
  361. elif self.fParameterIconTimer == ICON_STATE_WAIT1:
  362. self.fParameterIconTimer = ICON_STATE_WAIT2
  363. elif self.fParameterIconTimer == ICON_STATE_WAIT2:
  364. self.fParameterIconTimer = ICON_STATE_OFF
  365. self.parameterActivityChanged(False)
  366. self.fEditDialog.idleSlow()
  367. #------------------------------------------------------------------
  368. def drawOutline(self):
  369. painter = QPainter(self)
  370. if self.fIsSelected:
  371. painter.setPen(QPen(Qt.cyan, 4))
  372. painter.setBrush(Qt.transparent)
  373. painter.drawRect(0, 0, self.width(), self.height())
  374. else:
  375. painter.setPen(QPen(Qt.black, 1))
  376. painter.setBrush(Qt.black)
  377. painter.drawLine(0, self.height()-1, self.width(), self.height()-1)
  378. def showDefaultCustomMenu(self, isEnabled, bEdit = None, bGui = None):
  379. menu = QMenu(self)
  380. actActive = menu.addAction(self.tr("Disable") if isEnabled else self.tr("Enable"))
  381. menu.addSeparator()
  382. actReset = menu.addAction(self.tr("Reset parameters"))
  383. actRandom = menu.addAction(self.tr("Randomize parameters"))
  384. menu.addSeparator()
  385. if bEdit is not None:
  386. actEdit = menu.addAction(self.tr("Edit"))
  387. actEdit.setCheckable(True)
  388. actEdit.setChecked(bEdit.isChecked())
  389. else:
  390. actEdit = None
  391. if bGui is not None:
  392. actGui = menu.addAction(self.tr("Show Custom UI"))
  393. actGui.setCheckable(True)
  394. actGui.setChecked(bGui.isChecked())
  395. actGui.setEnabled(bGui.isEnabled())
  396. else:
  397. actGui = None
  398. menu.addSeparator()
  399. actClone = menu.addAction(self.tr("Clone"))
  400. actReplace = menu.addAction(self.tr("Replace..."))
  401. actRename = menu.addAction(self.tr("Rename..."))
  402. actRemove = menu.addAction(self.tr("Remove"))
  403. actSel = menu.exec_(QCursor.pos())
  404. if not actSel:
  405. return
  406. if actSel == actActive:
  407. self.setActive(not isEnabled, True, True)
  408. elif actSel == actReset:
  409. if gCarla.host is None: return
  410. gCarla.host.reset_parameters(self.fPluginId)
  411. elif actSel == actRandom:
  412. if gCarla.host is None: return
  413. gCarla.host.randomize_parameters(self.fPluginId)
  414. elif actSel == actGui:
  415. bGui.click()
  416. elif actSel == actEdit:
  417. bEdit.click()
  418. elif actSel == actClone:
  419. if gCarla.host is not None and not gCarla.host.clone_plugin(self.fPluginId):
  420. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  421. gCarla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  422. elif actSel == actRename:
  423. oldName = self.fPluginInfo['name']
  424. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  425. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  426. return
  427. newName = newNameTry[0]
  428. if gCarla.host is None or gCarla.host.rename_plugin(self.fPluginId, newName):
  429. self.setName(newName)
  430. else:
  431. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  432. gCarla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  433. elif actSel == actReplace:
  434. gCarla.gui.slot_pluginAdd(self.fPluginId)
  435. elif actSel == actRemove:
  436. if gCarla.host is not None and not gCarla.host.remove_plugin(self.fPluginId):
  437. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  438. gCarla.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  439. #------------------------------------------------------------------
  440. @pyqtSlot(bool)
  441. def slot_enableClicked(self, yesNo):
  442. self.setActive(yesNo, False, True)
  443. @pyqtSlot()
  444. def slot_showDefaultCustomMenu(self):
  445. self.showDefaultCustomMenu(self.fIsActive, self.b_edit, self.b_gui)
  446. @pyqtSlot()
  447. def slot_knobCustomMenu(self):
  448. sender = self.sender()
  449. index = sender.fIndex
  450. minimum = sender.fMinimum
  451. maximum = sender.fMaximum
  452. current = sender.fRealValue
  453. label = sender.fLabel
  454. if index in (PARAMETER_DRYWET, PARAMETER_VOLUME):
  455. default = 1.0
  456. resetText = self.tr("Reset (%i%%)" % int(default*100.0))
  457. minimText = self.tr("Set to Minimum (%i%%)" % int(minimum*100.0))
  458. maximText = self.tr("Set to Maximum (%i%%)" % int(maximum*100.0))
  459. else:
  460. default = gCarla.host.get_default_parameter_value(self.fPluginId, index)
  461. resetText = self.tr("Reset (%f)" % default)
  462. minimText = self.tr("Set to Minimum (%f)" % minimum)
  463. maximText = self.tr("Set to Maximum (%f)" % maximum)
  464. menu = QMenu(self)
  465. actReset = menu.addAction(resetText)
  466. menu.addSeparator()
  467. actMinimum = menu.addAction(minimText)
  468. actMaximum = menu.addAction(maximText)
  469. menu.addSeparator()
  470. actSet = menu.addAction(self.tr("Set value..."))
  471. actSelected = menu.exec_(QCursor.pos())
  472. if actSelected == actSet:
  473. valueTry = QInputDialog.getDouble(self, self.tr("Set value"), label, current, minimum, maximum, 3) # FIXME - 3 decimals
  474. if valueTry[1]:
  475. value = valueTry[0] * 10
  476. else:
  477. return
  478. elif actSelected == actMinimum:
  479. value = minimum
  480. elif actSelected == actMaximum:
  481. value = maximum
  482. elif actSelected == actReset:
  483. value = default
  484. else:
  485. return
  486. self.sender().setValue(value)
  487. #------------------------------------------------------------------
  488. @pyqtSlot(bool)
  489. def slot_showCustomUi(self, show):
  490. gCarla.host.show_custom_ui(self.fPluginId, show)
  491. @pyqtSlot(bool)
  492. def slot_showEditDialog(self, show):
  493. self.fEditDialog.setVisible(show)
  494. @pyqtSlot()
  495. def slot_removePlugin(self):
  496. gCarla.host.remove_plugin(self.fPluginId)
  497. #------------------------------------------------------------------
  498. @pyqtSlot(int)
  499. def slot_parameterValueChanged(self, value):
  500. index = self.sender().getIndex()
  501. if index < 0:
  502. self.setInternalParameter(index, value)
  503. else:
  504. gCarla.host.set_parameter_value(self.fPluginId, index, value)
  505. self.setParameterValue(index, value, False)
  506. @pyqtSlot(int)
  507. def slot_programChanged(self, index):
  508. gCarla.host.set_program(self.fPluginId, index)
  509. self.setProgram(index, False)
  510. @pyqtSlot(int)
  511. def slot_midiProgramChanged(self, index):
  512. gCarla.host.set_midi_program(self.fPluginId, index)
  513. self.setMidiProgram(index, False)
  514. #------------------------------------------------------------------
  515. def paintEvent(self, event):
  516. self.drawOutline()
  517. QFrame.paintEvent(self, event)
  518. # ------------------------------------------------------------------------------------------------------------
  519. class PluginSlot_Default(AbstractPluginSlot):
  520. def __init__(self, parent, pluginId):
  521. AbstractPluginSlot.__init__(self, parent, pluginId)
  522. self.ui = ui_carla_plugin_default.Ui_PluginWidget()
  523. self.ui.setupUi(self)
  524. # -------------------------------------------------------------
  525. # Internal stuff
  526. self.fColorTop = QColor(60, 60, 60)
  527. self.fColorBottom = QColor(47, 47, 47)
  528. self.fColorSeprtr = QColor(70, 70, 70)
  529. # -------------------------------------------------------------
  530. # Set-up GUI
  531. self.setStyleSheet("""
  532. QLabel#label_name {
  533. color: #BBB;
  534. }
  535. """)
  536. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  537. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  538. if self.fPluginInfo['iconName'] == "distrho":
  539. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  540. elif self.fPluginInfo['iconName'] == "file":
  541. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  542. else:
  543. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  544. # -------------------------------------------------------------
  545. self.b_enable = self.ui.b_enable
  546. self.b_gui = self.ui.b_gui
  547. self.b_edit = self.ui.b_edit
  548. self.label_name = self.ui.label_name
  549. self.led_control = self.ui.led_control
  550. self.led_midi = self.ui.led_midi
  551. self.led_audio_in = self.ui.led_audio_in
  552. self.led_audio_out = self.ui.led_audio_out
  553. self.peak_in = self.ui.peak_in
  554. self.peak_out = self.ui.peak_out
  555. self.ready()
  556. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  557. #------------------------------------------------------------------
  558. def getFixedHeight(self):
  559. return 36
  560. #------------------------------------------------------------------
  561. def paintEvent(self, event):
  562. painter = QPainter(self)
  563. painter.save()
  564. areaX = self.ui.area_right.x()+7
  565. width = self.width()
  566. height = self.height()
  567. painter.setPen(QPen(QColor(17, 17, 17), 1))
  568. painter.setBrush(QColor(17, 17, 17))
  569. painter.drawRect(0, 0, width, height)
  570. painter.setPen(self.fColorSeprtr.lighter(110))
  571. painter.setBrush(self.fColorBottom)
  572. painter.setRenderHint(QPainter.Antialiasing, True)
  573. # name -> leds arc
  574. path = QPainterPath()
  575. path.moveTo(areaX-20, height-4)
  576. path.cubicTo(areaX, height-5, areaX-20, 4.75, areaX, 4.75)
  577. path.lineTo(areaX, height-5)
  578. painter.drawPath(path)
  579. painter.setPen(self.fColorSeprtr)
  580. painter.setRenderHint(QPainter.Antialiasing, False)
  581. # separator lines
  582. painter.drawLine(0, height-5, areaX-20, height-5)
  583. painter.drawLine(areaX, 4, width, 4)
  584. painter.setPen(self.fColorBottom)
  585. painter.setBrush(self.fColorBottom)
  586. # top, bottom and left lines
  587. painter.drawLine(0, 0, width, 0)
  588. painter.drawRect(0, height-4, areaX, 4)
  589. painter.drawRoundedRect(areaX-20, height-5, areaX, 5, 22, 22)
  590. painter.drawLine(0, 0, 0, height)
  591. # fill the rest
  592. painter.drawRect(areaX-1, 5, width, height)
  593. # bottom 1px line
  594. painter.setPen(self.fColorSeprtr)
  595. painter.drawLine(0, height-1, width, height-1)
  596. painter.restore()
  597. AbstractPluginSlot.paintEvent(self, event)
  598. # ------------------------------------------------------------------------------------------------------------
  599. class PluginSlot_BasicFX(AbstractPluginSlot):
  600. def __init__(self, parent, pluginId):
  601. AbstractPluginSlot.__init__(self, parent, pluginId)
  602. self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
  603. self.ui.setupUi(self)
  604. # -------------------------------------------------------------
  605. # Set-up GUI
  606. labelFont = self.ui.label_name.font()
  607. labelFont.setBold(True)
  608. labelFont.setPointSize(9)
  609. self.ui.label_name.setFont(labelFont)
  610. r = 40
  611. g = 40
  612. b = 40
  613. if self.fPluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR:
  614. r += 10
  615. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_EQ:
  616. g += 10
  617. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  618. b += 10
  619. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  620. r += 15
  621. b -= 15
  622. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DISTORTION:
  623. g += 10
  624. b += 10
  625. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS:
  626. r += 10
  627. b += 10
  628. elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_UTILITY:
  629. r += 10
  630. g += 10
  631. bg = "noise1"
  632. if self.fPluginInfo['maker'] in ("falkTX, Michael Gruhn", "DISTRHO") and "3bandeq" in self.fPluginInfo['label'].lower():
  633. bg = "3bandeq"
  634. self.setStyleSheet("""
  635. PluginSlot_BasicFX#PluginWidget {
  636. background-color: rgb(%i, %i, %i);
  637. background-image: url(:/bitmaps/background_%s.png);
  638. background-repeat: repeat-xy;
  639. }
  640. QLabel#label_name {
  641. color: #BBB;
  642. }
  643. """ % (r, g, b, bg))
  644. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  645. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  646. if self.fPluginInfo['iconName'] == "distrho":
  647. self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png")
  648. elif self.fPluginInfo['iconName'] == "file":
  649. self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png")
  650. else:
  651. self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")
  652. # -------------------------------------------------------------
  653. # Set-up parameters
  654. parameterCount = gCarla.host.get_parameter_count(self.fPluginId) if gCarla.host is not None else 0
  655. index = 0
  656. for i in range(parameterCount):
  657. if index >= 8:
  658. break
  659. paramInfo = gCarla.host.get_parameter_info(self.fPluginId, i)
  660. paramData = gCarla.host.get_parameter_data(self.fPluginId, i)
  661. paramRanges = gCarla.host.get_parameter_ranges(self.fPluginId, i)
  662. if paramData['type'] != PARAMETER_INPUT:
  663. continue
  664. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  665. continue
  666. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  667. continue
  668. paramName = getParameterShortName(paramInfo['name'])
  669. #if self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER:
  670. #_r = 55 + float(i)/8*200
  671. #_g = 255 - float(i)/8*200
  672. #_b = 127 - r*2
  673. #elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY:
  674. #_r = 127
  675. #_g = 55 + float(i)/8*200
  676. #_b = 255 - float(i)/8*200
  677. #elif r < b < g:
  678. #_r = 55 + float(i)/8*200
  679. #_g = 127
  680. #_b = 255 - float(i)/8*200
  681. #else:
  682. _r = 255 - float(index)/8*200
  683. _g = 55 + float(index)/8*200
  684. _b = (r-40)*4
  685. #if _r < 140: _r = 140
  686. #if _g < 140: _g = 140
  687. #if _b < 140: _b = 140
  688. widget = PixmapDial(self, i)
  689. widget.setPixmap(3)
  690. widget.setLabel(paramName)
  691. widget.setCustomPaintColor(QColor(_r, _g, _b))
  692. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  693. widget.forceWhiteLabelGradientText()
  694. widget.setMinimum(paramRanges['min'])
  695. widget.setMaximum(paramRanges['max'])
  696. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  697. widget.setEnabled(False)
  698. self.ui.w_knobs.layout().insertWidget(index, widget)
  699. index += 1
  700. self.fParameterList.append([i, widget])
  701. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  702. self.ui.dial_drywet.setPixmap(3)
  703. self.ui.dial_drywet.setLabel("Dry/Wet")
  704. self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  705. self.ui.dial_drywet.setMinimum(0.0)
  706. self.ui.dial_drywet.setMaximum(1.0)
  707. self.ui.dial_drywet.forceWhiteLabelGradientText()
  708. self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET)
  709. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  710. self.ui.dial_vol.setPixmap(3)
  711. self.ui.dial_vol.setLabel("Volume")
  712. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  713. self.ui.dial_vol.setMinimum(0.0)
  714. self.ui.dial_vol.setMaximum(1.27)
  715. self.ui.dial_vol.forceWhiteLabelGradientText()
  716. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  717. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  718. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  719. # -------------------------------------------------------------
  720. self.b_enable = self.ui.b_enable
  721. self.b_gui = self.ui.b_gui
  722. self.b_edit = self.ui.b_edit
  723. self.label_name = self.ui.label_name
  724. self.led_control = self.ui.led_control
  725. self.led_midi = self.ui.led_midi
  726. self.led_audio_in = self.ui.led_audio_in
  727. self.led_audio_out = self.ui.led_audio_out
  728. self.peak_in = self.ui.peak_in
  729. self.peak_out = self.ui.peak_out
  730. self.ready()
  731. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  732. #------------------------------------------------------------------
  733. def getFixedHeight(self):
  734. return 79
  735. #------------------------------------------------------------------
  736. def paintEvent(self, event):
  737. painter = QPainter(self)
  738. painter.setBrush(Qt.transparent)
  739. painter.setPen(QPen(QColor(42, 42, 42), 1))
  740. painter.drawRect(0, 1, self.width()-1, 79-3)
  741. painter.setPen(QPen(QColor(60, 60, 60), 1))
  742. painter.drawLine(0, 0, self.width(), 0)
  743. AbstractPluginSlot.paintEvent(self, event)
  744. # ------------------------------------------------------------------------------------------------------------
  745. class PluginSlot_Nekobi(AbstractPluginSlot):
  746. def __init__(self, parent, pluginId):
  747. AbstractPluginSlot.__init__(self, parent, pluginId)
  748. #self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
  749. #self.ui.setupUi(self)
  750. # -------------------------------------------------------------
  751. # Set-up GUI
  752. self.fPixmapCenter = QPixmap(":/bitmaps/background_nekobi.png")
  753. self.fPixmapLeft = QPixmap(":/bitmaps/background_nekobi_left.png")
  754. self.fPixmapLeftRect = QRectF(0, 0, self.fPixmapLeft.width(), self.fPixmapLeft.height())
  755. self.fPixmapRight = QPixmap(":/bitmaps/background_nekobi_right.png")
  756. self.fPixmapRightRect = QRectF(0, 0, self.fPixmapRight.width(), self.fPixmapRight.height())
  757. #self.setStyleSheet("""
  758. #PluginSlot_Nekobi#PluginWidget {
  759. #background-image: url(:/bitmaps/background_nekobi.png);
  760. #background-repeat: repeat-xy;
  761. #}
  762. #QLabel#label_name {
  763. #color: #BBB;
  764. #}
  765. #""")
  766. #------------------------------------------------------------------
  767. def getFixedHeight(self):
  768. return 108
  769. #------------------------------------------------------------------
  770. def paintEvent(self, event):
  771. painter = QPainter(self)
  772. # main bg (center)
  773. painter.drawTiledPixmap(0, 0, self.width(), self.height(), self.fPixmapCenter)
  774. # left side
  775. painter.drawPixmap(self.fPixmapLeftRect, self.fPixmapLeft, self.fPixmapLeftRect)
  776. # right side
  777. rightTarget = QRectF(self.fPixmapRightRect)
  778. rightTarget.moveLeft(self.width()-rightTarget.width())
  779. painter.drawPixmap(rightTarget, self.fPixmapRight, self.fPixmapRightRect)
  780. AbstractPluginSlot.paintEvent(self, event)
  781. # ------------------------------------------------------------------------------------------------------------
  782. class PluginSlot_Calf(AbstractPluginSlot):
  783. def __init__(self, parent, pluginId):
  784. AbstractPluginSlot.__init__(self, parent, pluginId)
  785. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  786. self.ui.setupUi(self)
  787. # -------------------------------------------------------------
  788. # Internal stuff
  789. self.fButtonFont = QFont()
  790. #self.fButtonFont.setBold(False)
  791. self.fButtonFont.setPointSize(8)
  792. self.fButtonColorOn = QColor( 18, 41, 87)
  793. self.fButtonColorOff = QColor(150, 150, 150)
  794. # -------------------------------------------------------------
  795. # Set-up GUI
  796. self.setStyleSheet("""
  797. QLabel#label_audio_in, QLabel#label_audio_out, QLabel#label_midi {
  798. color: black;
  799. }
  800. PluginSlot_Calf#PluginWidget {
  801. background-image: url(:/bitmaps/background_calf.png);
  802. background-repeat: repeat-xy;
  803. border: 2px;
  804. }
  805. """)
  806. self.ui.b_gui.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  807. self.ui.b_edit.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png")
  808. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  809. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  810. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  811. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  812. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  813. else:
  814. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  815. labelFont = self.ui.label_name.font()
  816. labelFont.setBold(True)
  817. labelFont.setPointSize(labelFont.pointSize()+3)
  818. self.ui.label_name.setFont(labelFont)
  819. audioCount = gCarla.host.get_audio_port_count_info(self.fPluginId) if gCarla.host is not None else {'ins': 2, 'outs': 2 }
  820. midiCount = gCarla.host.get_midi_port_count_info(self.fPluginId) if gCarla.host is not None else {'ins': 1, 'outs': 0 }
  821. if audioCount['ins'] == 0:
  822. self.ui.label_audio_in.hide()
  823. self.ui.peak_in.hide()
  824. if audioCount['outs'] > 0:
  825. self.ui.peak_out.setMinimumWidth(200)
  826. if audioCount['outs'] == 0:
  827. self.ui.label_audio_out.hide()
  828. self.ui.peak_out.hide()
  829. if midiCount['ins'] == 0:
  830. self.ui.label_midi.hide()
  831. self.ui.led_midi.hide()
  832. # -------------------------------------------------------------
  833. self.b_gui = self.ui.b_gui
  834. self.b_edit = self.ui.b_edit
  835. self.b_remove = self.ui.b_remove
  836. self.label_name = self.ui.label_name
  837. self.led_midi = self.ui.led_midi
  838. self.peak_in = self.ui.peak_in
  839. self.peak_out = self.ui.peak_out
  840. self.ready()
  841. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  842. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  843. #------------------------------------------------------------------
  844. def getFixedHeight(self):
  845. return 70
  846. #------------------------------------------------------------------
  847. def pluginHintsChanged(self, hints):
  848. if hints & PLUGIN_HAS_CUSTOM_UI:
  849. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  850. else:
  851. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  852. AbstractPluginSlot.pluginHintsChanged(self, hints)
  853. # ------------------------------------------------------------------------------------------------------------
  854. class PluginSlot_ZitaRev(AbstractPluginSlot):
  855. def __init__(self, parent, pluginId):
  856. AbstractPluginSlot.__init__(self, parent, pluginId)
  857. self.ui = ui_carla_plugin_zita.Ui_PluginWidget()
  858. self.ui.setupUi(self)
  859. # -------------------------------------------------------------
  860. # Internal stuff
  861. audioCount = gCarla.host.get_audio_port_count_info(self.fPluginId) if gCarla.host is not None else {'ins': 2, 'outs': 2 }
  862. # -------------------------------------------------------------
  863. # Set-up GUI
  864. self.setMinimumWidth(640)
  865. self.setStyleSheet("""
  866. PluginSlot_ZitaRev#PluginWidget {
  867. background-color: #404040;
  868. border: 2px solid transparent;
  869. }
  870. QWidget#w_revsect {
  871. background-image: url(:/bitmaps/zita-rev/revsect.png);
  872. }
  873. QWidget#w_eq1sect {
  874. background-image: url(:/bitmaps/zita-rev/eq1sect.png);
  875. }
  876. QWidget#w_eq2sect {
  877. background-image: url(:/bitmaps/zita-rev/eq2sect.png);
  878. }
  879. QWidget#w_ambmixsect {
  880. background-image: url(:/bitmaps/zita-rev/%s.png);
  881. }
  882. QWidget#w_redzita {
  883. background-image: url(:/bitmaps/zita-rev/redzita.png);
  884. }
  885. """ % ("mixsect" if audioCount['outs'] == 2 else "ambsect"))
  886. # -------------------------------------------------------------
  887. # Set-up Knobs
  888. self.fKnobDelay = PixmapDial(self, 0)
  889. self.fKnobDelay.setPixmap(6)
  890. self.fKnobDelay.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  891. self.fKnobDelay.setMinimum(0.02)
  892. self.fKnobDelay.setMaximum(0.10)
  893. self.fKnobXover = PixmapDial(self, 1)
  894. self.fKnobXover.setPixmap(6)
  895. self.fKnobXover.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  896. self.fKnobXover.setMinimum(50.0)
  897. self.fKnobXover.setMaximum(1000.0)
  898. self.fKnobRtLow = PixmapDial(self, 2)
  899. self.fKnobRtLow.setPixmap(6)
  900. self.fKnobRtLow.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  901. self.fKnobRtLow.setMinimum(1.0)
  902. self.fKnobRtLow.setMaximum(8.0)
  903. self.fKnobRtMid = PixmapDial(self, 3)
  904. self.fKnobRtMid.setPixmap(6)
  905. self.fKnobRtMid.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  906. self.fKnobRtMid.setMinimum(1.0)
  907. self.fKnobRtMid.setMaximum(8.0)
  908. self.fKnobDamping = PixmapDial(self, 4)
  909. self.fKnobDamping.setPixmap(6)
  910. self.fKnobDamping.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  911. self.fKnobDamping.setMinimum(1500.0)
  912. self.fKnobDamping.setMaximum(24000.0)
  913. self.fKnobEq1Freq = PixmapDial(self, 5)
  914. self.fKnobEq1Freq.setPixmap(6)
  915. self.fKnobEq1Freq.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  916. self.fKnobEq1Freq.setMinimum(40.0)
  917. self.fKnobEq1Freq.setMaximum(10000.0)
  918. self.fKnobEq1Gain = PixmapDial(self, 6)
  919. self.fKnobEq1Gain.setPixmap(6)
  920. self.fKnobEq1Gain.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  921. self.fKnobEq1Gain.setMinimum(-20.0)
  922. self.fKnobEq1Gain.setMaximum(20.0)
  923. self.fKnobEq2Freq = PixmapDial(self, 7)
  924. self.fKnobEq2Freq.setPixmap(6)
  925. self.fKnobEq2Freq.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  926. self.fKnobEq2Freq.setMinimum(40.0)
  927. self.fKnobEq2Freq.setMaximum(10000.0)
  928. self.fKnobEq2Gain = PixmapDial(self, 8)
  929. self.fKnobEq2Gain.setPixmap(6)
  930. self.fKnobEq2Gain.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  931. self.fKnobEq2Gain.setMinimum(-20.0)
  932. self.fKnobEq2Gain.setMaximum(20.0)
  933. self.fKnobMix = PixmapDial(self, 9)
  934. self.fKnobMix.setPixmap(6)
  935. self.fKnobMix.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_ZITA)
  936. self.fKnobMix.setMinimum(0.0)
  937. self.fKnobMix.setMaximum(1.0)
  938. self.fParameterList.append([0, self.fKnobDelay])
  939. self.fParameterList.append([1, self.fKnobXover])
  940. self.fParameterList.append([2, self.fKnobRtLow])
  941. self.fParameterList.append([3, self.fKnobRtMid])
  942. self.fParameterList.append([4, self.fKnobDamping])
  943. self.fParameterList.append([5, self.fKnobEq1Freq])
  944. self.fParameterList.append([6, self.fKnobEq1Gain])
  945. self.fParameterList.append([7, self.fKnobEq2Freq])
  946. self.fParameterList.append([8, self.fKnobEq2Gain])
  947. self.fParameterList.append([9, self.fKnobMix])
  948. # -------------------------------------------------------------
  949. self.ready()
  950. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  951. #------------------------------------------------------------------
  952. def getFixedHeight(self):
  953. return 79
  954. #------------------------------------------------------------------
  955. def paintEvent(self, event):
  956. AbstractPluginSlot.paintEvent(self, event)
  957. self.drawOutline()
  958. def resizeEvent(self, event):
  959. self.fKnobDelay.move(self.ui.w_revsect.x()+31, self.ui.w_revsect.y()+33)
  960. self.fKnobXover.move(self.ui.w_revsect.x()+93, self.ui.w_revsect.y()+18)
  961. self.fKnobRtLow.move(self.ui.w_revsect.x()+148, self.ui.w_revsect.y()+18)
  962. self.fKnobRtMid.move(self.ui.w_revsect.x()+208, self.ui.w_revsect.y()+18)
  963. self.fKnobDamping.move(self.ui.w_revsect.x()+268, self.ui.w_revsect.y()+18)
  964. self.fKnobEq1Freq.move(self.ui.w_eq1sect.x()+20, self.ui.w_eq1sect.y()+33)
  965. self.fKnobEq1Gain.move(self.ui.w_eq1sect.x()+69, self.ui.w_eq1sect.y()+18)
  966. self.fKnobEq2Freq.move(self.ui.w_eq2sect.x()+20, self.ui.w_eq2sect.y()+33)
  967. self.fKnobEq2Gain.move(self.ui.w_eq2sect.x()+69, self.ui.w_eq2sect.y()+18)
  968. self.fKnobMix.move(self.ui.w_ambmixsect.x()+24, self.ui.w_ambmixsect.y()+33)
  969. AbstractPluginSlot.resizeEvent(self, event)
  970. # ------------------------------------------------------------------------------------------------------------
  971. class PluginSlot_ZynFX(AbstractPluginSlot):
  972. def __init__(self, parent, pluginId):
  973. AbstractPluginSlot.__init__(self, parent, pluginId)
  974. self.ui = ui_carla_plugin_zynfx.Ui_PluginWidget()
  975. self.ui.setupUi(self)
  976. # -------------------------------------------------------------
  977. # Set-up GUI
  978. self.setStyleSheet("""
  979. PluginSlot_ZynFX#PluginWidget {
  980. background-image: url(:/bitmaps/background_zynfx.png);
  981. background-repeat: repeat-xy;
  982. border: 2px;
  983. }
  984. QLabel#label_name, QLabel#label_presets {
  985. color: #BBB;
  986. }
  987. """)
  988. self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png")
  989. self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png")
  990. labelFont = self.ui.label_name.font()
  991. labelFont.setBold(True)
  992. labelFont.setPointSize(9)
  993. self.ui.label_name.setFont(labelFont)
  994. presetFont = self.ui.label_presets.font()
  995. presetFont.setBold(True)
  996. presetFont.setPointSize(8)
  997. self.ui.label_presets.setFont(presetFont)
  998. # -------------------------------------------------------------
  999. # Set-up parameters
  1000. parameterCount = gCarla.host.get_parameter_count(self.fPluginId) if gCarla.host is not None else 0
  1001. index = 0
  1002. for i in range(parameterCount):
  1003. paramInfo = gCarla.host.get_parameter_info(self.fPluginId, i)
  1004. paramData = gCarla.host.get_parameter_data(self.fPluginId, i)
  1005. paramRanges = gCarla.host.get_parameter_ranges(self.fPluginId, i)
  1006. if paramData['type'] != PARAMETER_INPUT:
  1007. continue
  1008. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1009. continue
  1010. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1011. continue
  1012. paramName = paramInfo['name']
  1013. # real zyn fx plugins
  1014. if self.fPluginInfo['label'] == "zynalienwah":
  1015. if i == 0: paramName = "Freq"
  1016. elif i == 1: paramName = "Rnd"
  1017. elif i == 2: paramName = "L type" # combobox
  1018. elif i == 3: paramName = "St.df"
  1019. elif i == 5: paramName = "Fb"
  1020. elif i == 7: paramName = "L/R"
  1021. if self.fPluginInfo['label'] == "zynchorus":
  1022. if i == 0: paramName = "Freq"
  1023. elif i == 1: paramName = "Rnd"
  1024. elif i == 2: paramName = "L type" # combobox
  1025. elif i == 3: paramName = "St.df"
  1026. elif i == 6: paramName = "Fb"
  1027. elif i == 7: paramName = "L/R"
  1028. elif i == 8: paramName = "Flngr" # button
  1029. elif i == 9: paramName = "Subst" # button
  1030. elif self.fPluginInfo['label'] == "zyndistortion":
  1031. if i == 0: paramName = "LRc."
  1032. elif i == 4: paramName = "Neg." # button
  1033. elif i == 5: paramName = "LPF"
  1034. elif i == 6: paramName = "HPF"
  1035. elif i == 7: paramName = "St." # button
  1036. elif i == 8: paramName = "PF" # button
  1037. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  1038. if i == 0: paramName = "Freq"
  1039. elif i == 1: paramName = "Rnd"
  1040. elif i == 2: paramName = "L type" # combobox
  1041. elif i == 3: paramName = "St.df"
  1042. elif i == 4: paramName = "LfoD"
  1043. elif i == 5: paramName = "A.S."
  1044. elif i == 6: paramName = "A.Inv." # button
  1045. elif i == 7: paramName = "A.M."
  1046. elif self.fPluginInfo['label'] == "zynecho":
  1047. if i == 1: paramName = "LRdl."
  1048. elif i == 2: paramName = "LRc."
  1049. elif i == 3: paramName = "Fb."
  1050. elif i == 4: paramName = "Damp"
  1051. elif self.fPluginInfo['label'] == "zynphaser":
  1052. if i == 0: paramName = "Freq"
  1053. elif i == 1: paramName = "Rnd"
  1054. elif i == 2: paramName = "L type" # combobox
  1055. elif i == 3: paramName = "St.df"
  1056. elif i == 5: paramName = "Fb"
  1057. elif i == 7: paramName = "L/R"
  1058. elif i == 8: paramName = "Subst" # button
  1059. elif i == 9: paramName = "Phase"
  1060. elif i == 11: paramName = "Dist"
  1061. elif self.fPluginInfo['label'] == "zynreverb":
  1062. if i == 2: paramName = "I.delfb"
  1063. elif i == 5: paramName = "LPF"
  1064. elif i == 6: paramName = "HPF"
  1065. elif i == 9: paramName = "R.S."
  1066. elif i == 10: paramName = "I.del"
  1067. else:
  1068. paramName = getParameterShortName(paramInfo['name'])
  1069. widget = PixmapDial(self, i)
  1070. widget.setPixmap(5)
  1071. widget.setLabel(paramName)
  1072. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1073. widget.setMinimum(paramRanges['min'])
  1074. widget.setMaximum(paramRanges['max'])
  1075. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1076. widget.setEnabled(False)
  1077. self.ui.w_knobs.layout().insertWidget(index, widget)
  1078. index += 1
  1079. self.fParameterList.append([i, widget])
  1080. self.ui.dial_drywet.setIndex(PARAMETER_DRYWET)
  1081. self.ui.dial_drywet.setPixmap(5)
  1082. self.ui.dial_drywet.setLabel("Wet")
  1083. self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1084. self.ui.dial_drywet.setMinimum(0.0)
  1085. self.ui.dial_drywet.setMaximum(1.0)
  1086. self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET)
  1087. self.ui.dial_vol.setIndex(PARAMETER_VOLUME)
  1088. self.ui.dial_vol.setPixmap(5)
  1089. self.ui.dial_vol.setLabel("Vol")
  1090. self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  1091. self.ui.dial_vol.setMinimum(0.0)
  1092. self.ui.dial_vol.setMaximum(1.27)
  1093. self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME)
  1094. self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet])
  1095. self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol])
  1096. # -------------------------------------------------------------
  1097. # Set-up MIDI programs
  1098. midiProgramCount = gCarla.host.get_midi_program_count(self.fPluginId) if gCarla.host is not None else 0
  1099. if midiProgramCount > 0:
  1100. self.ui.cb_presets.setEnabled(True)
  1101. self.ui.label_presets.setEnabled(True)
  1102. for i in range(midiProgramCount):
  1103. mpData = gCarla.host.get_midi_program_data(self.fPluginId, i)
  1104. mpName = mpData['name']
  1105. self.ui.cb_presets.addItem(mpName)
  1106. self.fCurrentMidiProgram = gCarla.host.get_current_midi_program_index(self.fPluginId)
  1107. self.ui.cb_presets.setCurrentIndex(self.fCurrentMidiProgram)
  1108. else:
  1109. self.fCurrentMidiProgram = -1
  1110. self.ui.cb_presets.setEnabled(False)
  1111. self.ui.cb_presets.setVisible(False)
  1112. self.ui.label_presets.setEnabled(False)
  1113. self.ui.label_presets.setVisible(False)
  1114. # -------------------------------------------------------------
  1115. self.b_enable = self.ui.b_enable
  1116. self.b_edit = self.ui.b_edit
  1117. self.cb_presets = self.ui.cb_presets
  1118. self.label_name = self.ui.label_name
  1119. self.led_control = self.ui.led_control
  1120. self.led_midi = self.ui.led_midi
  1121. self.led_audio_in = self.ui.led_audio_in
  1122. self.led_audio_out = self.ui.led_audio_out
  1123. self.peak_in = self.ui.peak_in
  1124. self.peak_out = self.ui.peak_out
  1125. self.ready()
  1126. self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu)
  1127. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  1128. #------------------------------------------------------------------
  1129. def getFixedHeight(self):
  1130. return 74
  1131. #------------------------------------------------------------------
  1132. def paintEvent(self, event):
  1133. painter = QPainter(self)
  1134. painter.setBrush(Qt.transparent)
  1135. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1136. painter.drawRect(0, 1, self.width()-1, 74-3)
  1137. painter.setPen(QPen(QColor(94, 94, 94), 1))
  1138. painter.drawLine(0, 0, self.width(), 0)
  1139. AbstractPluginSlot.paintEvent(self, event)
  1140. # ------------------------------------------------------------------------------------------------------------
  1141. def createPluginSlot(parent, pluginId):
  1142. if not gCarla.useCustomSkins:
  1143. return PluginSlot_Default(parent, pluginId)
  1144. pluginInfo = gCarla.host.get_plugin_info(pluginId)
  1145. pluginName = gCarla.host.get_real_plugin_name(pluginId)
  1146. pluginLabel = pluginInfo['label']
  1147. uniqueId = pluginInfo['uniqueId']
  1148. #pluginMaker = pluginInfo['maker']
  1149. #pluginIcon = pluginInfo['iconName']
  1150. if pluginInfo['type'] == PLUGIN_INTERNAL:
  1151. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1152. return PluginSlot_ZynFX(parent, pluginId)
  1153. elif pluginInfo['type'] == PLUGIN_LADSPA:
  1154. if (pluginLabel == "zita-reverb" and uniqueId == 3701) or (pluginLabel == "zita-reverb-amb" and uniqueId == 3702):
  1155. return PluginSlot_ZitaRev(parent, pluginId)
  1156. if pluginName.split(" ", 1)[0].lower() == "calf":
  1157. return PluginSlot_Calf(parent, pluginId)
  1158. #if pluginName.lower() == "nekobi":
  1159. #return PluginSlot_Nekobi(parent, pluginId)
  1160. return PluginSlot_BasicFX(parent, pluginId)
  1161. # ------------------------------------------------------------------------------------------------------------
  1162. # Main Testing
  1163. if __name__ == '__main__':
  1164. from carla_app import CarlaApplication
  1165. import resources_rc
  1166. app = CarlaApplication("Carla-Skins")
  1167. #gui = PluginSlot_BasicFX(None, 0)
  1168. #gui = PluginSlot_Calf(None, 0)
  1169. #gui = PluginSlot_Default(None, 0)
  1170. #gui = PluginSlot_ZitaRev(None, 0)
  1171. gui = PluginSlot_ZynFX(None, 0)
  1172. gui.setSelected(True)
  1173. gui.show()
  1174. app.exec_()