EqControls.cpp 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * eqcontrols.cpp - defination of EqControls 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 "EqControls.h"
  25. #include <QtXml/QDomElement>
  26. #include "EqControlsDialog.h"
  27. #include "EqEffect.h"
  28. EqControls::EqControls( EqEffect *effect ) :
  29. EffectControls( effect ),
  30. m_effect( effect ),
  31. m_inGainModel( 0.0, -60.0, 20.0, 0.01, this, tr( "Input gain") ),
  32. m_outGainModel( -.0, -60.0, 20.0, 0.01, this, tr( "Output gain" ) ),
  33. m_lowShelfGainModel( 0.0 , -18, 18, 0.001, this, tr( "Low-shelf gain" ) ),
  34. m_para1GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 1 gain" ) ),
  35. m_para2GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 2 gain" ) ),
  36. m_para3GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 3 gain" ) ),
  37. m_para4GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 4 gain" ) ),
  38. m_highShelfGainModel( 0.0 , -18, 18, 0.001, this, tr( "High-shelf gain" ) ),
  39. m_hpResModel( 0.707,0.003, 10.0 , 0.001, this, tr( "HP res" ) ),
  40. m_lowShelfResModel( 1.4,0.55, 10.0 , 0.001, this , tr( "Low-shelf res" ) ),
  41. m_para1BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 1 BW" ) ),
  42. m_para2BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 2 BW" ) ),
  43. m_para3BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 3 BW" ) ),
  44. m_para4BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 4 BW" ) ),
  45. m_highShelfResModel( 1.4, 0.55, 10.0 , 0.001, this , tr( "High-shelf res" ) ),
  46. m_lpResModel( 0.707,0.003, 10.0 , 0.001, this , tr( "LP res" ) ),
  47. m_hpFeqModel( 31.0, 20.0, 20000, 0.001, this , tr( "HP freq" ) ),
  48. m_lowShelfFreqModel( 80.0, 20.0, 20000, 0.001, this , tr( "Low-shelf freq" ) ),
  49. m_para1FreqModel( 120.0, 20.0, 20000, 0.001, this , tr( "Peak 1 freq" ) ),
  50. m_para2FreqModel( 250.0, 20.0, 20000, 0.001, this, tr( "Peak 2 freq" ) ),
  51. m_para3FreqModel( 2000.0, 20.0, 20000, 0.001, this , tr( "Peak 3 freq" ) ),
  52. m_para4FreqModel( 4000.0, 20.0, 20000, 0.001, this , tr( "Peak 4 freq" ) ),
  53. m_highShelfFreqModel( 12000.0, 20.0, 20000, 0.001, this , tr( "High-shelf freq" ) ),
  54. m_lpFreqModel( 18000.0, 20.0, 20000, 0.001, this , tr( "LP freq" ) ),
  55. m_hpActiveModel( false, this , tr( "HP active" ) ),
  56. m_lowShelfActiveModel( false, this , tr( "Low-shelf active" ) ),
  57. m_para1ActiveModel( false, this , tr( "Peak 1 active" ) ),
  58. m_para2ActiveModel( false, this , tr( "Peak 2 active" ) ),
  59. m_para3ActiveModel( false, this , tr( "Peak 3 active" ) ),
  60. m_para4ActiveModel( false, this , tr( "Peak 4 active" ) ),
  61. m_highShelfActiveModel( false, this , tr( "High-shelf active" ) ),
  62. m_lpActiveModel( false, this , tr( "LP active" ) ),
  63. m_lp12Model( false, this , tr( "LP 12" ) ),
  64. m_lp24Model( false, this , tr( "LP 24" ) ),
  65. m_lp48Model( false, this , tr( "LP 48" ) ),
  66. m_hp12Model( false, this , tr( "HP 12" ) ),
  67. m_hp24Model( false, this , tr( "HP 24" ) ),
  68. m_hp48Model( false, this , tr( "HP 48" ) ),
  69. m_lpTypeModel( 0,0,2, this, tr( "Low-pass type" ) ) ,
  70. m_hpTypeModel( 0,0,2, this, tr( "High-pass type" ) ),
  71. m_analyseInModel( true, this , tr( "Analyse IN" ) ),
  72. m_analyseOutModel( true, this, tr( "Analyse OUT" ) )
  73. {
  74. m_hpFeqModel.setScaleLogarithmic( true );
  75. m_lowShelfFreqModel.setScaleLogarithmic( true );
  76. m_para1FreqModel.setScaleLogarithmic( true );
  77. m_para2FreqModel.setScaleLogarithmic( true );
  78. m_para3FreqModel.setScaleLogarithmic( true );
  79. m_para4FreqModel.setScaleLogarithmic( true );
  80. m_highShelfFreqModel.setScaleLogarithmic( true );
  81. m_lpFreqModel.setScaleLogarithmic( true );
  82. m_para1GainModel.setScaleLogarithmic( true );
  83. m_inPeakL = 0;
  84. m_inPeakR = 0;
  85. m_outPeakL = 0;
  86. m_outPeakR = 0;
  87. m_lowShelfPeakL = 0; m_lowShelfPeakR = 0;
  88. m_para1PeakL = 0; m_para1PeakR = 0;
  89. m_para2PeakL = 0; m_para2PeakR = 0;
  90. m_para3PeakL = 0; m_para3PeakR = 0;
  91. m_para4PeakL = 0; m_para4PeakR = 0;
  92. m_highShelfPeakL = 0; m_highShelfPeakR = 0;
  93. m_inProgress = false;
  94. m_inGainModel.setScaleLogarithmic( true );
  95. }
  96. void EqControls::loadSettings( const QDomElement &_this )
  97. {
  98. m_inGainModel.loadSettings( _this, "Inputgain" );
  99. m_outGainModel.loadSettings( _this, "Outputgain" );
  100. m_lowShelfGainModel.loadSettings( _this , "Lowshelfgain" );
  101. m_para1GainModel.loadSettings( _this, "Peak1gain" );
  102. m_para2GainModel.loadSettings( _this, "Peak2gain" );
  103. m_para3GainModel.loadSettings( _this, "Peak3gain" );
  104. m_para4GainModel.loadSettings( _this, "Peak4gain" );
  105. m_highShelfGainModel.loadSettings( _this , "HighShelfgain" );
  106. m_hpResModel.loadSettings( _this ,"HPres" );
  107. m_lowShelfResModel.loadSettings( _this, "LowShelfres" );
  108. m_para1BwModel.loadSettings( _this ,"Peak1bw" );
  109. m_para2BwModel.loadSettings( _this ,"Peak2bw" );
  110. m_para3BwModel.loadSettings( _this ,"Peak3bw" );
  111. m_para4BwModel.loadSettings( _this ,"Peak4bw" );
  112. m_highShelfResModel.loadSettings( _this, "HighShelfres" );
  113. m_lpResModel.loadSettings( _this, "LPres" );
  114. m_hpFeqModel.loadSettings( _this, "HPfreq" );
  115. m_lowShelfFreqModel.loadSettings( _this, "LowShelffreq" );
  116. m_para1FreqModel.loadSettings( _this, "Peak1freq" );
  117. m_para2FreqModel.loadSettings( _this, "Peak2freq" );
  118. m_para3FreqModel.loadSettings( _this, "Peak3freq" );
  119. m_para4FreqModel.loadSettings( _this, "Peak4freq" );
  120. m_highShelfFreqModel.loadSettings( _this, "Highshelffreq" );
  121. m_lpFreqModel.loadSettings( _this, "LPfreq" );
  122. m_hpActiveModel.loadSettings( _this, "HPactive" );
  123. m_lowShelfActiveModel.loadSettings( _this, "Lowshelfactive" );
  124. m_para1ActiveModel.loadSettings( _this, "Peak1active" );
  125. m_para2ActiveModel.loadSettings( _this, "Peak2active" );
  126. m_para3ActiveModel.loadSettings( _this, "Peak3active" );
  127. m_para4ActiveModel.loadSettings( _this, "Peak4active" );
  128. m_highShelfActiveModel.loadSettings( _this, "Highshelfactive" );
  129. m_lpActiveModel.loadSettings( _this, "LPactive" );
  130. m_lp12Model.loadSettings( _this , "LP12" );
  131. m_lp24Model.loadSettings( _this , "LP24" );
  132. m_lp48Model.loadSettings( _this , "LP48" );
  133. m_hp12Model.loadSettings( _this , "HP12" );
  134. m_hp24Model.loadSettings( _this , "HP24" );
  135. m_hp48Model.loadSettings( _this , "HP48" );
  136. m_lpTypeModel.loadSettings( _this, "LP" );
  137. m_hpTypeModel.loadSettings( _this, "HP" );
  138. m_analyseInModel.loadSettings( _this, "AnalyseIn" );
  139. m_analyseOutModel.loadSettings( _this, "AnalyseOut" );
  140. }
  141. EffectControlDialog*EqControls::createView()
  142. {
  143. return new EqControlsDialog( this );
  144. }
  145. void EqControls::saveSettings( QDomDocument &doc, QDomElement &parent )
  146. {
  147. m_inGainModel.saveSettings( doc, parent, "Inputgain" );
  148. m_outGainModel.saveSettings( doc, parent, "Outputgain");
  149. m_lowShelfGainModel.saveSettings( doc, parent , "Lowshelfgain" );
  150. m_para1GainModel.saveSettings( doc, parent, "Peak1gain" );
  151. m_para2GainModel.saveSettings( doc, parent, "Peak2gain" );
  152. m_para3GainModel.saveSettings( doc, parent, "Peak3gain" );
  153. m_para4GainModel.saveSettings( doc, parent, "Peak4gain" );
  154. m_highShelfGainModel.saveSettings( doc, parent, "HighShelfgain" );
  155. m_hpResModel.saveSettings( doc, parent ,"HPres" );
  156. m_lowShelfResModel.saveSettings( doc, parent, "LowShelfres" );
  157. m_para1BwModel.saveSettings( doc, parent,"Peak1bw" );
  158. m_para2BwModel.saveSettings( doc, parent,"Peak2bw" );
  159. m_para3BwModel.saveSettings( doc, parent,"Peak3bw" );
  160. m_para4BwModel.saveSettings( doc, parent,"Peak4bw" );
  161. m_highShelfResModel.saveSettings( doc, parent, "HighShelfres" );
  162. m_lpResModel.saveSettings( doc, parent, "LPres" );
  163. m_hpFeqModel.saveSettings( doc, parent, "HPfreq" );
  164. m_lowShelfFreqModel.saveSettings( doc, parent, "LowShelffreq" );
  165. m_para1FreqModel.saveSettings( doc, parent, "Peak1freq" );
  166. m_para2FreqModel.saveSettings( doc, parent, "Peak2freq" );
  167. m_para3FreqModel.saveSettings( doc, parent, "Peak3freq" );
  168. m_para4FreqModel.saveSettings( doc, parent, "Peak4freq" );
  169. m_highShelfFreqModel.saveSettings( doc, parent, "Highshelffreq" );
  170. m_lpFreqModel.saveSettings( doc, parent, "LPfreq" );
  171. m_hpActiveModel.saveSettings( doc, parent, "HPactive" );
  172. m_lowShelfActiveModel.saveSettings( doc, parent, "Lowshelfactive" );
  173. m_para1ActiveModel.saveSettings( doc, parent, "Peak1active" );
  174. m_para2ActiveModel.saveSettings( doc, parent, "Peak2active" );
  175. m_para3ActiveModel.saveSettings( doc, parent, "Peak3active" );
  176. m_para4ActiveModel.saveSettings( doc, parent, "Peak4active" );
  177. m_highShelfActiveModel.saveSettings( doc, parent, "Highshelfactive" );
  178. m_lpActiveModel.saveSettings( doc, parent, "LPactive" );
  179. m_lp12Model.saveSettings( doc, parent, "LP12" );
  180. m_lp24Model.saveSettings( doc, parent, "LP24" );
  181. m_lp48Model.saveSettings( doc, parent, "LP48" );
  182. m_hp12Model.saveSettings( doc, parent, "HP12" );
  183. m_hp24Model.saveSettings( doc, parent, "HP24" );
  184. m_hp48Model.saveSettings( doc, parent, "HP48" );
  185. m_lpTypeModel.saveSettings( doc, parent, "LP" );
  186. m_hpTypeModel.saveSettings( doc, parent, "HP" );
  187. m_analyseInModel.saveSettings( doc, parent, "AnalyseIn" );
  188. m_analyseOutModel.saveSettings( doc, parent, "AnalyseOut" );
  189. }