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_widgets.py 65KB

11 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 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
9 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
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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla widgets code
  4. # Copyright (C) 2011-2016 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 pyqtSignal, pyqtSlot, pyqtWrapperType, Qt, QByteArray, QSettings, QTimer
  24. from PyQt5.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  25. from PyQt5.QtWidgets import QDialog, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  26. else:
  27. from PyQt4.QtCore import pyqtSignal, pyqtSlot, pyqtWrapperType, Qt, QByteArray, QSettings, QTimer
  28. from PyQt4.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
  29. from PyQt4.QtGui import QDialog, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
  30. # ------------------------------------------------------------------------------------------------------------
  31. # Imports (Custom)
  32. import ui_carla_about
  33. import ui_carla_about_juce
  34. import ui_carla_edit
  35. import ui_carla_parameter
  36. from carla_shared import *
  37. from carla_utils import *
  38. from paramspinbox import CustomInputDialog
  39. from pixmapkeyboard import PixmapKeyboardHArea
  40. # ------------------------------------------------------------------------------------------------------------
  41. # Carla GUI defines
  42. ICON_STATE_ON = 3 # turns on, sets as wait
  43. ICON_STATE_WAIT = 2 # nothing, sets as off
  44. ICON_STATE_OFF = 1 # turns off, sets as null
  45. ICON_STATE_NULL = 0 # nothing
  46. # ------------------------------------------------------------------------------------------------------------
  47. # Carla About dialog
  48. class CarlaAboutW(QDialog):
  49. def __init__(self, parent, host):
  50. QDialog.__init__(self, parent)
  51. self.ui = ui_carla_about.Ui_CarlaAboutW()
  52. self.ui.setupUi(self)
  53. if False:
  54. # kdevelop likes this :)
  55. host = CarlaHostNull()
  56. if host.isControl:
  57. extraInfo = " - <b>%s</b>" % self.tr("OSC Bridge Version")
  58. elif host.isPlugin:
  59. extraInfo = " - <b>%s</b>" % self.tr("Plugin Version")
  60. else:
  61. extraInfo = ""
  62. self.ui.l_about.setText(self.tr(""
  63. "<br>Version %s"
  64. "<br>Carla is a fully-featured audio plugin host%s.<br>"
  65. "<br>Copyright (C) 2011-2016 falkTX<br>"
  66. "" % (VERSION, extraInfo)))
  67. if host.isControl:
  68. self.ui.l_extended.hide()
  69. self.ui.tabWidget.removeTab(2)
  70. self.ui.tabWidget.removeTab(1)
  71. self.ui.l_extended.setText(gCarla.utils.get_complete_license_text())
  72. if host.is_engine_running() and not host.isControl:
  73. self.ui.le_osc_url_tcp.setText(host.get_host_osc_url_tcp())
  74. self.ui.le_osc_url_udp.setText(host.get_host_osc_url_udp())
  75. else:
  76. self.ui.le_osc_url_tcp.setText(self.tr("(Engine not running)"))
  77. self.ui.le_osc_url_udp.setText(self.tr("(Engine not running)"))
  78. self.ui.l_osc_cmds.setText("<table>"
  79. "<tr><td>" "/set_active" "&nbsp;</td><td>&lt;" "i-value" "&gt;</td><td>" "</td></tr>"
  80. "<tr><td>" "/set_drywet" "&nbsp;</td><td>&lt;" "f-value" "&gt;</td><td>" "</td></tr>"
  81. "<tr><td>" "/set_volume" "&nbsp;</td><td>&lt;" "f-value" "&gt;</td><td>" "</td></tr>"
  82. "<tr><td>" "/set_balance_left" "&nbsp;</td><td>&lt;" "f-value" "&gt;</td><td>" "</td></tr>"
  83. "<tr><td>" "/set_balance_right" "&nbsp;</td><td>&lt;" "f-value" "&gt;</td><td>" "</td></tr>"
  84. "<tr><td>" "/set_panning" "&nbsp;</td><td>&lt;" "f-value" "&gt;</td><td>" "</td></tr>"
  85. "<tr><td>" "/set_parameter_value" "&nbsp;</td><td>&lt;" "i-index" "&gt;</td><td>&lt;" "f-value" "&gt;</td></tr>"
  86. "<tr><td>" "/set_parameter_midi_cc" "&nbsp;</td><td>&lt;" "i-index" "&gt;</td><td>&lt;" "i-cc" "&gt;</td></tr>"
  87. "<tr><td>" "/set_parameter_midi_channel" "&nbsp;</td><td>&lt;" "i-index" "&gt;</td><td>&lt;" "i-channel" "&gt;</td></tr>"
  88. "<tr><td>" "/set_program" "&nbsp;</td><td>&lt;" "i-index" "&gt;</td><td>" "</td></tr>"
  89. "<tr><td>" "/set_midi_program" "&nbsp;</td><td>&lt;" "i-index" "&gt;</td><td>" "</td></tr>"
  90. "<tr><td>" "/note_on" "&nbsp;</td><td>&lt;" "i-note" "&gt;</td><td>&lt;" "i-velo" "&gt;</td></tr>"
  91. "<tr><td>" "/note_off" "&nbsp;</td><td>&lt;" "i-note" "&gt;</td><td>" "</td></tr>"
  92. "</table>"
  93. )
  94. self.ui.l_example.setText("/Carla/2/set_parameter_value 5 1.0")
  95. self.ui.l_example_help.setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>")
  96. self.ui.l_ladspa.setText(self.tr("Everything! (Including LRDF)"))
  97. self.ui.l_dssi.setText(self.tr("Everything! (Including CustomData/Chunks)"))
  98. self.ui.l_lv2.setText(self.tr("About 110&#37; complete (using custom extensions)<br/>"
  99. "Implemented Feature/Extensions:"
  100. "<ul>"
  101. "<li>http://lv2plug.in/ns/ext/atom</li>"
  102. "<li>http://lv2plug.in/ns/ext/buf-size</li>"
  103. "<li>http://lv2plug.in/ns/ext/data-access</li>"
  104. #"<li>http://lv2plug.in/ns/ext/dynmanifest</li>"
  105. "<li>http://lv2plug.in/ns/ext/event</li>"
  106. "<li>http://lv2plug.in/ns/ext/instance-access</li>"
  107. "<li>http://lv2plug.in/ns/ext/log</li>"
  108. "<li>http://lv2plug.in/ns/ext/midi</li>"
  109. #"<li>http://lv2plug.in/ns/ext/morph</li>"
  110. "<li>http://lv2plug.in/ns/ext/options</li>"
  111. "<li>http://lv2plug.in/ns/ext/parameters</li>"
  112. #"<li>http://lv2plug.in/ns/ext/patch</li>"
  113. #"<li>http://lv2plug.in/ns/ext/port-groups</li>"
  114. "<li>http://lv2plug.in/ns/ext/port-props</li>"
  115. "<li>http://lv2plug.in/ns/ext/presets</li>"
  116. "<li>http://lv2plug.in/ns/ext/resize-port</li>"
  117. "<li>http://lv2plug.in/ns/ext/state</li>"
  118. "<li>http://lv2plug.in/ns/ext/time</li>"
  119. "<li>http://lv2plug.in/ns/ext/uri-map</li>"
  120. "<li>http://lv2plug.in/ns/ext/urid</li>"
  121. "<li>http://lv2plug.in/ns/ext/worker</li>"
  122. "<li>http://lv2plug.in/ns/extensions/ui</li>"
  123. "<li>http://lv2plug.in/ns/extensions/units</li>"
  124. "<li>http://home.gna.org/lv2dynparam/rtmempool/v1</li>"
  125. "<li>http://kxstudio.sf.net/ns/lv2ext/external-ui</li>"
  126. "<li>http://kxstudio.sf.net/ns/lv2ext/programs</li>"
  127. "<li>http://kxstudio.sf.net/ns/lv2ext/props</li>"
  128. "<li>http://kxstudio.sf.net/ns/lv2ext/rtmempool</li>"
  129. "<li>http://ll-plugins.nongnu.org/lv2/ext/midimap</li>"
  130. "<li>http://ll-plugins.nongnu.org/lv2/ext/miditype</li>"
  131. "</ul>"))
  132. if MACOS or WINDOWS:
  133. self.ui.l_vst2.setText(self.tr("Using Juce host"))
  134. self.ui.l_vst3.setText(self.tr("Using Juce host"))
  135. if MACOS:
  136. self.ui.l_au.setText(self.tr("Using Juce host"))
  137. else:
  138. self.ui.line_vst3.hide()
  139. self.ui.l_au.hide()
  140. self.ui.lid_au.hide()
  141. else:
  142. self.ui.l_vst2.setText(self.tr("About 85% complete (missing vst bank/presets and some minor stuff)"))
  143. self.ui.line_vst2.hide()
  144. self.ui.l_vst3.hide()
  145. self.ui.lid_vst3.hide()
  146. self.ui.line_vst3.hide()
  147. self.ui.l_au.hide()
  148. self.ui.lid_au.hide()
  149. # 2nd tab is usually longer than the 1st
  150. # adjust appropriately
  151. self.ui.tabWidget.setCurrentIndex(1)
  152. self.adjustSize()
  153. self.ui.tabWidget.setCurrentIndex(0)
  154. self.setFixedSize(self.size())
  155. if WINDOWS:
  156. self.setWindowFlags(self.windowFlags()|Qt.MSWindowsFixedSizeDialogHint)
  157. def done(self, r):
  158. QDialog.done(self, r)
  159. self.close()
  160. # ------------------------------------------------------------------------------------------------------------
  161. # JUCE About dialog
  162. class JuceAboutW(QDialog):
  163. def __init__(self, parent):
  164. QDialog.__init__(self, parent)
  165. self.ui = ui_carla_about_juce.Ui_JuceAboutW()
  166. self.ui.setupUi(self)
  167. self.ui.l_text2.setText(self.tr("This program uses JUCE version %s." % gCarla.utils.get_juce_version()))
  168. self.adjustSize()
  169. self.setFixedSize(self.size())
  170. if WINDOWS:
  171. self.setWindowFlags(self.windowFlags()|Qt.MSWindowsFixedSizeDialogHint)
  172. def done(self, r):
  173. QDialog.done(self, r)
  174. self.close()
  175. # ------------------------------------------------------------------------------------------------------------
  176. # Plugin Parameter
  177. class PluginParameter(QWidget):
  178. midiControlChanged = pyqtSignal(int, int)
  179. midiChannelChanged = pyqtSignal(int, int)
  180. valueChanged = pyqtSignal(int, float)
  181. def __init__(self, parent, host, pInfo, pluginId, tabIndex):
  182. QWidget.__init__(self, parent)
  183. self.host = host
  184. self.ui = ui_carla_parameter.Ui_PluginParameter()
  185. self.ui.setupUi(self)
  186. if False:
  187. # kdevelop likes this :)
  188. host = CarlaHostNull()
  189. self.host = host
  190. # -------------------------------------------------------------
  191. # Internal stuff
  192. self.fMidiControl = -1
  193. self.fMidiChannel = 1
  194. self.fParameterId = pInfo['index']
  195. self.fPluginId = pluginId
  196. self.fTabIndex = tabIndex
  197. # -------------------------------------------------------------
  198. # Set-up GUI
  199. pType = pInfo['type']
  200. pHints = pInfo['hints']
  201. self.ui.label.setText(pInfo['name'])
  202. self.ui.widget.setName(pInfo['name'])
  203. self.ui.widget.setMinimum(pInfo['minimum'])
  204. self.ui.widget.setMaximum(pInfo['maximum'])
  205. self.ui.widget.setDefault(pInfo['default'])
  206. self.ui.widget.setValue(pInfo['current'])
  207. self.ui.widget.setLabel(pInfo['unit'])
  208. self.ui.widget.setStep(pInfo['step'])
  209. self.ui.widget.setStepSmall(pInfo['stepSmall'])
  210. self.ui.widget.setStepLarge(pInfo['stepLarge'])
  211. self.ui.widget.setScalePoints(pInfo['scalePoints'], bool(pHints & PARAMETER_USES_SCALEPOINTS))
  212. if pType == PARAMETER_INPUT:
  213. if not pHints & PARAMETER_IS_ENABLED:
  214. self.ui.label.setEnabled(False)
  215. self.ui.widget.setEnabled(False)
  216. self.ui.widget.setReadOnly(True)
  217. self.ui.sb_control.setEnabled(False)
  218. self.ui.sb_channel.setEnabled(False)
  219. elif not pHints & PARAMETER_IS_AUTOMABLE:
  220. self.ui.sb_control.setEnabled(False)
  221. self.ui.sb_channel.setEnabled(False)
  222. if pHints & PARAMETER_IS_READ_ONLY:
  223. self.ui.widget.setReadOnly(True)
  224. elif pType == PARAMETER_OUTPUT:
  225. self.ui.widget.setReadOnly(True)
  226. else:
  227. self.ui.widget.setVisible(False)
  228. self.ui.sb_control.setVisible(False)
  229. self.ui.sb_channel.setVisible(False)
  230. if pHints & PARAMETER_USES_CUSTOM_TEXT and not host.isPlugin:
  231. self.ui.widget.setTextCallback(self._textCallBack)
  232. self.ui.widget.updateAll()
  233. self.setMidiControl(pInfo['midiCC'])
  234. self.setMidiChannel(pInfo['midiChannel'])
  235. # -------------------------------------------------------------
  236. # Set-up connections
  237. self.ui.sb_control.customContextMenuRequested.connect(self.slot_controlSpinboxCustomMenu)
  238. self.ui.sb_channel.customContextMenuRequested.connect(self.slot_channelSpinboxCustomMenu)
  239. self.ui.sb_control.valueChanged.connect(self.slot_controlSpinboxChanged)
  240. self.ui.sb_channel.valueChanged.connect(self.slot_channelSpinboxChanged)
  241. self.ui.widget.valueChanged.connect(self.slot_widgetValueChanged)
  242. # -------------------------------------------------------------
  243. def getPluginId(self):
  244. return self.fPluginId
  245. def getTabIndex(self):
  246. return self.fTabIndex
  247. def setPluginId(self, pluginId):
  248. self.fPluginId = pluginId
  249. def setDefault(self, value):
  250. self.ui.widget.setDefault(value)
  251. def setValue(self, value):
  252. self.ui.widget.blockSignals(True)
  253. self.ui.widget.setValue(value)
  254. self.ui.widget.blockSignals(False)
  255. def setMidiControl(self, control):
  256. self.fMidiControl = control
  257. self.ui.sb_control.blockSignals(True)
  258. self.ui.sb_control.setValue(control)
  259. self.ui.sb_control.blockSignals(False)
  260. def setMidiChannel(self, channel):
  261. self.fMidiChannel = channel
  262. self.ui.sb_channel.blockSignals(True)
  263. self.ui.sb_channel.setValue(channel)
  264. self.ui.sb_channel.blockSignals(False)
  265. def setLabelWidth(self, width):
  266. self.ui.label.setFixedWidth(width)
  267. @pyqtSlot()
  268. def slot_controlSpinboxCustomMenu(self):
  269. menu = QMenu(self)
  270. actNone = menu.addAction(self.tr("None"))
  271. if self.fMidiControl == -1:
  272. actNone.setCheckable(True)
  273. actNone.setChecked(True)
  274. for cc in MIDI_CC_LIST:
  275. action = menu.addAction(cc)
  276. if self.fMidiControl != -1 and int(cc.split(" ", 1)[0], 16) == self.fMidiControl:
  277. action.setCheckable(True)
  278. action.setChecked(True)
  279. actSel = menu.exec_(QCursor.pos())
  280. if not actSel:
  281. pass
  282. elif actSel == actNone:
  283. self.ui.sb_control.setValue(-1)
  284. else:
  285. selControlStr = actSel.text()
  286. selControl = int(selControlStr.split(" ", 1)[0], 16)
  287. self.ui.sb_control.setValue(selControl)
  288. @pyqtSlot()
  289. def slot_channelSpinboxCustomMenu(self):
  290. menu = QMenu(self)
  291. for i in range(1, 16+1):
  292. action = menu.addAction("%i" % i)
  293. if self.fMidiChannel == i:
  294. action.setCheckable(True)
  295. action.setChecked(True)
  296. actSel = menu.exec_(QCursor.pos())
  297. if actSel:
  298. selChannel = int(actSel.text())
  299. self.ui.sb_channel.setValue(selChannel)
  300. @pyqtSlot(int)
  301. def slot_controlSpinboxChanged(self, control):
  302. self.fMidiControl = control
  303. self.midiControlChanged.emit(self.fParameterId, control)
  304. @pyqtSlot(int)
  305. def slot_channelSpinboxChanged(self, channel):
  306. self.fMidiChannel = channel
  307. self.midiChannelChanged.emit(self.fParameterId, channel)
  308. @pyqtSlot(float)
  309. def slot_widgetValueChanged(self, value):
  310. self.valueChanged.emit(self.fParameterId, value)
  311. def _textCallBack(self):
  312. return self.host.get_parameter_text(self.fPluginId, self.fParameterId)
  313. # ------------------------------------------------------------------------------------------------------------
  314. # Plugin Editor Parent (Meta class)
  315. class PluginEditParentMeta():
  316. #class PluginEditParentMeta(metaclass=ABCMeta):
  317. @abstractmethod
  318. def editDialogVisibilityChanged(self, pluginId, visible):
  319. raise NotImplementedError
  320. @abstractmethod
  321. def editDialogPluginHintsChanged(self, pluginId, hints):
  322. raise NotImplementedError
  323. @abstractmethod
  324. def editDialogParameterValueChanged(self, pluginId, parameterId, value):
  325. raise NotImplementedError
  326. @abstractmethod
  327. def editDialogProgramChanged(self, pluginId, index):
  328. raise NotImplementedError
  329. @abstractmethod
  330. def editDialogMidiProgramChanged(self, pluginId, index):
  331. raise NotImplementedError
  332. @abstractmethod
  333. def editDialogNotePressed(self, pluginId, note):
  334. raise NotImplementedError
  335. @abstractmethod
  336. def editDialogNoteReleased(self, pluginId, note):
  337. raise NotImplementedError
  338. @abstractmethod
  339. def editDialogMidiActivityChanged(self, pluginId, onOff):
  340. raise NotImplementedError
  341. # ------------------------------------------------------------------------------------------------------------
  342. # Plugin Editor (Built-in)
  343. class PluginEdit(QDialog):
  344. # settings
  345. kParamsPerPage = 8
  346. # signals
  347. SIGTERM = pyqtSignal()
  348. SIGUSR1 = pyqtSignal()
  349. def __init__(self, parent, host, pluginId):
  350. QDialog.__init__(self, parent.window() if parent is not None else None)
  351. self.host = host
  352. self.ui = ui_carla_edit.Ui_PluginEdit()
  353. self.ui.setupUi(self)
  354. if False:
  355. # kdevelop likes this :)
  356. parent = PluginEditParentMeta()
  357. host = CarlaHostNull()
  358. self.host = host
  359. # -------------------------------------------------------------
  360. # Internal stuff
  361. self.fGeometry = QByteArray()
  362. self.fParent = parent
  363. self.fPluginId = pluginId
  364. self.fPluginInfo = None
  365. self.fCurrentStateFilename = None
  366. self.fControlChannel = round(host.get_internal_parameter_value(pluginId, PARAMETER_CTRL_CHANNEL))
  367. self.fFirstInit = True
  368. self.fParameterList = [] # (type, id, widget)
  369. self.fParametersToUpdate = [] # (id, value)
  370. self.fPlayingNotes = [] # (channel, note)
  371. self.fTabIconOff = QIcon(":/bitmaps/led_off.png")
  372. self.fTabIconOn = QIcon(":/bitmaps/led_yellow.png")
  373. self.fTabIconTimers = []
  374. # used during testing
  375. self.fIdleTimerId = 0
  376. # -------------------------------------------------------------
  377. # Set-up GUI
  378. labelPluginFont = self.ui.label_plugin.font()
  379. labelPluginFont.setPixelSize(15)
  380. labelPluginFont.setWeight(75)
  381. self.ui.label_plugin.setFont(labelPluginFont)
  382. self.ui.dial_drywet.setCustomPaintMode(self.ui.dial_drywet.CUSTOM_PAINT_MODE_CARLA_WET)
  383. self.ui.dial_drywet.setPixmap(3)
  384. self.ui.dial_drywet.setLabel("Dry/Wet")
  385. self.ui.dial_drywet.setMinimum(0.0)
  386. self.ui.dial_drywet.setMaximum(1.0)
  387. self.ui.dial_drywet.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_DRYWET))
  388. self.ui.dial_vol.setCustomPaintMode(self.ui.dial_vol.CUSTOM_PAINT_MODE_CARLA_VOL)
  389. self.ui.dial_vol.setPixmap(3)
  390. self.ui.dial_vol.setLabel("Volume")
  391. self.ui.dial_vol.setMinimum(0.0)
  392. self.ui.dial_vol.setMaximum(1.27)
  393. self.ui.dial_vol.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_VOLUME))
  394. self.ui.dial_b_left.setCustomPaintMode(self.ui.dial_b_left.CUSTOM_PAINT_MODE_CARLA_L)
  395. self.ui.dial_b_left.setPixmap(4)
  396. self.ui.dial_b_left.setLabel("L")
  397. self.ui.dial_b_left.setMinimum(-1.0)
  398. self.ui.dial_b_left.setMaximum(1.0)
  399. self.ui.dial_b_left.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_BALANCE_LEFT))
  400. self.ui.dial_b_right.setCustomPaintMode(self.ui.dial_b_right.CUSTOM_PAINT_MODE_CARLA_R)
  401. self.ui.dial_b_right.setPixmap(4)
  402. self.ui.dial_b_right.setLabel("R")
  403. self.ui.dial_b_right.setMinimum(-1.0)
  404. self.ui.dial_b_right.setMaximum(1.0)
  405. self.ui.dial_b_right.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_BALANCE_RIGHT))
  406. self.ui.dial_pan.setCustomPaintMode(self.ui.dial_b_right.CUSTOM_PAINT_MODE_CARLA_PAN)
  407. self.ui.dial_pan.setPixmap(4)
  408. self.ui.dial_pan.setLabel("Pan")
  409. self.ui.dial_pan.setMinimum(-1.0)
  410. self.ui.dial_pan.setMaximum(1.0)
  411. self.ui.dial_pan.setValue(host.get_internal_parameter_value(pluginId, PARAMETER_PANNING))
  412. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  413. self.ui.scrollArea = PixmapKeyboardHArea(self)
  414. self.ui.keyboard = self.ui.scrollArea.keyboard
  415. self.ui.keyboard.setEnabled(self.fControlChannel >= 0)
  416. self.layout().addWidget(self.ui.scrollArea)
  417. self.ui.scrollArea.setEnabled(False)
  418. self.ui.scrollArea.setVisible(False)
  419. # todo
  420. self.ui.rb_balance.setEnabled(False)
  421. self.ui.rb_balance.setVisible(False)
  422. self.ui.rb_pan.setEnabled(False)
  423. self.ui.rb_pan.setVisible(False)
  424. self.reloadAll()
  425. self.fFirstInit = False
  426. # -------------------------------------------------------------
  427. # Set-up connections
  428. self.finished.connect(self.slot_finished)
  429. self.ui.ch_fixed_buffer.clicked.connect(self.slot_optionChanged)
  430. self.ui.ch_force_stereo.clicked.connect(self.slot_optionChanged)
  431. self.ui.ch_map_program_changes.clicked.connect(self.slot_optionChanged)
  432. self.ui.ch_use_chunks.clicked.connect(self.slot_optionChanged)
  433. self.ui.ch_send_program_changes.clicked.connect(self.slot_optionChanged)
  434. self.ui.ch_send_control_changes.clicked.connect(self.slot_optionChanged)
  435. self.ui.ch_send_channel_pressure.clicked.connect(self.slot_optionChanged)
  436. self.ui.ch_send_note_aftertouch.clicked.connect(self.slot_optionChanged)
  437. self.ui.ch_send_pitchbend.clicked.connect(self.slot_optionChanged)
  438. self.ui.ch_send_all_sound_off.clicked.connect(self.slot_optionChanged)
  439. self.ui.dial_drywet.realValueChanged.connect(self.slot_dryWetChanged)
  440. self.ui.dial_vol.realValueChanged.connect(self.slot_volumeChanged)
  441. self.ui.dial_b_left.realValueChanged.connect(self.slot_balanceLeftChanged)
  442. self.ui.dial_b_right.realValueChanged.connect(self.slot_balanceRightChanged)
  443. self.ui.dial_pan.realValueChanged.connect(self.slot_panChanged)
  444. self.ui.sb_ctrl_channel.valueChanged.connect(self.slot_ctrlChannelChanged)
  445. self.ui.dial_drywet.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  446. self.ui.dial_vol.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  447. self.ui.dial_b_left.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  448. self.ui.dial_b_right.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  449. self.ui.dial_pan.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  450. self.ui.sb_ctrl_channel.customContextMenuRequested.connect(self.slot_channelCustomMenu)
  451. self.ui.keyboard.noteOn.connect(self.slot_noteOn)
  452. self.ui.keyboard.noteOff.connect(self.slot_noteOff)
  453. self.ui.cb_programs.currentIndexChanged.connect(self.slot_programIndexChanged)
  454. self.ui.cb_midi_programs.currentIndexChanged.connect(self.slot_midiProgramIndexChanged)
  455. self.ui.b_save_state.clicked.connect(self.slot_stateSave)
  456. self.ui.b_load_state.clicked.connect(self.slot_stateLoad)
  457. #host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback)
  458. #host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback)
  459. host.NoteOnCallback.connect(self.slot_handleNoteOnCallback)
  460. host.NoteOffCallback.connect(self.slot_handleNoteOffCallback)
  461. host.UpdateCallback.connect(self.slot_handleUpdateCallback)
  462. host.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback)
  463. host.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback)
  464. host.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback)
  465. host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback)
  466. #------------------------------------------------------------------
  467. @pyqtSlot(int, int, int, int)
  468. def slot_handleNoteOnCallback(self, pluginId, channel, note, velocity):
  469. if self.fPluginId != pluginId: return
  470. if self.fControlChannel == channel:
  471. self.ui.keyboard.sendNoteOn(note, False)
  472. playItem = (channel, note)
  473. if playItem not in self.fPlayingNotes:
  474. self.fPlayingNotes.append(playItem)
  475. if len(self.fPlayingNotes) == 1 and self.fParent is not None:
  476. self.fParent.editDialogMidiActivityChanged(self.fPluginId, True)
  477. @pyqtSlot(int, int, int)
  478. def slot_handleNoteOffCallback(self, pluginId, channel, note):
  479. if self.fPluginId != pluginId: return
  480. if self.fControlChannel == channel:
  481. self.ui.keyboard.sendNoteOff(note, False)
  482. playItem = (channel, note)
  483. if playItem in self.fPlayingNotes:
  484. self.fPlayingNotes.remove(playItem)
  485. if len(self.fPlayingNotes) == 0 and self.fParent is not None:
  486. self.fParent.editDialogMidiActivityChanged(self.fPluginId, False)
  487. @pyqtSlot(int)
  488. def slot_handleUpdateCallback(self, pluginId):
  489. if self.fPluginId == pluginId:
  490. self.updateInfo()
  491. @pyqtSlot(int)
  492. def slot_handleReloadInfoCallback(self, pluginId):
  493. if self.fPluginId == pluginId:
  494. self.reloadInfo()
  495. @pyqtSlot(int)
  496. def slot_handleReloadParametersCallback(self, pluginId):
  497. if self.fPluginId == pluginId:
  498. self.reloadParameters()
  499. @pyqtSlot(int)
  500. def slot_handleReloadProgramsCallback(self, pluginId):
  501. if self.fPluginId == pluginId:
  502. self.reloadPrograms()
  503. @pyqtSlot(int)
  504. def slot_handleReloadAllCallback(self, pluginId):
  505. if self.fPluginId == pluginId:
  506. self.reloadAll()
  507. #------------------------------------------------------------------
  508. def updateInfo(self):
  509. # Update current program text
  510. if self.ui.cb_programs.count() > 0:
  511. pIndex = self.ui.cb_programs.currentIndex()
  512. if pIndex >= 0:
  513. pName = self.host.get_program_name(self.fPluginId, pIndex)
  514. #pName = pName[:40] + (pName[40:] and "...")
  515. self.ui.cb_programs.setItemText(pIndex, pName)
  516. # Update current midi program text
  517. if self.ui.cb_midi_programs.count() > 0:
  518. mpIndex = self.ui.cb_midi_programs.currentIndex()
  519. if mpIndex >= 0:
  520. mpData = self.host.get_midi_program_data(self.fPluginId, mpIndex)
  521. mpBank = mpData['bank']
  522. mpProg = mpData['program']
  523. mpName = mpData['name']
  524. #mpName = mpName[:40] + (mpName[40:] and "...")
  525. self.ui.cb_midi_programs.setItemText(mpIndex, "%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  526. # Update all parameter values
  527. for paramType, paramId, paramWidget in self.fParameterList:
  528. paramWidget.blockSignals(True)
  529. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId))
  530. paramWidget.blockSignals(False)
  531. # and the internal ones too
  532. self.ui.dial_drywet.blockSignals(True)
  533. self.ui.dial_drywet.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_DRYWET))
  534. self.ui.dial_drywet.blockSignals(False)
  535. self.ui.dial_vol.blockSignals(True)
  536. self.ui.dial_vol.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_VOLUME))
  537. self.ui.dial_vol.blockSignals(False)
  538. self.ui.dial_b_left.blockSignals(True)
  539. self.ui.dial_b_left.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_BALANCE_LEFT))
  540. self.ui.dial_b_left.blockSignals(False)
  541. self.ui.dial_b_right.blockSignals(True)
  542. self.ui.dial_b_right.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_BALANCE_RIGHT))
  543. self.ui.dial_b_right.blockSignals(False)
  544. self.ui.dial_pan.blockSignals(True)
  545. self.ui.dial_pan.setValue(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_PANNING))
  546. self.ui.dial_pan.blockSignals(False)
  547. self.fControlChannel = round(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_CTRL_CHANNEL))
  548. self.ui.sb_ctrl_channel.blockSignals(True)
  549. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  550. self.ui.sb_ctrl_channel.blockSignals(False)
  551. self.ui.keyboard.allNotesOff()
  552. self._updateCtrlPrograms()
  553. self.fParametersToUpdate = []
  554. #------------------------------------------------------------------
  555. def reloadAll(self):
  556. self.fPluginInfo = self.host.get_plugin_info(self.fPluginId)
  557. self.reloadInfo()
  558. self.reloadParameters()
  559. self.reloadPrograms()
  560. if self.fPluginInfo['type'] == PLUGIN_LV2:
  561. self.ui.b_save_state.setEnabled(False)
  562. if not self.ui.scrollArea.isEnabled():
  563. self.resize(self.width(), self.height()-self.ui.scrollArea.height())
  564. # Workaround for a Qt4 bug, see https://bugreports.qt-project.org/browse/QTBUG-7792
  565. if LINUX: QTimer.singleShot(0, self.slot_fixNameWordWrap)
  566. @pyqtSlot()
  567. def slot_fixNameWordWrap(self):
  568. self.adjustSize()
  569. self.setMinimumSize(self.width(), self.height())
  570. #------------------------------------------------------------------
  571. def reloadInfo(self):
  572. realPluginName = self.host.get_real_plugin_name(self.fPluginId)
  573. #audioCountInfo = self.host.get_audio_port_count_info(self.fPluginId)
  574. midiCountInfo = self.host.get_midi_port_count_info(self.fPluginId)
  575. #paramCountInfo = self.host.get_parameter_count_info(self.fPluginId)
  576. pluginHints = self.fPluginInfo['hints']
  577. self.ui.le_type.setText(getPluginTypeAsString(self.fPluginInfo['type']))
  578. self.ui.label_name.setEnabled(bool(realPluginName))
  579. self.ui.le_name.setEnabled(bool(realPluginName))
  580. self.ui.le_name.setText(realPluginName)
  581. self.ui.le_name.setToolTip(realPluginName)
  582. self.ui.label_label.setEnabled(bool(self.fPluginInfo['label']))
  583. self.ui.le_label.setEnabled(bool(self.fPluginInfo['label']))
  584. self.ui.le_label.setText(self.fPluginInfo['label'])
  585. self.ui.le_label.setToolTip(self.fPluginInfo['label'])
  586. self.ui.label_maker.setEnabled(bool(self.fPluginInfo['maker']))
  587. self.ui.le_maker.setEnabled(bool(self.fPluginInfo['maker']))
  588. self.ui.le_maker.setText(self.fPluginInfo['maker'])
  589. self.ui.le_maker.setToolTip(self.fPluginInfo['maker'])
  590. self.ui.label_copyright.setEnabled(bool(self.fPluginInfo['copyright']))
  591. self.ui.le_copyright.setEnabled(bool(self.fPluginInfo['copyright']))
  592. self.ui.le_copyright.setText(self.fPluginInfo['copyright'])
  593. self.ui.le_copyright.setToolTip(self.fPluginInfo['copyright'])
  594. self.ui.label_unique_id.setEnabled(bool(self.fPluginInfo['uniqueId']))
  595. self.ui.le_unique_id.setEnabled(bool(self.fPluginInfo['uniqueId']))
  596. self.ui.le_unique_id.setText(str(self.fPluginInfo['uniqueId']))
  597. self.ui.le_unique_id.setToolTip(str(self.fPluginInfo['uniqueId']))
  598. self.ui.label_plugin.setText("\n%s\n" % (self.fPluginInfo['name'] or "(none)"))
  599. self.setWindowTitle(self.fPluginInfo['name'] or "(none)")
  600. self.ui.dial_drywet.setEnabled(pluginHints & PLUGIN_CAN_DRYWET)
  601. self.ui.dial_vol.setEnabled(pluginHints & PLUGIN_CAN_VOLUME)
  602. self.ui.dial_b_left.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  603. self.ui.dial_b_right.setEnabled(pluginHints & PLUGIN_CAN_BALANCE)
  604. self.ui.dial_pan.setEnabled(pluginHints & PLUGIN_CAN_PANNING)
  605. self.ui.ch_use_chunks.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_USE_CHUNKS)
  606. self.ui.ch_use_chunks.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_USE_CHUNKS)
  607. self.ui.ch_fixed_buffer.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FIXED_BUFFERS)
  608. self.ui.ch_fixed_buffer.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FIXED_BUFFERS)
  609. self.ui.ch_force_stereo.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_FORCE_STEREO)
  610. self.ui.ch_force_stereo.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_FORCE_STEREO)
  611. self.ui.ch_map_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  612. self.ui.ch_map_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES)
  613. self.ui.ch_send_control_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  614. self.ui.ch_send_control_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CONTROL_CHANGES)
  615. self.ui.ch_send_channel_pressure.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  616. self.ui.ch_send_channel_pressure.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE)
  617. self.ui.ch_send_note_aftertouch.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  618. self.ui.ch_send_note_aftertouch.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH)
  619. self.ui.ch_send_pitchbend.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PITCHBEND)
  620. self.ui.ch_send_pitchbend.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PITCHBEND)
  621. self.ui.ch_send_all_sound_off.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  622. self.ui.ch_send_all_sound_off.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  623. canSendPrograms = bool((self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PROGRAM_CHANGES) != 0 and
  624. (self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) == 0)
  625. self.ui.ch_send_program_changes.setEnabled(canSendPrograms)
  626. self.ui.ch_send_program_changes.setChecked(self.fPluginInfo['optionsEnabled'] & PLUGIN_OPTION_SEND_PROGRAM_CHANGES)
  627. self.ui.sw_programs.setCurrentIndex(0 if self.fPluginInfo['type'] in (PLUGIN_VST2, PLUGIN_GIG, PLUGIN_SFZ) else 1)
  628. # Show/hide keyboard
  629. showKeyboard = (self.fPluginInfo['category'] == PLUGIN_CATEGORY_SYNTH or midiCountInfo['ins'] > 0 < midiCountInfo['outs'])
  630. self.ui.scrollArea.setEnabled(showKeyboard)
  631. self.ui.scrollArea.setVisible(showKeyboard)
  632. # Force-update parent for new hints
  633. if self.fParent is not None and not self.fFirstInit:
  634. self.fParent.editDialogPluginHintsChanged(self.fPluginId, pluginHints)
  635. def reloadParameters(self):
  636. # Reset
  637. self.fParameterList = []
  638. self.fParametersToUpdate = []
  639. self.fTabIconTimers = []
  640. # Remove all previous parameters
  641. for x in range(self.ui.tabWidget.count()-1):
  642. self.ui.tabWidget.widget(1).deleteLater()
  643. self.ui.tabWidget.removeTab(1)
  644. parameterCount = self.host.get_parameter_count(self.fPluginId)
  645. # -----------------------------------------------------------------
  646. if parameterCount <= 0:
  647. return
  648. # -----------------------------------------------------------------
  649. paramInputList = []
  650. paramOutputList = []
  651. paramInputWidth = 0
  652. paramOutputWidth = 0
  653. paramInputListFull = [] # ([params], width)
  654. paramOutputListFull = [] # ([params], width)
  655. for i in range(min(parameterCount, self.host.maxParameters)):
  656. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  657. paramData = self.host.get_parameter_data(self.fPluginId, i)
  658. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  659. paramValue = self.host.get_current_parameter_value(self.fPluginId, i)
  660. if paramData['type'] not in (PARAMETER_INPUT, PARAMETER_OUTPUT):
  661. continue
  662. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  663. continue
  664. parameter = {
  665. 'type': paramData['type'],
  666. 'hints': paramData['hints'],
  667. 'name': paramInfo['name'],
  668. 'unit': paramInfo['unit'],
  669. 'scalePoints': [],
  670. 'index': paramData['index'],
  671. 'default': paramRanges['def'],
  672. 'minimum': paramRanges['min'],
  673. 'maximum': paramRanges['max'],
  674. 'step': paramRanges['step'],
  675. 'stepSmall': paramRanges['stepSmall'],
  676. 'stepLarge': paramRanges['stepLarge'],
  677. 'midiCC': paramData['midiCC'],
  678. 'midiChannel': paramData['midiChannel']+1,
  679. 'current': paramValue
  680. }
  681. for j in range(paramInfo['scalePointCount']):
  682. scalePointInfo = self.host.get_parameter_scalepoint_info(self.fPluginId, i, j)
  683. parameter['scalePoints'].append({
  684. 'value': scalePointInfo['value'],
  685. 'label': scalePointInfo['label']
  686. })
  687. #parameter['name'] = parameter['name'][:30] + (parameter['name'][30:] and "...")
  688. # -----------------------------------------------------------------
  689. # Get width values, in packs of 10
  690. if parameter['type'] == PARAMETER_INPUT:
  691. paramInputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  692. if paramInputWidthTMP > paramInputWidth:
  693. paramInputWidth = paramInputWidthTMP
  694. paramInputList.append(parameter)
  695. if len(paramInputList) == self.kParamsPerPage:
  696. paramInputListFull.append((paramInputList, paramInputWidth))
  697. paramInputList = []
  698. paramInputWidth = 0
  699. else:
  700. paramOutputWidthTMP = QFontMetrics(self.font()).width(parameter['name'])
  701. if paramOutputWidthTMP > paramOutputWidth:
  702. paramOutputWidth = paramOutputWidthTMP
  703. paramOutputList.append(parameter)
  704. if len(paramOutputList) == self.kParamsPerPage:
  705. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  706. paramOutputList = []
  707. paramOutputWidth = 0
  708. # for i in range(parameterCount)
  709. else:
  710. # Final page width values
  711. if 0 < len(paramInputList) < 10:
  712. paramInputListFull.append((paramInputList, paramInputWidth))
  713. if 0 < len(paramOutputList) < 10:
  714. paramOutputListFull.append((paramOutputList, paramOutputWidth))
  715. # Create parameter tabs + widgets
  716. self._createParameterWidgets(PARAMETER_INPUT, paramInputListFull, self.tr("Parameters"))
  717. self._createParameterWidgets(PARAMETER_OUTPUT, paramOutputListFull, self.tr("Outputs"))
  718. def reloadPrograms(self):
  719. # Programs
  720. self.ui.cb_programs.blockSignals(True)
  721. self.ui.cb_programs.clear()
  722. programCount = self.host.get_program_count(self.fPluginId)
  723. if programCount > 0:
  724. self.ui.cb_programs.setEnabled(True)
  725. self.ui.label_programs.setEnabled(True)
  726. for i in range(programCount):
  727. pName = self.host.get_program_name(self.fPluginId, i)
  728. #pName = pName[:40] + (pName[40:] and "...")
  729. self.ui.cb_programs.addItem(pName)
  730. self.ui.cb_programs.setCurrentIndex(self.host.get_current_program_index(self.fPluginId))
  731. else:
  732. self.ui.cb_programs.setEnabled(False)
  733. self.ui.label_programs.setEnabled(False)
  734. self.ui.cb_programs.blockSignals(False)
  735. # MIDI Programs
  736. self.ui.cb_midi_programs.blockSignals(True)
  737. self.ui.cb_midi_programs.clear()
  738. midiProgramCount = self.host.get_midi_program_count(self.fPluginId)
  739. if midiProgramCount > 0:
  740. self.ui.cb_midi_programs.setEnabled(True)
  741. self.ui.label_midi_programs.setEnabled(True)
  742. for i in range(midiProgramCount):
  743. mpData = self.host.get_midi_program_data(self.fPluginId, i)
  744. mpBank = mpData['bank']
  745. mpProg = mpData['program']
  746. mpName = mpData['name']
  747. #mpName = mpName[:40] + (mpName[40:] and "...")
  748. self.ui.cb_midi_programs.addItem("%03i:%03i - %s" % (mpBank+1, mpProg+1, mpName))
  749. self.ui.cb_midi_programs.setCurrentIndex(self.host.get_current_midi_program_index(self.fPluginId))
  750. else:
  751. self.ui.cb_midi_programs.setEnabled(False)
  752. self.ui.label_midi_programs.setEnabled(False)
  753. self.ui.cb_midi_programs.blockSignals(False)
  754. self.ui.sw_programs.setEnabled(programCount > 0 or midiProgramCount > 0)
  755. if self.fPluginInfo['type'] == PLUGIN_LV2:
  756. self.ui.b_load_state.setEnabled(programCount > 0)
  757. #------------------------------------------------------------------
  758. def clearNotes(self):
  759. self.fPlayingNotes = []
  760. self.ui.keyboard.allNotesOff()
  761. def noteOn(self, channel, note, velocity):
  762. if self.fControlChannel == channel:
  763. self.ui.keyboard.sendNoteOn(note, False)
  764. def noteOff(self, channel, note):
  765. if self.fControlChannel == channel:
  766. self.ui.keyboard.sendNoteOff(note, False)
  767. #------------------------------------------------------------------
  768. def getHints(self):
  769. return self.fPluginInfo['hints']
  770. def setPluginId(self, idx):
  771. self.fPluginId = idx
  772. def setName(self, name):
  773. self.fPluginInfo['name'] = name
  774. self.ui.label_plugin.setText("\n%s\n" % name)
  775. self.setWindowTitle(name)
  776. #------------------------------------------------------------------
  777. def setParameterValue(self, parameterId, value):
  778. for paramItem in self.fParametersToUpdate:
  779. if paramItem[0] == parameterId:
  780. paramItem[1] = value
  781. break
  782. else:
  783. self.fParametersToUpdate.append([parameterId, value])
  784. def setParameterDefault(self, parameterId, value):
  785. for paramType, paramId, paramWidget in self.fParameterList:
  786. if paramId == parameterId:
  787. paramWidget.setDefault(value)
  788. break
  789. def setParameterMidiControl(self, parameterId, control):
  790. for paramType, paramId, paramWidget in self.fParameterList:
  791. if paramId == parameterId:
  792. paramWidget.setMidiControl(control)
  793. break
  794. def setParameterMidiChannel(self, parameterId, channel):
  795. for paramType, paramId, paramWidget in self.fParameterList:
  796. if paramId == parameterId:
  797. paramWidget.setMidiChannel(channel+1)
  798. break
  799. def setProgram(self, index):
  800. self.ui.cb_programs.blockSignals(True)
  801. self.ui.cb_programs.setCurrentIndex(index)
  802. self.ui.cb_programs.blockSignals(False)
  803. self._updateParameterValues()
  804. def setMidiProgram(self, index):
  805. self.ui.cb_midi_programs.blockSignals(True)
  806. self.ui.cb_midi_programs.setCurrentIndex(index)
  807. self.ui.cb_midi_programs.blockSignals(False)
  808. self._updateParameterValues()
  809. def setOption(self, option, yesNo):
  810. if option == PLUGIN_OPTION_USE_CHUNKS:
  811. widget = self.ui.ch_use_chunks
  812. elif option == PLUGIN_OPTION_FIXED_BUFFERS:
  813. widget = self.ui.ch_fixed_buffer
  814. elif option == PLUGIN_OPTION_FORCE_STEREO:
  815. widget = self.ui.ch_force_stereo
  816. elif option == PLUGIN_OPTION_MAP_PROGRAM_CHANGES:
  817. widget = self.ui.ch_map_program_changes
  818. elif option == PLUGIN_OPTION_SEND_PROGRAM_CHANGES:
  819. widget = self.ui.ch_send_program_changes
  820. elif option == PLUGIN_OPTION_SEND_CONTROL_CHANGES:
  821. widget = self.ui.ch_send_control_changes
  822. elif option == PLUGIN_OPTION_SEND_CHANNEL_PRESSURE:
  823. widget = self.ui.ch_send_channel_pressure
  824. elif option == PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH:
  825. widget = self.ui.ch_send_note_aftertouch
  826. elif option == PLUGIN_OPTION_SEND_PITCHBEND:
  827. widget = self.ui.ch_send_pitchbend
  828. elif option == PLUGIN_OPTION_SEND_ALL_SOUND_OFF:
  829. widget = self.ui.ch_send_all_sound_off
  830. else:
  831. return
  832. widget.blockSignals(True)
  833. widget.setChecked(yesNo)
  834. widget.blockSignals(False)
  835. #------------------------------------------------------------------
  836. def setVisible(self, yesNo):
  837. if yesNo:
  838. if not self.fGeometry.isNull():
  839. self.restoreGeometry(self.fGeometry)
  840. else:
  841. self.fGeometry = self.saveGeometry()
  842. QDialog.setVisible(self, yesNo)
  843. #------------------------------------------------------------------
  844. def idleSlow(self):
  845. # Check Tab icons
  846. for i in range(len(self.fTabIconTimers)):
  847. if self.fTabIconTimers[i] == ICON_STATE_ON:
  848. self.fTabIconTimers[i] = ICON_STATE_WAIT
  849. elif self.fTabIconTimers[i] == ICON_STATE_WAIT:
  850. self.fTabIconTimers[i] = ICON_STATE_OFF
  851. elif self.fTabIconTimers[i] == ICON_STATE_OFF:
  852. self.fTabIconTimers[i] = ICON_STATE_NULL
  853. self.ui.tabWidget.setTabIcon(i+1, self.fTabIconOff)
  854. # Check parameters needing update
  855. for index, value in self.fParametersToUpdate:
  856. if index == PARAMETER_DRYWET:
  857. self.ui.dial_drywet.blockSignals(True)
  858. self.ui.dial_drywet.setValue(value)
  859. self.ui.dial_drywet.blockSignals(False)
  860. elif index == PARAMETER_VOLUME:
  861. self.ui.dial_vol.blockSignals(True)
  862. self.ui.dial_vol.setValue(value)
  863. self.ui.dial_vol.blockSignals(False)
  864. elif index == PARAMETER_BALANCE_LEFT:
  865. self.ui.dial_b_left.blockSignals(True)
  866. self.ui.dial_b_left.setValue(value)
  867. self.ui.dial_b_left.blockSignals(False)
  868. elif index == PARAMETER_BALANCE_RIGHT:
  869. self.ui.dial_b_right.blockSignals(True)
  870. self.ui.dial_b_right.setValue(value)
  871. self.ui.dial_b_right.blockSignals(False)
  872. elif index == PARAMETER_PANNING:
  873. self.ui.dial_pan.blockSignals(True)
  874. self.ui.dial_pan.setValue(value)
  875. self.ui.dial_pan.blockSignals(False)
  876. elif index == PARAMETER_CTRL_CHANNEL:
  877. self.fControlChannel = round(value)
  878. self.ui.sb_ctrl_channel.blockSignals(True)
  879. self.ui.sb_ctrl_channel.setValue(self.fControlChannel+1)
  880. self.ui.sb_ctrl_channel.blockSignals(False)
  881. self.ui.keyboard.allNotesOff()
  882. self._updateCtrlPrograms()
  883. elif index >= 0:
  884. for paramType, paramId, paramWidget in self.fParameterList:
  885. if paramId != index:
  886. continue
  887. # FIXME see below
  888. if paramType != PARAMETER_INPUT:
  889. continue
  890. paramWidget.blockSignals(True)
  891. paramWidget.setValue(value)
  892. paramWidget.blockSignals(False)
  893. #if paramType == PARAMETER_INPUT:
  894. tabIndex = paramWidget.getTabIndex()
  895. if self.fTabIconTimers[tabIndex-1] == ICON_STATE_NULL:
  896. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOn)
  897. self.fTabIconTimers[tabIndex-1] = ICON_STATE_ON
  898. break
  899. # Clear all parameters
  900. self.fParametersToUpdate = []
  901. # Update parameter outputs | FIXME needed?
  902. for paramType, paramId, paramWidget in self.fParameterList:
  903. if paramType != PARAMETER_OUTPUT:
  904. continue
  905. paramWidget.blockSignals(True)
  906. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId))
  907. paramWidget.blockSignals(False)
  908. #------------------------------------------------------------------
  909. @pyqtSlot()
  910. def slot_stateSave(self):
  911. if self.fPluginInfo['type'] == PLUGIN_LV2:
  912. # TODO
  913. return
  914. if self.fCurrentStateFilename:
  915. askTry = QMessageBox.question(self, self.tr("Overwrite?"), self.tr("Overwrite previously created file?"), QMessageBox.Ok|QMessageBox.Cancel)
  916. if askTry == QMessageBox.Ok:
  917. self.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  918. return
  919. self.fCurrentStateFilename = None
  920. fileFilter = self.tr("Carla State File (*.carxs)")
  921. filename = QFileDialog.getSaveFileName(self, self.tr("Save Plugin State File"), filter=fileFilter)
  922. if config_UseQt5:
  923. filename = filename[0]
  924. if not filename:
  925. return
  926. if not filename.lower().endswith(".carxs"):
  927. filename += ".carxs"
  928. self.fCurrentStateFilename = filename
  929. self.host.save_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  930. @pyqtSlot()
  931. def slot_stateLoad(self):
  932. if self.fPluginInfo['type'] == PLUGIN_LV2:
  933. presetList = []
  934. for i in range(self.host.get_program_count(self.fPluginId)):
  935. presetList.append("%03i - %s" % (i+1, self.host.get_program_name(self.fPluginId, i)))
  936. ret = QInputDialog.getItem(self, self.tr("Open LV2 Preset"), self.tr("Select an LV2 Preset:"), presetList, 0, False)
  937. if ret[1]:
  938. index = int(ret[0].split(" - ", 1)[0])-1
  939. self.host.set_program(self.fPluginId, index)
  940. self.setMidiProgram(-1)
  941. return
  942. fileFilter = self.tr("Carla State File (*.carxs)")
  943. filename = QFileDialog.getOpenFileName(self, self.tr("Open Plugin State File"), filter=fileFilter)
  944. if config_UseQt5:
  945. filename = filename[0]
  946. if not filename:
  947. return
  948. self.fCurrentStateFilename = filename
  949. self.host.load_plugin_state(self.fPluginId, self.fCurrentStateFilename)
  950. #------------------------------------------------------------------
  951. @pyqtSlot(bool)
  952. def slot_optionChanged(self, clicked):
  953. sender = self.sender()
  954. if sender == self.ui.ch_use_chunks:
  955. option = PLUGIN_OPTION_USE_CHUNKS
  956. elif sender == self.ui.ch_fixed_buffer:
  957. option = PLUGIN_OPTION_FIXED_BUFFERS
  958. elif sender == self.ui.ch_force_stereo:
  959. option = PLUGIN_OPTION_FORCE_STEREO
  960. elif sender == self.ui.ch_map_program_changes:
  961. option = PLUGIN_OPTION_MAP_PROGRAM_CHANGES
  962. elif sender == self.ui.ch_send_program_changes:
  963. option = PLUGIN_OPTION_SEND_PROGRAM_CHANGES
  964. elif sender == self.ui.ch_send_control_changes:
  965. option = PLUGIN_OPTION_SEND_CONTROL_CHANGES
  966. elif sender == self.ui.ch_send_channel_pressure:
  967. option = PLUGIN_OPTION_SEND_CHANNEL_PRESSURE
  968. elif sender == self.ui.ch_send_note_aftertouch:
  969. option = PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH
  970. elif sender == self.ui.ch_send_pitchbend:
  971. option = PLUGIN_OPTION_SEND_PITCHBEND
  972. elif sender == self.ui.ch_send_all_sound_off:
  973. option = PLUGIN_OPTION_SEND_ALL_SOUND_OFF
  974. else:
  975. return
  976. #--------------------------------------------------------------
  977. # handle map-program-changes and send-program-changes conflict
  978. if option == PLUGIN_OPTION_MAP_PROGRAM_CHANGES and clicked:
  979. self.ui.ch_send_program_changes.setEnabled(False)
  980. # disable send-program-changes if needed
  981. if self.ui.ch_send_program_changes.isChecked():
  982. self.host.set_option(self.fPluginId, PLUGIN_OPTION_SEND_PROGRAM_CHANGES, False)
  983. #--------------------------------------------------------------
  984. # set option
  985. self.host.set_option(self.fPluginId, option, clicked)
  986. #--------------------------------------------------------------
  987. # handle map-program-changes and send-program-changes conflict
  988. if option == PLUGIN_OPTION_MAP_PROGRAM_CHANGES and not clicked:
  989. self.ui.ch_send_program_changes.setEnabled(self.fPluginInfo['optionsAvailable'] & PLUGIN_OPTION_SEND_PROGRAM_CHANGES)
  990. # restore send-program-changes if needed
  991. if self.ui.ch_send_program_changes.isChecked():
  992. self.host.set_option(self.fPluginId, PLUGIN_OPTION_SEND_PROGRAM_CHANGES, True)
  993. #------------------------------------------------------------------
  994. @pyqtSlot(float)
  995. def slot_dryWetChanged(self, value):
  996. self.host.set_drywet(self.fPluginId, value)
  997. if self.fParent is not None:
  998. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_DRYWET, value)
  999. @pyqtSlot(float)
  1000. def slot_volumeChanged(self, value):
  1001. self.host.set_volume(self.fPluginId, value)
  1002. if self.fParent is not None:
  1003. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_VOLUME, value)
  1004. @pyqtSlot(float)
  1005. def slot_balanceLeftChanged(self, value):
  1006. self.host.set_balance_left(self.fPluginId, value)
  1007. if self.fParent is not None:
  1008. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_BALANCE_LEFT, value)
  1009. @pyqtSlot(float)
  1010. def slot_balanceRightChanged(self, value):
  1011. self.host.set_balance_right(self.fPluginId, value)
  1012. if self.fParent is not None:
  1013. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_BALANCE_RIGHT, value)
  1014. @pyqtSlot(float)
  1015. def slot_panChanged(self, value):
  1016. self.host.set_panning(self.fPluginId, value)
  1017. if self.fParent is not None:
  1018. self.fParent.editDialogParameterValueChanged(self.fPluginId, PARAMETER_PANNING, value)
  1019. @pyqtSlot(int)
  1020. def slot_ctrlChannelChanged(self, value):
  1021. self.fControlChannel = value-1
  1022. self.host.set_ctrl_channel(self.fPluginId, self.fControlChannel)
  1023. self.ui.keyboard.allNotesOff()
  1024. self._updateCtrlPrograms()
  1025. #------------------------------------------------------------------
  1026. @pyqtSlot(int, float)
  1027. def slot_parameterValueChanged(self, parameterId, value):
  1028. self.host.set_parameter_value(self.fPluginId, parameterId, value)
  1029. if self.fParent is not None:
  1030. self.fParent.editDialogParameterValueChanged(self.fPluginId, parameterId, value)
  1031. @pyqtSlot(int, int)
  1032. def slot_parameterMidiControlChanged(self, parameterId, control):
  1033. self.host.set_parameter_midi_cc(self.fPluginId, parameterId, control)
  1034. @pyqtSlot(int, int)
  1035. def slot_parameterMidiChannelChanged(self, parameterId, channel):
  1036. self.host.set_parameter_midi_channel(self.fPluginId, parameterId, channel-1)
  1037. #------------------------------------------------------------------
  1038. @pyqtSlot(int)
  1039. def slot_programIndexChanged(self, index):
  1040. self.host.set_program(self.fPluginId, index)
  1041. if self.fParent is not None:
  1042. self.fParent.editDialogProgramChanged(self.fPluginId, index)
  1043. self._updateParameterValues()
  1044. @pyqtSlot(int)
  1045. def slot_midiProgramIndexChanged(self, index):
  1046. self.host.set_midi_program(self.fPluginId, index)
  1047. if self.fParent is not None:
  1048. self.fParent.editDialogMidiProgramChanged(self.fPluginId, index)
  1049. self._updateParameterValues()
  1050. #------------------------------------------------------------------
  1051. @pyqtSlot(int)
  1052. def slot_noteOn(self, note):
  1053. if self.fControlChannel >= 0:
  1054. self.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 100)
  1055. if self.fParent is not None:
  1056. self.fParent.editDialogNotePressed(self.fPluginId, note)
  1057. @pyqtSlot(int)
  1058. def slot_noteOff(self, note):
  1059. if self.fControlChannel >= 0:
  1060. self.host.send_midi_note(self.fPluginId, self.fControlChannel, note, 0)
  1061. if self.fParent is not None:
  1062. self.fParent.editDialogNoteReleased(self.fPluginId, note)
  1063. #------------------------------------------------------------------
  1064. @pyqtSlot()
  1065. def slot_finished(self):
  1066. if self.fParent is not None:
  1067. self.fParent.editDialogVisibilityChanged(self.fPluginId, False)
  1068. #------------------------------------------------------------------
  1069. @pyqtSlot()
  1070. def slot_knobCustomMenu(self):
  1071. sender = self.sender()
  1072. knobName = sender.objectName()
  1073. if knobName == "dial_drywet":
  1074. minimum = 0.0
  1075. maximum = 1.0
  1076. default = 1.0
  1077. label = "Dry/Wet"
  1078. elif knobName == "dial_vol":
  1079. minimum = 0.0
  1080. maximum = 1.27
  1081. default = 1.0
  1082. label = "Volume"
  1083. elif knobName == "dial_b_left":
  1084. minimum = -1.0
  1085. maximum = 1.0
  1086. default = -1.0
  1087. label = "Balance-Left"
  1088. elif knobName == "dial_b_right":
  1089. minimum = -1.0
  1090. maximum = 1.0
  1091. default = 1.0
  1092. label = "Balance-Right"
  1093. elif knobName == "dial_pan":
  1094. minimum = -1.0
  1095. maximum = 1.0
  1096. default = 0.0
  1097. label = "Panning"
  1098. else:
  1099. minimum = 0.0
  1100. maximum = 1.0
  1101. default = 0.5
  1102. label = "Unknown"
  1103. menu = QMenu(self)
  1104. actReset = menu.addAction(self.tr("Reset (%i%%)" % (default*100)))
  1105. menu.addSeparator()
  1106. actMinimum = menu.addAction(self.tr("Set to Minimum (%i%%)" % (minimum*100)))
  1107. actCenter = menu.addAction(self.tr("Set to Center"))
  1108. actMaximum = menu.addAction(self.tr("Set to Maximum (%i%%)" % (maximum*100)))
  1109. menu.addSeparator()
  1110. actSet = menu.addAction(self.tr("Set value..."))
  1111. if label not in ("Balance-Left", "Balance-Right", "Panning"):
  1112. menu.removeAction(actCenter)
  1113. actSelected = menu.exec_(QCursor.pos())
  1114. if actSelected == actSet:
  1115. current = minimum + (maximum-minimum)*(float(sender.value())/10000)
  1116. value, ok = QInputDialog.getInt(self, self.tr("Set value"), label, round(current*100.0), round(minimum*100.0), round(maximum*100.0), 1)
  1117. if ok: value = float(value)/100.0
  1118. if not ok:
  1119. return
  1120. elif actSelected == actMinimum:
  1121. value = minimum
  1122. elif actSelected == actMaximum:
  1123. value = maximum
  1124. elif actSelected == actReset:
  1125. value = default
  1126. elif actSelected == actCenter:
  1127. value = 0.0
  1128. else:
  1129. return
  1130. self.sender().setValue(value)
  1131. #------------------------------------------------------------------
  1132. @pyqtSlot()
  1133. def slot_channelCustomMenu(self):
  1134. menu = QMenu(self)
  1135. actNone = menu.addAction(self.tr("None"))
  1136. if self.fControlChannel+1 == 0:
  1137. actNone.setCheckable(True)
  1138. actNone.setChecked(True)
  1139. for i in range(1, 16+1):
  1140. action = menu.addAction("%i" % i)
  1141. if self.fControlChannel+1 == i:
  1142. action.setCheckable(True)
  1143. action.setChecked(True)
  1144. actSel = menu.exec_(QCursor.pos())
  1145. if not actSel:
  1146. pass
  1147. elif actSel == actNone:
  1148. self.ui.sb_ctrl_channel.setValue(0)
  1149. elif actSel:
  1150. selChannel = int(actSel.text())
  1151. self.ui.sb_ctrl_channel.setValue(selChannel)
  1152. #------------------------------------------------------------------
  1153. def _createParameterWidgets(self, paramType, paramListFull, tabPageName):
  1154. i = 1
  1155. for paramList, width in paramListFull:
  1156. if len(paramList) == 0:
  1157. break
  1158. tabIndex = self.ui.tabWidget.count()
  1159. tabPageContainer = QWidget(self.ui.tabWidget)
  1160. tabPageLayout = QVBoxLayout(tabPageContainer)
  1161. tabPageContainer.setLayout(tabPageLayout)
  1162. for paramInfo in paramList:
  1163. paramWidget = PluginParameter(tabPageContainer, self.host, paramInfo, self.fPluginId, tabIndex)
  1164. paramWidget.setLabelWidth(width)
  1165. tabPageLayout.addWidget(paramWidget)
  1166. self.fParameterList.append((paramType, paramInfo['index'], paramWidget))
  1167. if paramType == PARAMETER_INPUT:
  1168. paramWidget.valueChanged.connect(self.slot_parameterValueChanged)
  1169. paramWidget.midiControlChanged.connect(self.slot_parameterMidiControlChanged)
  1170. paramWidget.midiChannelChanged.connect(self.slot_parameterMidiChannelChanged)
  1171. tabPageLayout.addStretch()
  1172. self.ui.tabWidget.addTab(tabPageContainer, "%s (%i)" % (tabPageName, i))
  1173. i += 1
  1174. if paramType == PARAMETER_INPUT:
  1175. self.ui.tabWidget.setTabIcon(tabIndex, self.fTabIconOff)
  1176. self.fTabIconTimers.append(ICON_STATE_NULL)
  1177. def _updateCtrlPrograms(self):
  1178. self.ui.keyboard.setEnabled(self.fControlChannel >= 0)
  1179. if self.fPluginInfo['category'] != PLUGIN_CATEGORY_SYNTH or self.fPluginInfo['type'] not in (PLUGIN_INTERNAL, PLUGIN_SF2, PLUGIN_GIG):
  1180. return
  1181. if self.fControlChannel < 0:
  1182. self.ui.cb_programs.setEnabled(False)
  1183. self.ui.cb_midi_programs.setEnabled(False)
  1184. return
  1185. self.ui.cb_programs.setEnabled(True)
  1186. self.ui.cb_midi_programs.setEnabled(True)
  1187. pIndex = self.host.get_current_program_index(self.fPluginId)
  1188. if self.ui.cb_programs.currentIndex() != pIndex:
  1189. self.setProgram(pIndex)
  1190. mpIndex = self.host.get_current_midi_program_index(self.fPluginId)
  1191. if self.ui.cb_midi_programs.currentIndex() != mpIndex:
  1192. self.setMidiProgram(mpIndex)
  1193. def _updateParameterValues(self):
  1194. for paramType, paramId, paramWidget in self.fParameterList:
  1195. paramWidget.blockSignals(True)
  1196. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId))
  1197. paramWidget.blockSignals(False)
  1198. #------------------------------------------------------------------
  1199. def testTimer(self):
  1200. self.fIdleTimerId = self.startTimer(50)
  1201. self.SIGTERM.connect(self.testTimerClose)
  1202. gCarla.gui = self
  1203. setUpSignals()
  1204. def testTimerClose(self):
  1205. self.close()
  1206. app.quit()
  1207. #------------------------------------------------------------------
  1208. def closeEvent(self, event):
  1209. if self.fIdleTimerId != 0:
  1210. self.killTimer(self.fIdleTimerId)
  1211. self.fIdleTimerId = 0
  1212. self.host.engine_close()
  1213. QDialog.closeEvent(self, event)
  1214. def timerEvent(self, event):
  1215. if event.timerId() == self.fIdleTimerId:
  1216. self.host.engine_idle()
  1217. self.idleSlow()
  1218. QDialog.timerEvent(self, event)
  1219. def done(self, r):
  1220. QDialog.done(self, r)
  1221. self.close()
  1222. # ------------------------------------------------------------------------------------------------------------
  1223. # Main
  1224. if __name__ == '__main__':
  1225. from carla_app import CarlaApplication
  1226. from carla_host import initHost, loadHostSettings
  1227. app = CarlaApplication()
  1228. host = initHost("Widgets", None, False, False, False)
  1229. loadHostSettings(host)
  1230. host.engine_init("JACK", "Carla-Widgets")
  1231. host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0)
  1232. host.set_active(0, True)
  1233. gui1 = CarlaAboutW(None, host)
  1234. gui1.show()
  1235. gui2 = PluginEdit(None, host, 0)
  1236. gui2.testTimer()
  1237. gui2.show()
  1238. app.exit_exec()