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.

109 lines
3.0KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # DISTRHO BigMeter Plugin
  4. # Copyright (C) 2013 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 GPL.txt file
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from numpy import rint
  20. from sys import argv, exit
  21. try:
  22. from PyQt5.QtWidgets import QApplication
  23. except:
  24. from PyQt4.QtGui import QApplication
  25. # -----------------------------------------------------------------------
  26. # Imports (ExternalUI)
  27. from externalui import ExternalUI
  28. from digitalpeakmeter import DigitalPeakMeter
  29. # -----------------------------------------------------------------------
  30. # External UI
  31. class DistrhoUIBigMeter(DigitalPeakMeter, ExternalUI):
  32. def __init__(self):
  33. DigitalPeakMeter.__init__(self, None)
  34. ExternalUI.__init__(self)
  35. channels = 6 if argv[0].endswith("bigmeterM-ui") else 2
  36. self.setChannels(channels)
  37. self.setColor(self.GREEN)
  38. self.setOrientation(self.VERTICAL)
  39. #self.setSmoothRelease(0) # till 5
  40. self.resize(30, 400)
  41. self.setWindowTitle(self.fUiName)
  42. self.fIdleTimer = self.startTimer(30)
  43. self.showUiIfTesting()
  44. # -------------------------------------------------------------------
  45. # DSP Callbacks
  46. def d_parameterChanged(self, index, value):
  47. if index == 0:
  48. color = rint(value)+1
  49. if not color in (self.GREEN, self.BLUE):
  50. return
  51. self.setColor(color)
  52. else:
  53. self.displayMeter(index, value)
  54. # -------------------------------------------------------------------
  55. # ExternalUI Callbacks
  56. def d_uiShow(self):
  57. self.show()
  58. def d_uiHide(self):
  59. self.hide()
  60. def d_uiQuit(self):
  61. self.close()
  62. app.quit()
  63. def d_uiTitleChanged(self, uiTitle):
  64. self.setWindowTitle(uiTitle)
  65. # -------------------------------------------------------------------
  66. # Qt events
  67. def timerEvent(self, event):
  68. if event.timerId() == self.fIdleTimer and not self.idleExternalUI():
  69. self.d_uiQuit()
  70. DigitalPeakMeter.timerEvent(self, event)
  71. def closeEvent(self, event):
  72. self.closeExternalUI()
  73. DigitalPeakMeter.closeEvent(self, event)
  74. #--------------- main ------------------
  75. if __name__ == '__main__':
  76. app = QApplication(argv)
  77. #app...
  78. gui = DistrhoUIBigMeter()
  79. exit(app.exec_())