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
25
26 #include "EqControlsDialog.h"
27
28 #include <QGraphicsView>
29 #include <QLayout>
30 #include <QWidget>
31
32 #include "AutomatableButton.h"
33 #include "embed.h"
34 #include "Engine.h"
35 #include "Knob.h"
36 #include "Fader.h"
37 #include "LedCheckbox.h"
38 #include "PixmapButton.h"
39
40 #include "EqControls.h"
41 #include "EqFader.h"
42 #include "EqParameterWidget.h"
43 #include "EqSpectrumView.h"
44
45
EqControlsDialog(EqControls * controls)46 EqControlsDialog::EqControlsDialog( EqControls *controls ) :
47 EffectControlDialog( controls ),
48 m_controls( controls )
49 {
50 setAutoFillBackground( true );
51 QPalette pal;
52 pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
53 setPalette( pal );
54 setFixedSize( 500, 500 );
55
56 EqSpectrumView * inSpec = new EqSpectrumView( &controls->m_inFftBands, this );
57 inSpec->move( 26, 17 );
58 inSpec->setColor( QColor( 77, 101, 242, 150 ) );
59
60 EqSpectrumView * outSpec = new EqSpectrumView( &controls->m_outFftBands, this );
61 outSpec->setColor( QColor( 0, 255, 239, 150 ) );
62 outSpec->move( 26, 17 );
63
64 m_parameterWidget = new EqParameterWidget( this , controls );
65 m_parameterWidget->move( 26, 17 );
66
67 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);
68 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 );
69 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 );
70 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 );
71 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 );
72 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 );
73 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 );
74 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);
75
76 QPixmap * faderBg = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderback" ) );
77 QPixmap * faderLeds = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderleds" ) );
78 QPixmap * faderKnob = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderknob" ) );
79
80 EqFader * GainFaderIn = new EqFader( &controls->m_inGainModel, tr( "In Gain" ), this, faderBg, faderLeds, faderKnob, &controls->m_inPeakL, &controls->m_inPeakR );
81 GainFaderIn->move( 23, 295 );
82 GainFaderIn->setDisplayConversion( false );
83 GainFaderIn->setHintText( tr( "Gain" ), "dBv");
84
85 EqFader * GainFaderOut = new EqFader( &controls->m_outGainModel, tr( "Out Gain" ), this, faderBg, faderLeds, faderKnob, &controls->m_outPeakL, &controls->m_outPeakR );
86 GainFaderOut->move( 453, 295);
87 GainFaderOut->setDisplayConversion( false );
88 GainFaderOut->setHintText( tr( "Gain" ), "dBv" );
89
90 // Gain Fader for each Filter exepts the pass filter
91 int distance = 126;
92 for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ )
93 {
94 EqFader * gainFader = new EqFader( m_parameterWidget->getBandModels( i )->gain, tr( "" ), this, faderBg, faderLeds, faderKnob, m_parameterWidget->getBandModels( i )->peakL, m_parameterWidget->getBandModels( i )->peakR );
95 gainFader->move( distance, 295 );
96 distance += 44;
97 gainFader->setMinimumHeight(80);
98 gainFader->resize(gainFader->width() , 80);
99 gainFader->setDisplayConversion( false );
100 gainFader->setHintText( tr( "Gain") , "dB");
101 }
102
103 //Control Button and Knobs for each Band
104 distance = 81;
105 for( int i = 0; i < m_parameterWidget->bandCount() ; i++ )
106 {
107 Knob * resKnob = new Knob( knobBright_26, this );
108 resKnob->move( distance, 440 );
109 resKnob->setVolumeKnob(false);
110 resKnob->setModel( m_parameterWidget->getBandModels( i )->res );
111 if(i > 1 && i < 6) { resKnob->setHintText( tr( "Bandwidth: " ) , tr( " Octave" ) ); }
112 else { resKnob->setHintText( tr( "Resonance : " ) , "" ); }
113
114 Knob * freqKnob = new Knob( knobBright_26, this );
115 freqKnob->move( distance, 396 );
116 freqKnob->setVolumeKnob( false );
117 freqKnob->setModel( m_parameterWidget->getBandModels( i )->freq );
118 freqKnob->setHintText( tr( "Frequency:" ), "Hz" );
119
120 // adds the Number Active buttons
121 PixmapButton * activeButton = new PixmapButton( this, NULL );
122 activeButton->setCheckable(true);
123 activeButton->setModel( m_parameterWidget->getBandModels( i )->active );
124
125 QString iconActiveFileName = "bandLabel" + QString::number(i+1);
126 QString iconInactiveFileName = "bandLabel" + QString::number(i+1) + "off";
127 activeButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( iconActiveFileName.toLatin1() ) );
128 activeButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( iconInactiveFileName.toLatin1() ) );
129 activeButton->move( distance - 2, 276 );
130 activeButton->setModel( m_parameterWidget->getBandModels( i )->active );
131
132 // Connects the knobs, Faders and buttons with the curve graphic
133 QObject::connect( m_parameterWidget->getBandModels( i )->freq , SIGNAL( dataChanged() ), m_parameterWidget, SLOT ( updateHandle() ) );
134 if ( m_parameterWidget->getBandModels( i )->gain ) QObject::connect( m_parameterWidget->getBandModels( i )->gain, SIGNAL( dataChanged() ), m_parameterWidget, SLOT ( updateHandle() ));
135 QObject::connect( m_parameterWidget->getBandModels( i )->res, SIGNAL( dataChanged() ), m_parameterWidget , SLOT ( updateHandle() ) );
136 QObject::connect( m_parameterWidget->getBandModels( i )->active, SIGNAL( dataChanged() ), m_parameterWidget , SLOT ( updateHandle() ) );
137
138 m_parameterWidget->changeHandle( i );
139 distance += 44;
140 }
141
142
143 // adds the buttons for Spectrum analyser on/off
144 LedCheckBox * inSpecButton = new LedCheckBox( this );
145 inSpecButton->setCheckable(true);
146 inSpecButton->setModel( &controls->m_analyseInModel );
147 inSpecButton->move( 172, 240 );
148 LedCheckBox * outSpecButton = new LedCheckBox( this );
149 outSpecButton->setCheckable(true);
150 outSpecButton->setModel( &controls->m_analyseOutModel );
151 outSpecButton->move( 302, 240 );
152
153 //hp filter type
154 PixmapButton * hp12Button = new PixmapButton( this , NULL );
155 hp12Button->setModel( m_parameterWidget->getBandModels( 0 )->hp12 );
156 hp12Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "12dB" ) );
157 hp12Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "12dBoff" ) );
158 hp12Button->move( 79, 298 );
159 PixmapButton * hp24Button = new PixmapButton( this , NULL );
160 hp24Button->setModel(m_parameterWidget->getBandModels( 0 )->hp24 );
161 hp24Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "24dB" ) );
162 hp24Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "24dBoff" ) );
163
164 hp24Button->move( 79 , 328 );
165 PixmapButton * hp48Button = new PixmapButton( this , NULL );
166 hp48Button->setModel( m_parameterWidget->getBandModels(0)->hp48 );
167 hp48Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "48dB" ) );
168 hp48Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "48dBoff" ) );
169
170 hp48Button->move( 79, 358 );
171 //LP filter type
172 PixmapButton * lp12Button = new PixmapButton( this , NULL );
173 lp12Button->setModel( m_parameterWidget->getBandModels( 7 )->lp12 );
174 lp12Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "12dB" ) );
175 lp12Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "12dBoff" ) );
176
177 lp12Button->move( 387, 298 );
178 PixmapButton * lp24Button = new PixmapButton( this , NULL );
179 lp24Button->setModel( m_parameterWidget->getBandModels( 7 )->lp24 );
180 lp24Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "24dB" ) );
181 lp24Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "24dBoff" ) );
182
183 lp24Button->move( 387, 328 );
184
185 PixmapButton * lp48Button = new PixmapButton( this , NULL );
186 lp48Button->setModel( m_parameterWidget->getBandModels( 7 )->lp48 );
187 lp48Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "48dB" ) );
188 lp48Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "48dBoff" ) );
189
190 lp48Button->move( 387, 358 );
191 // the curve has to change its appearance
192 QObject::connect( m_parameterWidget->getBandModels( 0 )->hp12 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
193 QObject::connect( m_parameterWidget->getBandModels( 0 )->hp24 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
194 QObject::connect( m_parameterWidget->getBandModels( 0 )->hp48 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
195
196 QObject::connect( m_parameterWidget->getBandModels( 7 )->lp12 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
197 QObject::connect( m_parameterWidget->getBandModels( 7 )->lp24 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
198 QObject::connect( m_parameterWidget->getBandModels( 7 )->lp48 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle()));
199
200 automatableButtonGroup *lpBtnGrp = new automatableButtonGroup(this,tr ( "lp grp" ) );
201 lpBtnGrp->addButton( lp12Button );
202 lpBtnGrp->addButton( lp24Button );
203 lpBtnGrp->addButton( lp48Button );
204 lpBtnGrp->setModel( &m_controls->m_lpTypeModel, false);
205
206 automatableButtonGroup *hpBtnGrp = new automatableButtonGroup( this, tr( "hp grp" ) );
207 hpBtnGrp->addButton( hp12Button );
208 hpBtnGrp->addButton( hp24Button );
209 hpBtnGrp->addButton( hp48Button );
210 hpBtnGrp->setModel( &m_controls->m_hpTypeModel,false);
211 }
212
213
214
215
mouseDoubleClickEvent(QMouseEvent * event)216 void EqControlsDialog::mouseDoubleClickEvent(QMouseEvent *event)
217 {
218 m_originalHeight = parentWidget()->height() == 283 ? m_originalHeight : parentWidget()->height() ;
219 parentWidget()->setFixedHeight( parentWidget()->height() == m_originalHeight ? 283 : m_originalHeight );
220 update();
221 }
222
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)223 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)
224 {
225 EqBand *filterModels = m_parameterWidget->getBandModels( index );
226 filterModels->active = active;
227 filterModels->freq = freq;
228 filterModels->res = res;
229 filterModels->color = color;
230 filterModels->gain = gain;
231 filterModels->peakL = peakL;
232 filterModels->peakR = peakR;
233 filterModels->hp12 = hp12;
234 filterModels->hp24 = hp24;
235 filterModels->hp48 = hp48;
236 filterModels->lp12 = lp12;
237 filterModels->lp24 = lp24;
238 filterModels->lp48 = lp48;
239 return filterModels;
240 }
241