CrossoverEQControls.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * CrossoverEQControls.cpp - A native 4-band Crossover Equalizer
  3. * good for simulating tonestacks or simple peakless (flat-band) equalization
  4. *
  5. * Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
  6. * Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  7. *
  8. * This file is part of LMMS - https://lmms.io
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2 of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public
  21. * License along with this program (see COPYING); if not, write to the
  22. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  23. * Boston, MA 02110-1301 USA.
  24. *
  25. */
  26. #include "CrossoverEQControls.h"
  27. #include "CrossoverEQ.h"
  28. CrossoverEQControls::CrossoverEQControls( CrossoverEQEffect * eff ) :
  29. EffectControls( eff ),
  30. m_effect( eff ),
  31. m_xover12( 125.f, 50.f, 10000.f, 1.0f, this, "Band 1/2 Crossover" ),
  32. m_xover23( 1250.f, 50.f, 20000.f, 1.0f, this, "Band 2/3 Crossover" ),
  33. m_xover34( 5000.f, 50.f, 20000.f, 1.0f, this, "Band 3/4 Crossover" ),
  34. m_gain1( 0.f, -60.f, 30.f, 0.1f, this, "Band 1 Gain" ),
  35. m_gain2( 0.f, -60.f, 30.f, 0.1f, this, "Band 2 Gain" ),
  36. m_gain3( 0.f, -60.f, 30.f, 0.1f, this, "Band 3 Gain" ),
  37. m_gain4( 0.f, -60.f, 30.f, 0.1f, this, "Band 4 Gain" ),
  38. m_mute1( true, this, "Mute Band 1" ),
  39. m_mute2( true, this, "Mute Band 2" ),
  40. m_mute3( true, this, "Mute Band 3" ),
  41. m_mute4( true, this, "Mute Band 4" )
  42. {
  43. connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) );
  44. connect( &m_xover12, SIGNAL( dataChanged() ), this, SLOT( xover12Changed() ) );
  45. connect( &m_xover23, SIGNAL( dataChanged() ), this, SLOT( xover23Changed() ) );
  46. connect( &m_xover34, SIGNAL( dataChanged() ), this, SLOT( xover34Changed() ) );
  47. m_xover12.setScaleLogarithmic( true );
  48. m_xover23.setScaleLogarithmic( true );
  49. m_xover34.setScaleLogarithmic( true );
  50. }
  51. void CrossoverEQControls::saveSettings( QDomDocument & doc, QDomElement & elem )
  52. {
  53. m_xover12.saveSettings( doc, elem, "xover12" );
  54. m_xover23.saveSettings( doc, elem, "xover23" );
  55. m_xover34.saveSettings( doc, elem, "xover34" );
  56. m_gain1.saveSettings( doc, elem, "gain1" );
  57. m_gain2.saveSettings( doc, elem, "gain2" );
  58. m_gain3.saveSettings( doc, elem, "gain3" );
  59. m_gain4.saveSettings( doc, elem, "gain4" );
  60. m_mute1.saveSettings( doc, elem, "mute1" );
  61. m_mute2.saveSettings( doc, elem, "mute2" );
  62. m_mute3.saveSettings( doc, elem, "mute3" );
  63. m_mute4.saveSettings( doc, elem, "mute4" );
  64. }
  65. void CrossoverEQControls::loadSettings( const QDomElement & elem )
  66. {
  67. m_xover12.loadSettings( elem, "xover12" );
  68. m_xover23.loadSettings( elem, "xover23" );
  69. m_xover34.loadSettings( elem, "xover34" );
  70. m_gain1.loadSettings( elem, "gain1" );
  71. m_gain2.loadSettings( elem, "gain2" );
  72. m_gain3.loadSettings( elem, "gain3" );
  73. m_gain4.loadSettings( elem, "gain4" );
  74. m_mute1.loadSettings( elem, "mute1" );
  75. m_mute2.loadSettings( elem, "mute2" );
  76. m_mute3.loadSettings( elem, "mute3" );
  77. m_mute4.loadSettings( elem, "mute4" );
  78. m_effect->m_needsUpdate = true;
  79. m_effect->clearFilterHistories();
  80. }
  81. void CrossoverEQControls::xover12Changed()
  82. {
  83. float v = m_xover12.value();
  84. if( m_xover23.value() < v ) { m_xover23.setValue( v ); }
  85. if( m_xover34.value() < v ) { m_xover34.setValue( v ); }
  86. }
  87. void CrossoverEQControls::xover23Changed()
  88. {
  89. float v = m_xover23.value();
  90. if( m_xover12.value() > v ) { m_xover12.setValue( v ); }
  91. if( m_xover34.value() < v ) { m_xover34.setValue( v ); }
  92. }
  93. void CrossoverEQControls::xover34Changed()
  94. {
  95. float v = m_xover34.value();
  96. if( m_xover12.value() > v ) { m_xover12.setValue( v ); }
  97. if( m_xover23.value() > v ) { m_xover23.setValue( v ); }
  98. }
  99. void CrossoverEQControls::sampleRateChanged()
  100. {
  101. m_effect->sampleRateChanged();
  102. }