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 63KB

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