EqEffect.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* eqeffect.h - defination of EqEffect 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 EQEFFECT_H
  24. #define EQEFFECT_H
  25. #include "BasicFilters.h"
  26. #include "Effect.h"
  27. #include "EqControls.h"
  28. #include "EqFilter.h"
  29. #include "lmms_math.h"
  30. class EqEffect : public Effect
  31. {
  32. public:
  33. EqEffect( Model * parent , const Descriptor::SubPluginFeatures::Key * key );
  34. virtual ~EqEffect();
  35. virtual bool processAudioBuffer( sampleFrame * buf, const fpp_t frames );
  36. virtual EffectControls * controls()
  37. {
  38. return &m_eqControls;
  39. }
  40. inline void gain( sampleFrame * buf, const fpp_t frames, float scale, sampleFrame * peak )
  41. {
  42. peak[0][0] = 0.0f; peak[0][1] = 0.0f;
  43. for( fpp_t f = 0; f < frames; ++f )
  44. {
  45. buf[f][0] *= scale;
  46. buf[f][1] *= scale;
  47. if( fabs( buf[f][0] ) > peak[0][0] )
  48. {
  49. peak[0][0] = fabs( buf[f][0] );
  50. }
  51. if( fabs( buf[f][1] ) > peak[0][1] )
  52. {
  53. peak[0][1] = fabs( buf[f][0] );
  54. }
  55. }
  56. }
  57. private:
  58. EqControls m_eqControls;
  59. EqHp12Filter m_hp12;
  60. EqHp12Filter m_hp24;
  61. EqHp12Filter m_hp480;
  62. EqHp12Filter m_hp481;
  63. EqLowShelfFilter m_lowShelf;
  64. EqPeakFilter m_para1;
  65. EqPeakFilter m_para2;
  66. EqPeakFilter m_para3;
  67. EqPeakFilter m_para4;
  68. EqHighShelfFilter m_highShelf;
  69. EqLp12Filter m_lp12;
  70. EqLp12Filter m_lp24;
  71. EqLp12Filter m_lp480;
  72. EqLp12Filter m_lp481;
  73. float m_inGain;
  74. float m_outGain;
  75. float peakBand( float minF, float maxF, EqAnalyser *, int );
  76. inline float bandToFreq ( int index , int sampleRate )
  77. {
  78. return index * sampleRate / ( MAX_BANDS * 2 );
  79. }
  80. void setBandPeaks( EqAnalyser * fft , int );
  81. };
  82. #endif // EQEFFECT_H