Bitcrush.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Bitcrush.h - A native bitcrusher
  3. *
  4. * Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
  5. * Copyright (c) 2006-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 BITCRUSH_H
  26. #define BITCRUSH_H
  27. #include "Effect.h"
  28. #include "BitcrushControls.h"
  29. #include "ValueBuffer.h"
  30. #include "lmms_math.h"
  31. #include "BasicFilters.h"
  32. class BitcrushEffect : public Effect
  33. {
  34. public:
  35. BitcrushEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key );
  36. virtual ~BitcrushEffect();
  37. virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames );
  38. virtual EffectControls* controls()
  39. {
  40. return &m_controls;
  41. }
  42. private:
  43. void sampleRateChanged();
  44. float depthCrush( float in );
  45. float noise( float amt );
  46. BitcrushControls m_controls;
  47. sampleFrame * m_buffer;
  48. float m_sampleRate;
  49. StereoLinkwitzRiley m_filter;
  50. float m_bitCounterL;
  51. float m_rateCoeffL;
  52. float m_bitCounterR;
  53. float m_rateCoeffR;
  54. bool m_rateEnabled;
  55. float m_left;
  56. float m_right;
  57. int m_levels;
  58. float m_levelsRatio;
  59. bool m_depthEnabled;
  60. float m_inGain;
  61. float m_outGain;
  62. float m_outClip;
  63. bool m_needsUpdate;
  64. int m_silenceCounter;
  65. friend class BitcrushControls;
  66. };
  67. #endif