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.

139 lines
3.9KB

  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 (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import Qt
  24. else:
  25. from PyQt4.QtCore import Qt
  26. # -----------------------------------------------------------------------
  27. # Imports (Custom)
  28. from carla_shared import *
  29. from carla_utils import *
  30. # -----------------------------------------------------------------------
  31. # Imports (ExternalUI)
  32. from carla_app import CarlaApplication
  33. from externalui import ExternalUI
  34. from digitalpeakmeter import DigitalPeakMeter
  35. # -----------------------------------------------------------------------
  36. # External UI
  37. class DistrhoUIBigMeter(ExternalUI, DigitalPeakMeter):
  38. def __init__(self):
  39. ExternalUI.__init__(self)
  40. DigitalPeakMeter.__init__(self, None)
  41. channels = 2 #6 if argv[0].endswith("bigmeterM-ui") else 2
  42. self.setChannels(channels)
  43. self.setColor(self.GREEN)
  44. self.setOrientation(self.VERTICAL)
  45. #self.setSmoothRelease(0) # till 5
  46. self.resize(50, 400)
  47. self.setWindowTitle(self.fUiName)
  48. self.fIdleTimer = self.startTimer(30)
  49. self.ready()
  50. # -------------------------------------------------------------------
  51. # DSP Callbacks
  52. def dspParameterChanged(self, index, value):
  53. if index == 0:
  54. color = int(value)
  55. if color not in (DigitalPeakMeter.GREEN, DigitalPeakMeter.BLUE):
  56. return
  57. self.setColor(color)
  58. elif index == 1:
  59. style = int(value)
  60. if style not in (DigitalPeakMeter.STYLE_DEFAULT, DigitalPeakMeter.STYLE_OPENAV):
  61. return
  62. self.setMeterStyle(style)
  63. else:
  64. self.displayMeter(index-1, value)
  65. # -------------------------------------------------------------------
  66. # ExternalUI Callbacks
  67. def uiShow(self):
  68. self.show()
  69. def uiFocus(self):
  70. self.setWindowState((self.windowState() & ~Qt.WindowMinimized) | Qt.WindowActive)
  71. self.show()
  72. self.raise_()
  73. self.activateWindow()
  74. def uiHide(self):
  75. self.hide()
  76. def uiQuit(self):
  77. self.closeExternalUI()
  78. self.close()
  79. app.quit()
  80. def uiTitleChanged(self, uiTitle):
  81. self.setWindowTitle(uiTitle)
  82. # -------------------------------------------------------------------
  83. # Qt events
  84. def timerEvent(self, event):
  85. if event.timerId() == self.fIdleTimer:
  86. self.idleExternalUI()
  87. DigitalPeakMeter.timerEvent(self, event)
  88. def closeEvent(self, event):
  89. self.closeExternalUI()
  90. DigitalPeakMeter.closeEvent(self, event)
  91. #--------------- main ------------------
  92. if __name__ == '__main__':
  93. import resources_rc
  94. pathBinaries, pathResources = getPaths()
  95. gCarla.utils = CarlaUtils(os.path.join(pathBinaries, "libcarla_utils." + DLL_EXTENSION))
  96. gCarla.utils.set_process_name("BigMeter")
  97. #gCarla.utils.set_locale_C()
  98. app = CarlaApplication("BigMeter")
  99. gui = DistrhoUIBigMeter()
  100. app.exit_exec()