BitcrushControls.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * BitcrushControls.cpp - 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. #include <QDomElement>
  26. #include "BitcrushControls.h"
  27. #include "Bitcrush.h"
  28. #include "lmms_math.h"
  29. BitcrushControls::BitcrushControls( BitcrushEffect * eff ) :
  30. EffectControls( eff ),
  31. m_effect( eff ),
  32. m_inGain( 0.0f, -20.0f, 20.0f, 0.1f, this, tr( "Input gain" ) ),
  33. m_inNoise( 0.0f, 0.0f, 100.0f, 0.1f, this, tr( "Input noise" ) ),
  34. m_outGain( 0.0f, -20.0f, 20.0f, 0.1f, this, tr( "Output gain" ) ),
  35. m_outClip( 0.0f, -20.0f, 20.0f, 0.1f, this, tr( "Output clip" ) ),
  36. m_rate( 44100.f, 20.f, 44100.f, 1.0f, this, tr( "Sample rate" ) ),
  37. m_stereoDiff( 0.f, 0.f, 50.f, 0.1f, this, tr( "Stereo difference" ) ),
  38. m_levels( 256.f, 1.f, 256.f, 0.01f, this, tr( "Levels" ) ),
  39. m_rateEnabled( true, this, tr( "Rate enabled" ) ),
  40. m_depthEnabled( true, this, tr( "Depth enabled" ) )
  41. {
  42. m_rate.setStrictStepSize( true );
  43. m_levels.setStrictStepSize( true );
  44. connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) );
  45. }
  46. BitcrushControls::~BitcrushControls()
  47. {
  48. }
  49. void BitcrushControls::saveSettings( QDomDocument & doc, QDomElement & elem )
  50. {
  51. m_inGain.saveSettings( doc, elem, "ingain" );
  52. m_inNoise.saveSettings( doc, elem, "innoise" );
  53. m_outGain.saveSettings( doc, elem, "outgain" );
  54. m_outClip.saveSettings( doc, elem, "outclip" );
  55. m_rate.saveSettings( doc, elem, "rate" );
  56. m_stereoDiff.saveSettings( doc, elem, "stereodiff" );
  57. m_levels.saveSettings( doc, elem, "levels" );
  58. m_rateEnabled.saveSettings( doc, elem, "rateon" );
  59. m_depthEnabled.saveSettings( doc, elem, "depthon" );
  60. }
  61. void BitcrushControls::loadSettings( const QDomElement & elem )
  62. {
  63. m_inGain.loadSettings( elem, "ingain" );
  64. m_inNoise.loadSettings( elem, "innoise" );
  65. m_outGain.loadSettings( elem, "outgain" );
  66. m_outClip.loadSettings( elem, "outclip" );
  67. m_rate.loadSettings( elem, "rate" );
  68. m_stereoDiff.loadSettings( elem, "stereodiff" );
  69. m_levels.loadSettings( elem, "levels" );
  70. m_rateEnabled.loadSettings( elem, "rateon" );
  71. m_depthEnabled.loadSettings( elem, "depthon" );
  72. m_effect->m_needsUpdate = true;
  73. }
  74. void BitcrushControls::sampleRateChanged()
  75. {
  76. m_effect->sampleRateChanged();
  77. }