FlangerControls.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * flangercontrols.cpp - defination of FlangerControls class.
  3. *
  4. * Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #include <QtXml/QDomElement>
  25. #include "FlangerControls.h"
  26. #include "FlangerEffect.h"
  27. #include "Engine.h"
  28. #include "Song.h"
  29. FlangerControls::FlangerControls( FlangerEffect *effect ) :
  30. EffectControls ( effect ),
  31. m_effect ( effect ),
  32. m_delayTimeModel(0.001, 0.0001, 0.050, 0.0001, this, tr( "Delay samples" ) ) ,
  33. m_lfoFrequencyModel( 0.25, 0.01, 60, 0.0001, 60000.0 ,this, tr( "LFO frequency" ) ),
  34. m_lfoAmountModel( 0.0, 0.0, 0.0025 , 0.0001 , this , tr( "Seconds" ) ),
  35. m_feedbackModel( 0.0 , 0.0 , 1.0 , 0.0001, this, tr( "Regen" ) ),
  36. m_whiteNoiseAmountModel( 0.0 , 0.0 , 0.05 , 0.0001, this, tr( "Noise" ) ),
  37. m_invertFeedbackModel ( false , this, tr( "Invert" ) )
  38. {
  39. connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changedSampleRate() ) );
  40. connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( changedPlaybackState() ) );
  41. }
  42. void FlangerControls::loadSettings( const QDomElement &_this )
  43. {
  44. m_delayTimeModel.loadSettings( _this, "DelayTimeSamples" );
  45. m_lfoFrequencyModel.loadSettings( _this, "LfoFrequency" );
  46. m_lfoAmountModel.loadSettings( _this, "LfoAmount" );
  47. m_feedbackModel.loadSettings( _this, "Feedback" );
  48. m_whiteNoiseAmountModel.loadSettings( _this, "WhiteNoise" );
  49. m_invertFeedbackModel.loadSettings( _this, "Invert" );
  50. }
  51. void FlangerControls::saveSettings( QDomDocument &doc, QDomElement &parent )
  52. {
  53. m_delayTimeModel.saveSettings( doc , parent, "DelayTimeSamples" );
  54. m_lfoFrequencyModel.saveSettings( doc, parent , "LfoFrequency" );
  55. m_lfoAmountModel.saveSettings( doc, parent , "LfoAmount" );
  56. m_feedbackModel.saveSettings( doc, parent, "Feedback" ) ;
  57. m_whiteNoiseAmountModel.saveSettings( doc, parent , "WhiteNoise" ) ;
  58. m_invertFeedbackModel.saveSettings( doc, parent, "Invert" );
  59. }
  60. void FlangerControls::changedSampleRate()
  61. {
  62. m_effect->changeSampleRate();
  63. }
  64. void FlangerControls::changedPlaybackState()
  65. {
  66. m_effect->restartLFO();
  67. }