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.

106 lines
3.0KB

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