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