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

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