DelayControls.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * delaycontrols.cpp - definition of DelayControls 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 "DelayControls.h"
  26. #include "DelayEffect.h"
  27. #include "Engine.h"
  28. #include "Song.h"
  29. DelayControls::DelayControls( DelayEffect* effect ):
  30. EffectControls( effect ),
  31. m_effect ( effect ),
  32. m_delayTimeModel( 0.5, 0.01, 5.0, 0.0001, 5000.0, this, tr( "Delay samples" )) ,
  33. m_feedbackModel(0.0f,0.0f,1.0f,0.01f,this,tr( "Feedback" ) ),
  34. m_lfoTimeModel(2.0, 0.01, 5.0, 0.0001, 20000.0, this, tr( "LFO frequency" ) ),
  35. m_lfoAmountModel(0.0, 0.0, 0.5, 0.0001, 2000.0, this, tr ( "LFO amount" ) ),
  36. m_outGainModel( 0.0, -60.0, 20.0, 0.01, this, tr( "Output gain" ) )
  37. {
  38. connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) );
  39. m_outPeakL = 0.0;
  40. m_outPeakR = 0.0;
  41. }
  42. void DelayControls::loadSettings( const QDomElement &_this )
  43. {
  44. m_delayTimeModel.loadSettings(_this, "DelayTimeSamples" );
  45. m_feedbackModel.loadSettings( _this, "FeebackAmount" );
  46. m_lfoTimeModel.loadSettings( _this , "LfoFrequency");
  47. m_lfoAmountModel.loadSettings( _this, "LfoAmount");
  48. m_outGainModel.loadSettings( _this, "OutGain" );
  49. }
  50. void DelayControls::saveSettings( QDomDocument& doc, QDomElement& _this )
  51. {
  52. m_delayTimeModel.saveSettings( doc, _this, "DelayTimeSamples" );
  53. m_feedbackModel.saveSettings( doc, _this ,"FeebackAmount" );
  54. m_lfoTimeModel.saveSettings( doc, _this, "LfoFrequency" );
  55. m_lfoAmountModel.saveSettings( doc, _this ,"LfoAmount" );
  56. m_outGainModel.saveSettings( doc, _this, "OutGain" );
  57. }
  58. void DelayControls::changeSampleRate()
  59. {
  60. m_effect->changeSampleRate();
  61. }