EqControlsDialog.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * eqcontrolsdialog.cpp - defination of EqControlsDialog 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 "EqControlsDialog.h"
  25. #include <QGraphicsView>
  26. #include <QLayout>
  27. #include <QWidget>
  28. #include "AutomatableButton.h"
  29. #include "embed.h"
  30. #include "Engine.h"
  31. #include "Knob.h"
  32. #include "Fader.h"
  33. #include "LedCheckbox.h"
  34. #include "PixmapButton.h"
  35. #include "EqControls.h"
  36. #include "EqFader.h"
  37. #include "EqParameterWidget.h"
  38. #include "EqSpectrumView.h"
  39. EqControlsDialog::EqControlsDialog( EqControls *controls ) :
  40. EffectControlDialog( controls ),
  41. m_controls( controls )
  42. {
  43. setAutoFillBackground( true );
  44. QPalette pal;
  45. pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
  46. setPalette( pal );
  47. setFixedSize( 500, 500 );
  48. EqSpectrumView * inSpec = new EqSpectrumView( &controls->m_inFftBands, this );
  49. inSpec->move( 26, 17 );
  50. inSpec->setColor( QColor( 77, 101, 242, 150 ) );
  51. EqSpectrumView * outSpec = new EqSpectrumView( &controls->m_outFftBands, this );
  52. outSpec->setColor( QColor( 0, 255, 239, 150 ) );
  53. outSpec->move( 26, 17 );
  54. m_parameterWidget = new EqParameterWidget( this , controls );
  55. m_parameterWidget->move( 26, 17 );
  56. setBand( 0, &controls->m_hpActiveModel, &controls->m_hpFeqModel, &controls->m_hpResModel, 0, QColor(255 ,255, 255), tr( "HP" ) ,0,0, &controls->m_hp12Model, &controls->m_hp24Model, &controls->m_hp48Model,0,0,0);
  57. setBand( 1, &controls->m_lowShelfActiveModel, &controls->m_lowShelfFreqModel, &controls->m_lowShelfResModel, &controls->m_lowShelfGainModel, QColor(255 ,255, 255), tr( "Low-shelf" ), &controls->m_lowShelfPeakL , &controls->m_lowShelfPeakR,0,0,0,0,0,0 );
  58. setBand( 2, &controls->m_para1ActiveModel, &controls->m_para1FreqModel, &controls->m_para1BwModel, &controls->m_para1GainModel, QColor(255 ,255, 255), tr( "Peak 1" ), &controls->m_para1PeakL, &controls->m_para1PeakR,0,0,0,0,0,0 );
  59. setBand( 3, &controls->m_para2ActiveModel, &controls->m_para2FreqModel, &controls->m_para2BwModel, &controls->m_para2GainModel, QColor(255 ,255, 255), tr( "Peak 2" ), &controls->m_para2PeakL, &controls->m_para2PeakR,0,0,0,0,0,0 );
  60. setBand( 4, &controls->m_para3ActiveModel, &controls->m_para3FreqModel, &controls->m_para3BwModel, &controls->m_para3GainModel, QColor(255 ,255, 255), tr( "Peak 3" ), &controls->m_para3PeakL, &controls->m_para3PeakR,0,0,0,0,0,0 );
  61. setBand( 5, &controls->m_para4ActiveModel, &controls->m_para4FreqModel, &controls->m_para4BwModel, &controls->m_para4GainModel, QColor(255 ,255, 255), tr( "Peak 4" ), &controls->m_para4PeakL, &controls->m_para4PeakR,0,0,0,0,0,0 );
  62. setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 );
  63. setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model);
  64. QPixmap * faderBg = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderback" ) );
  65. QPixmap * faderLeds = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderleds" ) );
  66. QPixmap * faderKnob = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderknob" ) );
  67. EqFader * GainFaderIn = new EqFader( &controls->m_inGainModel, tr( "Input gain" ), this, faderBg, faderLeds, faderKnob, &controls->m_inPeakL, &controls->m_inPeakR );
  68. GainFaderIn->move( 23, 295 );
  69. GainFaderIn->setDisplayConversion( false );
  70. GainFaderIn->setHintText( tr( "Gain" ), "dBv");
  71. EqFader * GainFaderOut = new EqFader( &controls->m_outGainModel, tr( "Output gain" ), this, faderBg, faderLeds, faderKnob, &controls->m_outPeakL, &controls->m_outPeakR );
  72. GainFaderOut->move( 453, 295);
  73. GainFaderOut->setDisplayConversion( false );
  74. GainFaderOut->setHintText( tr( "Gain" ), "dBv" );
  75. // Gain Fader for each Filter exepts the pass filter
  76. int distance = 126;
  77. for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ )
  78. {
  79. EqFader * gainFader = new EqFader( m_parameterWidget->getBandModels( i )->gain, tr( "" ), this, faderBg, faderLeds, faderKnob, m_parameterWidget->getBandModels( i )->peakL, m_parameterWidget->getBandModels( i )->peakR );
  80. gainFader->move( distance, 295 );
  81. distance += 44;
  82. gainFader->setMinimumHeight(80);
  83. gainFader->resize(gainFader->width() , 80);
  84. gainFader->setDisplayConversion( false );
  85. gainFader->setHintText( tr( "Gain") , "dB");
  86. }
  87. //Control Button and Knobs for each Band
  88. distance = 81;
  89. for( int i = 0; i < m_parameterWidget->bandCount() ; i++ )
  90. {
  91. Knob * resKnob = new Knob( knobBright_26, this );
  92. resKnob->move( distance, 440 );
  93. resKnob->setVolumeKnob(false);
  94. resKnob->setModel( m_parameterWidget->getBandModels( i )->res );
  95. if(i > 1 && i < 6) { resKnob->setHintText( tr( "Bandwidth: " ) , tr( " Octave" ) ); }
  96. else { resKnob->setHintText( tr( "Resonance : " ) , "" ); }
  97. Knob * freqKnob = new Knob( knobBright_26, this );
  98. freqKnob->move( distance, 396 );
  99. freqKnob->setVolumeKnob( false );
  100. freqKnob->setModel( m_parameterWidget->getBandModels( i )->freq );
  101. freqKnob->setHintText( tr( "Frequency:" ), "Hz" );
  102. // adds the Number Active buttons
  103. PixmapButton * activeButton = new PixmapButton( this, nullptr );
  104. activeButton->setCheckable(true);
  105. activeButton->setModel( m_parameterWidget->getBandModels( i )->active );
  106. QString iconActiveFileName = "bandLabel" + QString::number(i+1);
  107. QString iconInactiveFileName = "bandLabel" + QString::number(i+1) + "off";
  108. activeButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( iconActiveFileName.toLatin1() ) );
  109. activeButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( iconInactiveFileName.toLatin1() ) );
  110. activeButton->move( distance - 2, 276 );
  111. activeButton->setModel( m_parameterWidget->getBandModels( i )->active );
  112. // Connects the knobs, Faders and buttons with the curve graphic
  113. QObject::connect( m_parameterWidget->getBandModels( i )->freq , SIGNAL( dataChanged() ), m_parameterWidget, SLOT ( updateHandle() ) );
  114. if ( m_parameterWidget->getBandModels( i )->gain ) QObject::connect( m_parameterWidget->getBandModels( i )->gain, SIGNAL( dataChanged() ), m_parameterWidget, SLOT ( updateHandle() ));
  115. QObject::connect( m_parameterWidget->getBandModels( i )->res, SIGNAL( dataChanged() ), m_parameterWidget , SLOT ( updateHandle() ) );
  116. QObject::connect( m_parameterWidget->getBandModels( i )->active, SIGNAL( dataChanged() ), m_parameterWidget , SLOT ( updateHandle() ) );
  117. m_parameterWidget->changeHandle( i );
  118. distance += 44;
  119. }
  120. // adds the buttons for Spectrum analyser on/off
  121. LedCheckBox * inSpecButton = new LedCheckBox( this );
  122. inSpecButton->setCheckable(true);
  123. inSpecButton->setModel( &controls->m_analyseInModel );
  124. inSpecButton->move( 172, 240 );
  125. LedCheckBox * outSpecButton = new LedCheckBox( this );
  126. outSpecButton->setCheckable(true);
  127. outSpecButton->setModel( &controls->m_analyseOutModel );
  128. outSpecButton->move( 302, 240 );
  129. //hp filter type
  130. PixmapButton * hp12Button = new PixmapButton( this , nullptr );
  131. hp12Button->setModel( m_parameterWidget->getBandModels( 0 )->hp12 );
  132. hp12Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "12dB" ) );
  133. hp12Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "12dBoff" ) );
  134. hp12Button->move( 79, 298 );
  135. PixmapButton * hp24Button = new PixmapButton( this , nullptr );
  136. hp24Button->setModel(m_parameterWidget->getBandModels( 0 )->hp24 );
  137. hp24Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "24dB" ) );
  138. hp24Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "24dBoff" ) );
  139. hp24Button->move( 79 , 328 );
  140. PixmapButton * hp48Button = new PixmapButton( this , nullptr );
  141. hp48Button->setModel( m_parameterWidget->getBandModels(0)->hp48 );
  142. hp48Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "48dB" ) );
  143. hp48Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "48dBoff" ) );
  144. hp48Button->move( 79, 358 );
  145. //LP filter type
  146. PixmapButton * lp12Button = new PixmapButton( this , nullptr );
  147. lp12Button->setModel( m_parameterWidget->getBandModels( 7 )->lp12 );
  148. lp12Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "12dB" ) );
  149. lp12Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "12dBoff" ) );
  150. lp12Button->move( 387, 298 );
  151. PixmapButton * lp24Button = new PixmapButton( this , nullptr );
  152. lp24Button->setModel( m_parameterWidget->getBandModels( 7 )->lp24 );
  153. lp24Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "24dB" ) );
  154. lp24Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "24dBoff" ) );
  155. lp24Button->move( 387, 328 );
  156. PixmapButton * lp48Button = new PixmapButton( this , nullptr );
  157. lp48Button->setModel( m_parameterWidget->getBandModels( 7 )->lp48 );
  158. lp48Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "48dB" ) );
  159. lp48Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "48dBoff" ) );
  160. lp48Button->move( 387, 358 );
  161. // the curve has to change its appearance
  162. QObject::connect( m_parameterWidget->getBandModels( 0 )->hp12 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
  163. QObject::connect( m_parameterWidget->getBandModels( 0 )->hp24 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
  164. QObject::connect( m_parameterWidget->getBandModels( 0 )->hp48 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
  165. QObject::connect( m_parameterWidget->getBandModels( 7 )->lp12 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
  166. QObject::connect( m_parameterWidget->getBandModels( 7 )->lp24 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
  167. QObject::connect( m_parameterWidget->getBandModels( 7 )->lp48 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
  168. automatableButtonGroup *lpBtnGrp = new automatableButtonGroup( this, tr( "LP group" ) );
  169. lpBtnGrp->addButton( lp12Button );
  170. lpBtnGrp->addButton( lp24Button );
  171. lpBtnGrp->addButton( lp48Button );
  172. lpBtnGrp->setModel(&m_controls->m_lpTypeModel);
  173. automatableButtonGroup *hpBtnGrp = new automatableButtonGroup( this, tr( "HP group" ) );
  174. hpBtnGrp->addButton( hp12Button );
  175. hpBtnGrp->addButton( hp24Button );
  176. hpBtnGrp->addButton( hp48Button );
  177. hpBtnGrp->setModel(&m_controls->m_hpTypeModel);
  178. }
  179. void EqControlsDialog::mouseDoubleClickEvent(QMouseEvent *event)
  180. {
  181. m_originalHeight = parentWidget()->height() == 283 ? m_originalHeight : parentWidget()->height() ;
  182. parentWidget()->setFixedHeight( parentWidget()->height() == m_originalHeight ? 283 : m_originalHeight );
  183. update();
  184. }
  185. EqBand* EqControlsDialog::setBand(int index, BoolModel* active, FloatModel* freq, FloatModel* res, FloatModel* gain, QColor color, QString name, float* peakL, float* peakR, BoolModel* hp12, BoolModel* hp24, BoolModel* hp48, BoolModel* lp12, BoolModel* lp24, BoolModel* lp48)
  186. {
  187. EqBand *filterModels = m_parameterWidget->getBandModels( index );
  188. filterModels->active = active;
  189. filterModels->freq = freq;
  190. filterModels->res = res;
  191. filterModels->color = color;
  192. filterModels->gain = gain;
  193. filterModels->peakL = peakL;
  194. filterModels->peakR = peakR;
  195. filterModels->hp12 = hp12;
  196. filterModels->hp24 = hp24;
  197. filterModels->hp48 = hp48;
  198. filterModels->lp12 = lp12;
  199. filterModels->lp24 = lp24;
  200. filterModels->lp48 = lp48;
  201. return filterModels;
  202. }