|
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
-
- # DISTRHO BigMeter Plugin
- # Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License as
- # published by the Free Software Foundation; either version 2 of
- # the License, or any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # For a full copy of the GNU General Public License see the GPL.txt file
-
- # ------------------------------------------------------------------------------------------------------------
- # Imports (Global)
-
- from numpy import rint
- from sys import argv, exit
-
- try:
- from PyQt5.QtWidgets import QApplication
- except:
- from PyQt4.QtGui import QApplication
-
- # -----------------------------------------------------------------------
- # Imports (ExternalUI)
-
- from externalui import ExternalUI
- from digitalpeakmeter import DigitalPeakMeter
-
- # -----------------------------------------------------------------------
- # External UI
-
- class DistrhoUIBigMeter(DigitalPeakMeter, ExternalUI):
- def __init__(self):
- DigitalPeakMeter.__init__(self, None)
- ExternalUI.__init__(self)
-
- channels = 6 if argv[0].endswith("bigmeterM-ui") else 2
-
- self.setChannels(channels)
- self.setColor(self.GREEN)
- self.setOrientation(self.VERTICAL)
-
- #self.setSmoothRelease(0) # till 5
-
- self.resize(30, 400)
- self.setWindowTitle(self.fUiName)
-
- self.fIdleTimer = self.startTimer(30)
-
- self.showUiIfTesting()
-
- # -------------------------------------------------------------------
- # DSP Callbacks
-
- def d_parameterChanged(self, index, value):
- if index == 0:
- color = rint(value)+1
-
- if not color in (self.GREEN, self.BLUE):
- return
-
- self.setColor(color)
-
- else:
- self.displayMeter(index, value)
-
- # -------------------------------------------------------------------
- # ExternalUI Callbacks
-
- def d_uiShow(self):
- self.show()
-
- def d_uiHide(self):
- self.hide()
-
- def d_uiQuit(self):
- self.close()
- app.quit()
-
- def d_uiTitleChanged(self, uiTitle):
- self.setWindowTitle(uiTitle)
-
- # -------------------------------------------------------------------
- # Qt events
-
- def timerEvent(self, event):
- if event.timerId() == self.fIdleTimer and not self.idleExternalUI():
- self.d_uiQuit()
-
- DigitalPeakMeter.timerEvent(self, event)
-
- def closeEvent(self, event):
- self.closeExternalUI()
- DigitalPeakMeter.closeEvent(self, event)
-
- #--------------- main ------------------
- if __name__ == '__main__':
- app = QApplication(argv)
- #app...
- gui = DistrhoUIBigMeter()
- exit(app.exec_())
|