MultitapEcho.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * MultitapEcho.h - a multitap echo delay plugin
  3. *
  4. * Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
  5. * Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  6. *
  7. * This file is part of LMMS - https://lmms.io
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public
  20. * License along with this program (see COPYING); if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef MULTITAP_ECHO_H
  26. #define MULTITAP_ECHO_H
  27. #include "Effect.h"
  28. #include "MultitapEchoControls.h"
  29. #include "ValueBuffer.h"
  30. #include "RingBuffer.h"
  31. #include "lmms_math.h"
  32. #include "BasicFilters.h"
  33. class MultitapEchoEffect : public Effect
  34. {
  35. public:
  36. MultitapEchoEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key );
  37. virtual ~MultitapEchoEffect();
  38. virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames );
  39. virtual EffectControls* controls()
  40. {
  41. return &m_controls;
  42. }
  43. private:
  44. void updateFilters( int begin, int end );
  45. void runFilter( sampleFrame * dst, sampleFrame * src, StereoOnePole & filter, const fpp_t frames );
  46. inline void setFilterFreq( float fc, StereoOnePole & f )
  47. {
  48. const float b1 = expf( -2.0f * F_PI * fc );
  49. f.setCoeffs( 1.0f - b1, b1 );
  50. }
  51. int m_stages;
  52. MultitapEchoControls m_controls;
  53. float m_amp [32];
  54. float m_lpFreq [32];
  55. RingBuffer m_buffer;
  56. StereoOnePole m_filter [32][4];
  57. float m_sampleRate;
  58. float m_sampleRatio;
  59. sampleFrame * m_work;
  60. friend class MultitapEchoControls;
  61. };
  62. #endif