EqFader.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* eqfader.h - defination of EqFader class.
  2. *
  3. * Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
  4. *
  5. * This file is part of LMMS - https://lmms.io
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with this program (see COPYING); if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. * Boston, MA 02110-1301 USA.
  21. *
  22. */
  23. #ifndef EQFADER_H
  24. #define EQFADER_H
  25. #include <QList>
  26. #include <QWidget>
  27. #include "EffectControls.h"
  28. #include "Fader.h"
  29. #include "GuiApplication.h"
  30. #include "MainWindow.h"
  31. #include "TextFloat.h"
  32. class EqFader : public Fader
  33. {
  34. public:
  35. Q_OBJECT
  36. public:
  37. EqFader( FloatModel * model, const QString & name, QWidget * parent, QPixmap * backg, QPixmap * leds, QPixmap * knobpi, float* lPeak, float* rPeak ) :
  38. Fader( model, name, parent, backg, leds, knobpi )
  39. {
  40. setMinimumSize( 23, 80 );
  41. setMaximumSize( 23, 80 );
  42. resize( 23, 80 );
  43. m_lPeak = lPeak;
  44. m_rPeak = rPeak;
  45. connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateVuMeters() ) );
  46. m_model = model;
  47. setPeak_L( 0 );
  48. setPeak_R( 0 );
  49. }
  50. EqFader( FloatModel * model, const QString & name, QWidget * parent, float* lPeak, float* rPeak ) :
  51. Fader( model, name, parent )
  52. {
  53. setMinimumSize( 23, 116 );
  54. setMaximumSize( 23, 116 );
  55. resize( 23, 116 );
  56. m_lPeak = lPeak;
  57. m_rPeak = rPeak;
  58. connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateVuMeters() ) );
  59. m_model = model;
  60. setPeak_L( 0 );
  61. setPeak_R( 0 );
  62. }
  63. ~EqFader()
  64. {
  65. }
  66. private slots:
  67. void updateVuMeters()
  68. {
  69. const float opl = getPeak_L();
  70. const float opr = getPeak_R();
  71. const float fallOff = 1.07;
  72. if( *m_lPeak > opl )
  73. {
  74. setPeak_L( *m_lPeak );
  75. *m_lPeak = 0;
  76. }
  77. else
  78. {
  79. setPeak_L( opl/fallOff );
  80. }
  81. if( *m_rPeak > opr )
  82. {
  83. setPeak_R( *m_rPeak );
  84. *m_rPeak = 0;
  85. }
  86. else
  87. {
  88. setPeak_R( opr/fallOff );
  89. }
  90. update();
  91. }
  92. private:
  93. float* m_lPeak;
  94. float* m_rPeak;
  95. FloatModel* m_model;
  96. };
  97. #endif // EQFADER_H