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.

bigmeter-ui 3.9KB

10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla Native Plugins
  4. # Copyright (C) 2012-2019 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 (Global)
  19. from PyQt5.QtCore import Qt
  20. # -----------------------------------------------------------------------
  21. # Imports (Custom)
  22. from carla_shared import *
  23. from carla_utils import *
  24. # -----------------------------------------------------------------------
  25. # Imports (ExternalUI)
  26. from carla_app import CarlaApplication
  27. from externalui import ExternalUI
  28. from widgets.digitalpeakmeter import DigitalPeakMeter
  29. # -----------------------------------------------------------------------
  30. # External UI
  31. class DistrhoUIBigMeter(ExternalUI, DigitalPeakMeter):
  32. def __init__(self):
  33. ExternalUI.__init__(self)
  34. DigitalPeakMeter.__init__(self, None)
  35. channels = 2 #6 if argv[0].endswith("bigmeterM-ui") else 2
  36. self.setChannelCount(channels)
  37. self.setMeterColor(self.COLOR_GREEN)
  38. self.setMeterOrientation(self.VERTICAL)
  39. #self.setSmoothRelease(0) # till 5
  40. self.resize(50, 400)
  41. self.setWindowTitle(self.fUiName)
  42. self.fIdleTimer = self.startTimer(30)
  43. self.ready()
  44. # -------------------------------------------------------------------
  45. # DSP Callbacks
  46. def dspParameterChanged(self, index, value):
  47. if index == 0:
  48. color = int(value)
  49. if color not in (DigitalPeakMeter.COLOR_GREEN,
  50. DigitalPeakMeter.COLOR_BLUE):
  51. return
  52. self.setMeterColor(color)
  53. elif index == 1:
  54. style = int(value)
  55. if style not in (DigitalPeakMeter.STYLE_DEFAULT,
  56. DigitalPeakMeter.STYLE_OPENAV,
  57. DigitalPeakMeter.STYLE_RNCBC):
  58. return
  59. self.setMeterStyle(style)
  60. else:
  61. self.displayMeter(index-1, value)
  62. # -------------------------------------------------------------------
  63. # ExternalUI Callbacks
  64. def uiShow(self):
  65. self.show()
  66. def uiFocus(self):
  67. self.setWindowState((self.windowState() & ~Qt.WindowMinimized) | Qt.WindowActive)
  68. self.show()
  69. self.raise_()
  70. self.activateWindow()
  71. def uiHide(self):
  72. self.hide()
  73. def uiQuit(self):
  74. self.closeExternalUI()
  75. self.close()
  76. app.quit()
  77. def uiTitleChanged(self, uiTitle):
  78. self.setWindowTitle(uiTitle)
  79. # -------------------------------------------------------------------
  80. # Qt events
  81. def timerEvent(self, event):
  82. if event.timerId() == self.fIdleTimer:
  83. self.idleExternalUI()
  84. DigitalPeakMeter.timerEvent(self, event)
  85. def closeEvent(self, event):
  86. self.closeExternalUI()
  87. DigitalPeakMeter.closeEvent(self, event)
  88. # there might be other qt windows open which will block the UI from quitting
  89. app.quit()
  90. #--------------- main ------------------
  91. if __name__ == '__main__':
  92. import resources_rc
  93. pathBinaries, pathResources = getPaths()
  94. gCarla.utils = CarlaUtils(os.path.join(pathBinaries, "libcarla_utils." + DLL_EXTENSION))
  95. gCarla.utils.set_process_name("BigMeter")
  96. app = CarlaApplication("BigMeter")
  97. gui = DistrhoUIBigMeter()
  98. app.exit_exec()