peak_controller_effect_controls.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 "PresetPreviewPlayHandle.h"
  30. #include "Song.h"
  31. PeakControllerEffectControls::
  32. PeakControllerEffectControls( PeakControllerEffect * _eff ) :
  33. EffectControls( _eff ),
  34. m_effect( _eff ),
  35. m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ),
  36. m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Modulation amount" ) ),
  37. m_attackModel( 0, 0, 0.999, 0.001, this, tr( "Attack" ) ),
  38. m_decayModel( 0, 0, 0.999, 0.001, this, tr( "Release" ) ),
  39. m_tresholdModel( 0, 0, 1.0, 0.001, this, tr( "Treshold" ) ),
  40. m_muteModel( false, this, tr( "Mute output" ) ),
  41. m_absModel( true, this, tr("Abs Value") ),
  42. m_amountMultModel( 1.0, 0, 32, 0.2, this, tr("Amount Multiplicator") )
  43. {
  44. }
  45. void PeakControllerEffectControls::loadSettings( const QDomElement & _this )
  46. {
  47. m_baseModel.loadSettings( _this, "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. m_effect->m_effectId = rand();
  69. }
  70. if( m_effect->m_autoController && PresetPreviewPlayHandle::isPreviewing() == true )
  71. {
  72. delete m_effect->m_autoController;
  73. m_effect->m_autoController = 0;
  74. }
  75. }
  76. void PeakControllerEffectControls::saveSettings( QDomDocument & _doc,
  77. QDomElement & _this )
  78. {
  79. _this.setAttribute( "effectId", m_effect->m_effectId );
  80. m_baseModel.saveSettings( _doc, _this, "base" );
  81. m_amountModel.saveSettings( _doc, _this, "amount" );
  82. m_muteModel.saveSettings( _doc, _this, "mute" );
  83. m_attackModel.saveSettings( _doc, _this, "attack" );
  84. m_decayModel.saveSettings( _doc, _this, "decay" );
  85. m_absModel.saveSettings( _doc, _this, "abs" );
  86. m_amountMultModel.saveSettings( _doc, _this, "amountmult" );
  87. m_tresholdModel.saveSettings( _doc, _this, "treshold" );
  88. }