FlangerControls.cpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_lfoPhaseModel( 90.0, 0.0, 360.0, 0.0001, this, tr( "Stereo phase" ) ),
  36. m_feedbackModel( 0.0, -1.0, 1.0, 0.0001, this, tr( "Regen" ) ),
  37. m_whiteNoiseAmountModel( 0.0, 0.0, 0.05, 0.0001, this, tr( "Noise" ) ),
  38. m_invertFeedbackModel ( false, this, tr( "Invert" ) )
  39. {
  40. connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( changedSampleRate() ) );
  41. connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( changedPlaybackState() ) );
  42. }
  43. void FlangerControls::loadSettings( const QDomElement &_this )
  44. {
  45. m_delayTimeModel.loadSettings( _this, "DelayTimeSamples" );
  46. m_lfoFrequencyModel.loadSettings( _this, "LfoFrequency" );
  47. m_lfoAmountModel.loadSettings( _this, "LfoAmount" );
  48. m_lfoPhaseModel.loadSettings( _this, "LfoPhase" );
  49. m_feedbackModel.loadSettings( _this, "Feedback" );
  50. m_whiteNoiseAmountModel.loadSettings( _this, "WhiteNoise" );
  51. m_invertFeedbackModel.loadSettings( _this, "Invert" );
  52. }
  53. void FlangerControls::saveSettings( QDomDocument &doc, QDomElement &parent )
  54. {
  55. m_delayTimeModel.saveSettings( doc , parent, "DelayTimeSamples" );
  56. m_lfoFrequencyModel.saveSettings( doc, parent , "LfoFrequency" );
  57. m_lfoAmountModel.saveSettings( doc, parent , "LfoAmount" );
  58. m_lfoPhaseModel.saveSettings( doc, parent , "LfoPhase" );
  59. m_feedbackModel.saveSettings( doc, parent, "Feedback" ) ;
  60. m_whiteNoiseAmountModel.saveSettings( doc, parent , "WhiteNoise" ) ;
  61. m_invertFeedbackModel.saveSettings( doc, parent, "Invert" );
  62. }
  63. void FlangerControls::changedSampleRate()
  64. {
  65. m_effect->changeSampleRate();
  66. }
  67. void FlangerControls::changedPlaybackState()
  68. {
  69. m_effect->restartLFO();
  70. }