peak_controller_effect_controls.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * peak_controller_effect_controls.cpp - controls for peakController effect
  3. *
  4. * Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
  5. * Copyright (c) 2009-2011 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 "PeakController.h"
  27. #include "peak_controller_effect_controls.h"
  28. #include "peak_controller_effect.h"
  29. #include "Song.h"
  30. PeakControllerEffectControls::
  31. PeakControllerEffectControls( PeakControllerEffect * _eff ) :
  32. EffectControls( _eff ),
  33. m_effect( _eff ),
  34. m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ),
  35. m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Modulation amount" ) ),
  36. m_attackModel( 0, 0, 0.999, 0.001, this, tr( "Attack" ) ),
  37. m_decayModel( 0, 0, 0.999, 0.001, this, tr( "Release" ) ),
  38. m_tresholdModel( 0, 0, 1.0, 0.001, this, tr( "Treshold" ) ),
  39. m_muteModel( false, this, tr( "Mute output" ) ),
  40. m_absModel( true, this, tr("Absolute value") ),
  41. m_amountMultModel( 1.0, 0, 32, 0.2, this, tr("Amount multiplicator") )
  42. {
  43. }
  44. void PeakControllerEffectControls::loadSettings( const QDomElement & _this )
  45. {
  46. m_baseModel.loadSettings( _this, "base" );
  47. m_effect->m_lastSample = m_baseModel.value(); //Set initial Peak Controller output to Base
  48. m_amountModel.loadSettings( _this, "amount" );
  49. m_muteModel.loadSettings( _this, "mute" );
  50. m_attackModel.loadSettings( _this, "attack" );
  51. m_decayModel.loadSettings( _this, "decay" );
  52. m_absModel.loadSettings( _this, "abs" );
  53. m_amountMultModel.loadSettings( _this, "amountmult" );
  54. m_tresholdModel.loadSettings( _this, "treshold" );
  55. /*If the peak controller effect is NOT loaded from project,
  56. * m_effectId stored is useless.
  57. * Reason to assign a random number to it:
  58. * If the user clone the instrument, and m_effectId is cloned, and
  59. * m_effectId is copied, then there would be two instruments
  60. * having the same id.
  61. */
  62. if( Engine::getSong()->isLoadingProject() == true )
  63. {
  64. m_effect->m_effectId = _this.attribute( "effectId" ).toInt();
  65. }
  66. else
  67. {
  68. // TODO: Fix possible collision
  69. m_effect->m_effectId = rand();
  70. }
  71. }
  72. void PeakControllerEffectControls::saveSettings( QDomDocument & _doc,
  73. QDomElement & _this )
  74. {
  75. _this.setAttribute( "effectId", m_effect->m_effectId );
  76. m_baseModel.saveSettings( _doc, _this, "base" );
  77. m_amountModel.saveSettings( _doc, _this, "amount" );
  78. m_muteModel.saveSettings( _doc, _this, "mute" );
  79. m_attackModel.saveSettings( _doc, _this, "attack" );
  80. m_decayModel.saveSettings( _doc, _this, "decay" );
  81. m_absModel.saveSettings( _doc, _this, "abs" );
  82. m_amountMultModel.saveSettings( _doc, _this, "amountmult" );
  83. m_tresholdModel.saveSettings( _doc, _this, "treshold" );
  84. }