New GUI for the native EQ plugin
BIN
plugins/Eq/12dB.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
plugins/Eq/12dBoff.png
Normal file
|
After Width: | Height: | Size: 958 B |
BIN
plugins/Eq/24dB.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
plugins/Eq/24dBoff.png
Normal file
|
After Width: | Height: | Size: 990 B |
BIN
plugins/Eq/48dB.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
plugins/Eq/48dBoff.png
Normal file
|
After Width: | Height: | Size: 1012 B |
BIN
plugins/Eq/ActiveAnalyse.png
Normal file
|
After Width: | Height: | Size: 935 B |
BIN
plugins/Eq/ActiveAnalyseoff.png
Normal file
|
After Width: | Height: | Size: 846 B |
BIN
plugins/Eq/ActiveHP.png
Normal file
|
After Width: | Height: | Size: 992 B |
BIN
plugins/Eq/ActiveHPoff.png
Normal file
|
After Width: | Height: | Size: 905 B |
BIN
plugins/Eq/ActiveHS.png
Normal file
|
After Width: | Height: | Size: 968 B |
BIN
plugins/Eq/ActiveHSoff.png
Normal file
|
After Width: | Height: | Size: 883 B |
BIN
plugins/Eq/ActiveLP.png
Normal file
|
After Width: | Height: | Size: 990 B |
BIN
plugins/Eq/ActiveLPoff.png
Normal file
|
After Width: | Height: | Size: 896 B |
BIN
plugins/Eq/ActiveLS.png
Normal file
|
After Width: | Height: | Size: 983 B |
BIN
plugins/Eq/ActiveLSoff.png
Normal file
|
After Width: | Height: | Size: 909 B |
BIN
plugins/Eq/ActivePeak.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
plugins/Eq/ActivePeakoff.png
Normal file
|
After Width: | Height: | Size: 998 B |
@@ -2,5 +2,5 @@ INCLUDE(BuildPlugin)
|
||||
INCLUDE_DIRECTORIES(${FFTW3F_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${FFTW3F_LIBRARY_DIRS})
|
||||
LINK_LIBRARIES(${FFTW3F_LIBRARIES})
|
||||
BUILD_PLUGIN(eq EqEffect.cpp EqControls.cpp EqControlsDialog.cpp EqFilter.h EqParameterWidget.cpp EqFader.h EqSpectrumView.h
|
||||
MOCFILES EqControls.h EqControlsDialog.h EqParameterWidget.h EqFader.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
|
||||
BUILD_PLUGIN(eq EqEffect.cpp EqCurve.cpp EqCurve.h EqControls.cpp EqControlsDialog.cpp EqFilter.h EqParameterWidget.cpp EqFader.h EqSpectrumView.h
|
||||
MOCFILES EqControls.h EqControlsDialog.h EqCurve.h EqParameterWidget.h EqFader.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
|
||||
|
||||
@@ -34,12 +34,12 @@ EqControls::EqControls( EqEffect *effect ) :
|
||||
m_effect( effect ),
|
||||
m_inGainModel( 0.0, -60.0, 20.0, 0.01, this, tr( "Input gain") ),
|
||||
m_outGainModel( -.0, -60.0, 20.0, 0.01, this, tr( "Output gain" ) ),
|
||||
m_lowShelfGainModel( 0.0 , -40, 40, 0.001, this, tr( "Low shelf gain" ) ),
|
||||
m_para1GainModel( 0.0 , -40, 40, 0.001, this, tr( "Peak 1 gain" ) ),
|
||||
m_para2GainModel( 0.0 , -40, 40, 0.001, this, tr( "Peak 2 gain" ) ),
|
||||
m_para3GainModel( 0.0 , -40, 40, 0.001, this, tr( "Peak 3 gain" ) ),
|
||||
m_para4GainModel( 0.0 , -40, 40, 0.001, this, tr( "Peak 4 gain" ) ),
|
||||
m_highShelfGainModel( 0.0 , -40, 40, 0.001, this, tr( "High Shelf gain" ) ),
|
||||
m_lowShelfGainModel( 0.0 , -18, 18, 0.001, this, tr( "Low shelf gain" ) ),
|
||||
m_para1GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 1 gain" ) ),
|
||||
m_para2GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 2 gain" ) ),
|
||||
m_para3GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 3 gain" ) ),
|
||||
m_para4GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 4 gain" ) ),
|
||||
m_highShelfGainModel( 0.0 , -18, 18, 0.001, this, tr( "High Shelf gain" ) ),
|
||||
m_hpResModel( 0.707,0.003, 10.0 , 0.001, this, tr( "HP res" ) ),
|
||||
m_lowShelfResModel( 1.4,0.55, 10.0 , 0.001, this , tr( "Low Shelf res" ) ),
|
||||
m_para1BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 1 BW" ) ),
|
||||
@@ -48,22 +48,22 @@ EqControls::EqControls( EqEffect *effect ) :
|
||||
m_para4BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 4 BW" ) ),
|
||||
m_highShelfResModel( 1.4, 0.55, 10.0 , 0.001, this , tr( "High Shelf res" ) ),
|
||||
m_lpResModel( 0.707,0.003, 10.0 , 0.001, this , tr( "LP res" ) ),
|
||||
m_hpFeqModel( 31.0, 30.0, 20000, 0.001, this , tr( "HP freq" ) ),
|
||||
m_lowShelfFreqModel( 80.0, 25.0, 20000, 0.001, this , tr( "Low Shelf freq" ) ),
|
||||
m_hpFeqModel( 31.0, 27.0, 20000, 0.001, this , tr( "HP freq" ) ),
|
||||
m_lowShelfFreqModel( 80.0, 27.0, 20000, 0.001, this , tr( "Low Shelf freq" ) ),
|
||||
m_para1FreqModel( 120.0, 27.0, 20000, 0.001, this , tr( "Peak 1 freq" ) ),
|
||||
m_para2FreqModel( 250.0, 27.0, 20000, 0.001, this, tr( "Peak 2 freq" ) ),
|
||||
m_para3FreqModel( 2000.0, 27.0, 20000, 0.001, this , tr( "Peak 3 freq" ) ),
|
||||
m_para4FreqModel( 4000.0, 27.0, 20000, 0.001, this , tr( "Peak 4 freq" ) ),
|
||||
m_highShelfFreqModel( 12000.0, 27.0, 20000, 0.001, this , tr( "High shelf freq" ) ),
|
||||
m_lpFreqModel( 18000.0, 27.0, 20000, 0.001, this , tr( "LP freq" ) ),
|
||||
m_hpActiveModel( true, this , tr( "HP active" ) ),
|
||||
m_lowShelfActiveModel( true, this , tr( "Low shelf active" ) ),
|
||||
m_para1ActiveModel(true, this , tr( "Peak 1 active" ) ),
|
||||
m_para2ActiveModel( true, this , tr( "Peak 2 active" ) ),
|
||||
m_para3ActiveModel( true, this , tr( "Peak 3 active" ) ),
|
||||
m_para4ActiveModel( true, this , tr( "Peak 4 active" ) ),
|
||||
m_highShelfActiveModel( true, this , tr( "High shelf active" ) ),
|
||||
m_lpActiveModel( true, this , tr( "LP active" ) ),
|
||||
m_hpActiveModel( false, this , tr( "HP active" ) ),
|
||||
m_lowShelfActiveModel( false, this , tr( "Low shelf active" ) ),
|
||||
m_para1ActiveModel(false, this , tr( "Peak 1 active" ) ),
|
||||
m_para2ActiveModel( false, this , tr( "Peak 2 active" ) ),
|
||||
m_para3ActiveModel( false, this , tr( "Peak 3 active" ) ),
|
||||
m_para4ActiveModel( false, this , tr( "Peak 4 active" ) ),
|
||||
m_highShelfActiveModel( false, this , tr( "High shelf active" ) ),
|
||||
m_lpActiveModel( false, this , tr( "LP active" ) ),
|
||||
m_lp12Model( false, this , tr( "LP 12" ) ),
|
||||
m_lp24Model( false, this , tr( "LP 24" ) ),
|
||||
m_lp48Model( false, this , tr( "LP 48" ) ),
|
||||
@@ -71,7 +71,9 @@ EqControls::EqControls( EqEffect *effect ) :
|
||||
m_hp24Model( false, this , tr( "HP 24" ) ),
|
||||
m_hp48Model( false, this , tr( "HP 48" ) ),
|
||||
m_lpTypeModel( 0,0,2,this, tr( "low pass type") ) ,
|
||||
m_hpTypeModel( 0,0,2,this, tr( "high pass type") )
|
||||
m_hpTypeModel( 0,0,2,this, tr( "high pass type") ),
|
||||
m_analyseInModel( true, this , tr( "Analyse IN")),
|
||||
m_analyseOutModel( true, this, tr( "Analyse OUT"))
|
||||
{
|
||||
m_hpFeqModel.setScaleLogarithmic( true );
|
||||
m_lowShelfFreqModel.setScaleLogarithmic( true );
|
||||
@@ -93,9 +95,6 @@ EqControls::EqControls( EqEffect *effect ) :
|
||||
m_para4PeakL = 0; m_para4PeakR = 0;
|
||||
m_highShelfPeakL = 0; m_highShelfPeakR = 0;
|
||||
m_inProgress = false;
|
||||
m_analyseIn = true;
|
||||
m_analyseOut = true;
|
||||
|
||||
m_inGainModel.setScaleLogarithmic( true );
|
||||
}
|
||||
|
||||
@@ -144,6 +143,8 @@ void EqControls::loadSettings( const QDomElement &_this )
|
||||
m_hp48Model.loadSettings( _this , "HP48" );
|
||||
m_lpTypeModel.loadSettings( _this, "LP" );
|
||||
m_hpTypeModel.loadSettings( _this, "HP" );
|
||||
m_analyseInModel.loadSettings( _this, "AnalyseIn");
|
||||
m_analyseOutModel.loadSettings( _this, "AnalyseOut");
|
||||
}
|
||||
|
||||
|
||||
@@ -192,5 +193,7 @@ void EqControls::saveSettings( QDomDocument &doc, QDomElement &parent )
|
||||
m_hp48Model.saveSettings( doc, parent, "HP48" );
|
||||
m_lpTypeModel.saveSettings( doc, parent, "LP" );
|
||||
m_hpTypeModel.saveSettings( doc, parent, "HP" );
|
||||
m_analyseInModel.saveSettings( doc, parent, "AnalyseIn");
|
||||
m_analyseOutModel.saveSettings( doc, parent, "AnalyseOut");
|
||||
}
|
||||
|
||||
|
||||
@@ -41,16 +41,21 @@ public:
|
||||
virtual ~EqControls()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void saveSettings ( QDomDocument& doc, QDomElement& parent );
|
||||
|
||||
virtual void loadSettings ( const QDomElement &_this );
|
||||
|
||||
inline virtual QString nodeName() const
|
||||
{
|
||||
return "Eq";
|
||||
}
|
||||
|
||||
virtual int controlCount()
|
||||
{
|
||||
return 39;
|
||||
}
|
||||
|
||||
virtual EffectControlDialog* createView()
|
||||
{
|
||||
return new EqControlsDialog( this );
|
||||
@@ -66,20 +71,13 @@ public:
|
||||
float m_para3PeakL, m_para3PeakR;
|
||||
float m_para4PeakL, m_para4PeakR;
|
||||
float m_highShelfPeakL, m_highShelfPeakR;
|
||||
bool m_analyseIn;
|
||||
bool m_analyseOut;
|
||||
|
||||
EqAnalyser m_inFftBands;
|
||||
EqAnalyser m_outFftBands;
|
||||
|
||||
bool m_inProgress;
|
||||
|
||||
bool visable();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
EqEffect* m_effect;
|
||||
|
||||
@@ -130,9 +128,10 @@ private:
|
||||
IntModel m_lpTypeModel;
|
||||
IntModel m_hpTypeModel;
|
||||
|
||||
BoolModel m_analyseInModel;
|
||||
BoolModel m_analyseOutModel;
|
||||
|
||||
friend class EqControlsDialog;
|
||||
friend class EqEffect;
|
||||
|
||||
};
|
||||
|
||||
#endif // EQCONTROLS_H
|
||||
|
||||
@@ -30,12 +30,10 @@
|
||||
#include "EqFader.h"
|
||||
#include "Engine.h"
|
||||
#include "AutomatableButton.h"
|
||||
#include "QWidget"
|
||||
#include "MainWindow.h"
|
||||
#include "LedCheckbox.h"
|
||||
|
||||
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QLayout>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
EqControlsDialog::EqControlsDialog( EqControls *controls ) :
|
||||
@@ -45,113 +43,223 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
|
||||
m_controls = controls;
|
||||
setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
|
||||
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "EqLayout1BG" ) );
|
||||
setPalette( pal );
|
||||
setFixedSize( 350, 275 );
|
||||
m_inSpec = new EqSpectrumView( &controls->m_inFftBands, this);
|
||||
m_inSpec->move( 51, 2 );
|
||||
setFixedSize( 500, 500 );
|
||||
QGridLayout * mainLayout = new QGridLayout( this );
|
||||
|
||||
m_inSpec = new EqSpectrumView( &controls->m_inFftBands, this );
|
||||
mainLayout->addWidget( m_inSpec, 0, 1, 1, 8 );
|
||||
m_inSpec->color = QColor( 238, 154, 120, 80 );
|
||||
m_outSpec = new EqSpectrumView( &controls->m_outFftBands, this);
|
||||
m_outSpec->move( 51, 2 );
|
||||
m_outSpec->color = QColor(145, 205, 22, 80);
|
||||
|
||||
m_outSpec = new EqSpectrumView( &controls->m_outFftBands, this );
|
||||
m_outSpec->color = QColor( 145, 205, 22, 80 );
|
||||
mainLayout->addWidget( m_outSpec, 0, 1, 1, 8 );
|
||||
|
||||
m_parameterWidget = new EqParameterWidget( this , controls );
|
||||
m_parameterWidget->move( 51, 2 );
|
||||
mainLayout->addWidget( m_parameterWidget, 0, 1, 1, 8 );
|
||||
|
||||
setBand( 0, &controls->m_hpActiveModel, &controls->m_hpFeqModel, &controls->m_hpResModel, 0, QColor(255 ,255, 255), tr( "HP" ) ,0,0);
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0);
|
||||
int cw = width()/8; //the chanel width in pixels
|
||||
int ko = ( cw * 0.5 ) - ((new Knob( knobBright_26, 0 ))->width() * 0.5 );
|
||||
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);
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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);
|
||||
|
||||
m_inGainFader = new EqFader( &controls->m_inGainModel, tr( "In Gain" ), this, &controls->m_inPeakL, &controls->m_inPeakR);
|
||||
m_inGainFader->move( 10, 5 );
|
||||
m_inGainFader = new EqFader( &controls->m_inGainModel, tr( "In Gain" ), this,
|
||||
&controls->m_inPeakL, &controls->m_inPeakR );
|
||||
|
||||
mainLayout->addWidget( m_inGainFader, 0, 0 );
|
||||
m_inGainFader->setDisplayConversion( false );
|
||||
m_inGainFader->setHintText( tr( "Gain" ), "dBv");
|
||||
|
||||
|
||||
|
||||
m_outGainFader = new EqFader( &controls->m_outGainModel, tr( "Out Gain" ), this, &controls->m_outPeakL, &controls->m_outPeakR );
|
||||
m_outGainFader->move( 315, 5 );
|
||||
m_outGainFader = new EqFader( &controls->m_outGainModel, tr( "Out Gain" ), this,
|
||||
&controls->m_outPeakL, &controls->m_outPeakR );
|
||||
mainLayout->addWidget( m_outGainFader, 0, 9 );
|
||||
m_outGainFader->setDisplayConversion( false );
|
||||
m_outGainFader->setHintText( tr( "Gain" ), "dBv");
|
||||
//gain faders
|
||||
m_outGainFader->setHintText( tr( "Gain" ), "dBv" );
|
||||
|
||||
int fo = (cw * 0.5) - (m_outGainFader->width() * 0.5 );
|
||||
|
||||
for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++)
|
||||
// Gain Fader for each Filter exepts the pass filter
|
||||
for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ )
|
||||
{
|
||||
m_gainFader = new EqFader( m_parameterWidget->getBandModels(i)->gain, tr( "" ), this ,m_parameterWidget->getBandModels( i )->peakL, m_parameterWidget->getBandModels( i )->peakR );
|
||||
m_gainFader->move( cw * i + fo , 123 );
|
||||
m_gainFader = new EqFader( m_parameterWidget->getBandModels( i )->gain, tr( "" ), this,
|
||||
m_parameterWidget->getBandModels( i )->peakL, m_parameterWidget->getBandModels( i )->peakR );
|
||||
mainLayout->addWidget( m_gainFader, 2, i+1 );
|
||||
mainLayout->setAlignment( m_gainFader, Qt::AlignHCenter );
|
||||
m_gainFader->setMinimumHeight(80);
|
||||
m_gainFader->resize(m_gainFader->width() , 80);
|
||||
m_gainFader->setDisplayConversion( false );
|
||||
m_gainFader->setHintText( tr( "Gain") , "dB");
|
||||
}
|
||||
|
||||
for( int i = 0; i < m_parameterWidget->bandCount() ; i++)
|
||||
|
||||
//Control Button and Knobs for each Band
|
||||
for( int i = 0; i < m_parameterWidget->bandCount() ; i++ )
|
||||
{
|
||||
m_resKnob = new Knob( knobBright_26, this );
|
||||
if(i ==0 || i == 7)
|
||||
{
|
||||
m_resKnob->move( cw * i + ko , 190 );
|
||||
} else
|
||||
{
|
||||
m_resKnob->move( cw * i + ko , 205 );
|
||||
}
|
||||
mainLayout->setRowMinimumHeight( 4, 33 );
|
||||
mainLayout->addWidget( m_resKnob, 5, i+1 );
|
||||
mainLayout->setAlignment( m_resKnob, Qt::AlignHCenter );
|
||||
m_resKnob->setVolumeKnob(false);
|
||||
m_resKnob->setModel( m_parameterWidget->getBandModels( i )->res );
|
||||
if(i > 1 && i < 6) { m_resKnob->setHintText( tr( "Bandwidth: " ) , " Octave" ); }
|
||||
else { m_resKnob->setHintText( tr( "Resonance : " ) , "" ); }
|
||||
|
||||
m_freqKnob = new Knob( knobBright_26, this );
|
||||
if( i == 0 || i == 7 )
|
||||
{
|
||||
m_freqKnob->move( cw * i + ko, 222 );
|
||||
} else
|
||||
{
|
||||
m_freqKnob->move(cw * i + ko, 235 );
|
||||
}
|
||||
mainLayout->addWidget( m_freqKnob, 3, i+1 );
|
||||
mainLayout->setAlignment( m_freqKnob, Qt::AlignHCenter );
|
||||
m_freqKnob->setVolumeKnob( false );
|
||||
m_freqKnob->setModel( m_parameterWidget->getBandModels( i )->freq );
|
||||
m_freqKnob->setHintText( tr( "Frequency:" ), "Hz" );
|
||||
|
||||
m_activeBox = new LedCheckBox( m_parameterWidget->getBandModels( i )->name , this , "" , LedCheckBox::Green );
|
||||
m_activeBox->move( cw * i + fo + 3, 260 );
|
||||
// adds the Number Active buttons
|
||||
m_activeBox = new PixmapButton( this, NULL );
|
||||
m_activeBox->setCheckable(true);
|
||||
m_activeBox->setModel( m_parameterWidget->getBandModels( i )->active );
|
||||
|
||||
QString iconActiveFileName = "bandLabel" + QString::number(i+1) + "on";
|
||||
QString iconInactiveFileName = "bandLabel" + QString::number(i+1);
|
||||
m_activeBox->setActiveGraphic( PLUGIN_NAME::getIconPixmap( iconActiveFileName.toLatin1() ) );
|
||||
m_activeBox->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( iconInactiveFileName.toLatin1() ) );
|
||||
|
||||
mainLayout->addWidget( m_activeBox, 1, i+1 );
|
||||
mainLayout->setAlignment( m_activeBox, Qt::AlignHCenter );
|
||||
m_activeBox->setModel( m_parameterWidget->getBandModels( i )->active );
|
||||
|
||||
// adds the symbols active buttons
|
||||
m_activeBox = new PixmapButton( this, NULL );
|
||||
m_activeBox->setCheckable(true);
|
||||
m_activeBox->setModel( m_parameterWidget->getBandModels( i )->active );
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
m_activeBox->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveHP" ) );
|
||||
m_activeBox->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveHPoff" ) );
|
||||
break;
|
||||
case 1:
|
||||
m_activeBox->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveLS" ) );
|
||||
m_activeBox->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveLSoff" ) );
|
||||
break;
|
||||
case 6:
|
||||
m_activeBox->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveHS" ) );
|
||||
m_activeBox->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveHSoff" ) );
|
||||
break;
|
||||
case 7:
|
||||
m_activeBox->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveLP" ) );
|
||||
m_activeBox->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "ActiveLPoff" ) );
|
||||
break;
|
||||
default:
|
||||
m_activeBox->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "ActivePeak" ) );
|
||||
m_activeBox->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "ActivePeakoff" ) );
|
||||
}
|
||||
|
||||
mainLayout->addWidget( m_activeBox, 7, i+1 );
|
||||
mainLayout->setAlignment( m_activeBox, Qt::AlignHCenter);
|
||||
m_activeBox->setModel( m_parameterWidget->getBandModels( i )->active );
|
||||
|
||||
// Connects the knobs, Faders and buttons with the curve graphic
|
||||
QObject::connect( m_parameterWidget->getBandModels( i )->freq , SIGNAL( dataChanged() ), m_parameterWidget, SLOT ( updateView() ) );
|
||||
if ( m_parameterWidget->getBandModels( i )->gain ) QObject::connect( m_parameterWidget->getBandModels( i )->gain, SIGNAL( dataChanged() ), m_parameterWidget, SLOT ( updateView() ));
|
||||
QObject::connect( m_parameterWidget->getBandModels( i )->res, SIGNAL( dataChanged() ), m_parameterWidget , SLOT ( updateView() ) );
|
||||
QObject::connect( m_parameterWidget->getBandModels( i )->active, SIGNAL( dataChanged() ), m_parameterWidget , SLOT ( updateView() ) );
|
||||
|
||||
m_parameterWidget->changeHandle( i );
|
||||
}
|
||||
|
||||
|
||||
// adds the buttons for Spectrum analyser on/off
|
||||
m_inSpecB = new PixmapButton(this, NULL);
|
||||
m_inSpecB->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"ActiveAnalyse" ) );
|
||||
m_inSpecB->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"ActiveAnalyseoff" ) );
|
||||
m_inSpecB->setCheckable(true);
|
||||
m_inSpecB->setModel( &controls->m_analyseInModel );
|
||||
|
||||
m_outSpecB = new PixmapButton(this, NULL);
|
||||
m_outSpecB->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"ActiveAnalyse" ) );
|
||||
m_outSpecB->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"ActiveAnalyseoff" ) );
|
||||
m_outSpecB->setCheckable(true);
|
||||
m_outSpecB->setModel( &controls->m_analyseOutModel );
|
||||
mainLayout->addWidget( m_inSpecB, 1, 0 );
|
||||
mainLayout->addWidget( m_outSpecB, 1, 9 );
|
||||
mainLayout->setAlignment( m_inSpecB, Qt::AlignHCenter );
|
||||
mainLayout->setAlignment( m_outSpecB, Qt::AlignHCenter );
|
||||
|
||||
//hp filter type
|
||||
m_hp12Box = new PixmapButton( this , NULL );
|
||||
m_hp12Box->setModel( m_parameterWidget->getBandModels( 0 )->hp12 );
|
||||
m_hp12Box->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"12dB" ) );
|
||||
m_hp12Box->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"12dBoff" ) );
|
||||
|
||||
m_hp12Box = new LedCheckBox( tr( "12dB" ), this , "" , LedCheckBox::Green );
|
||||
m_hp12Box->move( cw*0 + ko, 170 );
|
||||
m_hp12Box->setModel( &controls->m_hp12Model );
|
||||
m_hp24Box = new LedCheckBox( tr( "24dB" ), this , "" , LedCheckBox::Green );
|
||||
m_hp24Box->move( cw*0 + ko, 150 );
|
||||
m_hp24Box->setModel( &controls->m_hp24Model );
|
||||
m_hp24Box = new PixmapButton( this , NULL );
|
||||
m_hp24Box->setModel(m_parameterWidget->getBandModels( 0 )->hp24 );
|
||||
|
||||
m_hp48Box = new LedCheckBox( tr( "48dB" ), this , "" , LedCheckBox::Green );
|
||||
m_hp48Box->move( cw*0 + ko, 130 );
|
||||
m_hp48Box->setModel( &controls->m_hp48Model );
|
||||
|
||||
m_hp24Box->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"24dB" ) );
|
||||
m_hp24Box->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"24dBoff" ) );
|
||||
|
||||
m_hp48Box = new PixmapButton( this , NULL );
|
||||
m_hp48Box->setModel( m_parameterWidget->getBandModels(0)->hp48 );
|
||||
|
||||
m_hp48Box->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"48dB" ) );
|
||||
m_hp48Box->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"48dBoff" ) );
|
||||
|
||||
//LP filter type
|
||||
m_lp12Box = new PixmapButton( this , NULL );
|
||||
mainLayout->addWidget( m_lp12Box, 2,1 );
|
||||
m_lp12Box->setModel( m_parameterWidget->getBandModels( 7 )->lp12 );
|
||||
m_lp12Box->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"12dB" ) );
|
||||
m_lp12Box->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"12dBoff" ) );
|
||||
|
||||
m_lp12Box = new LedCheckBox( tr( "12dB"), this , "" , LedCheckBox::Green );
|
||||
m_lp12Box->move( cw*7 + ko -5 , 170 );
|
||||
m_lp12Box->setModel( &controls->m_lp12Model );
|
||||
m_lp24Box = new LedCheckBox( tr( "24dB"), this , "" , LedCheckBox::Green );
|
||||
m_lp24Box->move( cw*7 + ko - 5, 150 );
|
||||
m_lp24Box->setModel( &controls->m_lp24Model );
|
||||
m_lp48Box = new LedCheckBox( tr( "48dB"), this , "" , LedCheckBox::Green );
|
||||
m_lp48Box->move( cw*7 + ko - 5, 130 );
|
||||
m_lp48Box->setModel( &controls->m_lp48Model );
|
||||
m_lp24Box = new PixmapButton( this , NULL );
|
||||
m_lp24Box->setModel( m_parameterWidget->getBandModels( 7 )->lp24 );
|
||||
m_lp24Box->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"24dB" ) );
|
||||
m_lp24Box->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"24dBoff" ) );
|
||||
|
||||
m_lp48Box = new PixmapButton( this , NULL );
|
||||
m_lp48Box->setModel( m_parameterWidget->getBandModels( 7 )->lp48 );
|
||||
m_lp48Box->setActiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"48dB" ) );
|
||||
m_lp48Box->setInactiveGraphic( PLUGIN_NAME::getIconPixmap(
|
||||
"48dBoff" ) );
|
||||
// the curve has to change its appearance
|
||||
QObject::connect( m_parameterWidget->getBandModels( 0 )->hp12 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateView()));
|
||||
QObject::connect( m_parameterWidget->getBandModels( 0 )->hp24 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateView()));
|
||||
QObject::connect( m_parameterWidget->getBandModels( 0 )->hp48 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateView()));
|
||||
|
||||
QObject::connect( m_parameterWidget->getBandModels( 7 )->lp12 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateView()));
|
||||
QObject::connect( m_parameterWidget->getBandModels( 7 )->lp24 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateView()));
|
||||
QObject::connect( m_parameterWidget->getBandModels( 7 )->lp48 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateView()));
|
||||
|
||||
QVBoxLayout * hpGrpBtnLayout = new QVBoxLayout;
|
||||
hpGrpBtnLayout->addWidget( m_hp12Box );
|
||||
hpGrpBtnLayout->addWidget( m_hp24Box );
|
||||
hpGrpBtnLayout->addWidget( m_hp48Box );
|
||||
|
||||
QVBoxLayout * lpGrpBtnLayout = new QVBoxLayout;
|
||||
lpGrpBtnLayout->addWidget( m_lp12Box );
|
||||
lpGrpBtnLayout->addWidget( m_lp24Box );
|
||||
lpGrpBtnLayout->addWidget( m_lp48Box );
|
||||
|
||||
mainLayout->addLayout( hpGrpBtnLayout, 2, 1, Qt::AlignCenter );
|
||||
mainLayout->addLayout( lpGrpBtnLayout, 2, 8, Qt::AlignCenter );
|
||||
|
||||
automatableButtonGroup *lpBtnGrp = new automatableButtonGroup(this,tr ( "lp grp" ) );
|
||||
lpBtnGrp->addButton( m_lp12Box);
|
||||
lpBtnGrp->addButton( m_lp12Box );
|
||||
lpBtnGrp->addButton( m_lp24Box );
|
||||
lpBtnGrp->addButton( m_lp48Box );
|
||||
lpBtnGrp->setModel( &m_controls->m_lpTypeModel, false);
|
||||
@@ -162,11 +270,46 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
|
||||
hpBtnGrp->addButton( m_hp48Box );
|
||||
hpBtnGrp->setModel( &m_controls->m_hpTypeModel,false);
|
||||
|
||||
mainLayout->setAlignment( Qt::AlignTop );
|
||||
for (int i = 0 ; i < 10; i++)
|
||||
{
|
||||
mainLayout->setColumnMinimumWidth(i, 50);
|
||||
}
|
||||
|
||||
mainLayout->setAlignment( m_inGainFader, Qt::AlignHCenter );
|
||||
mainLayout->setAlignment( m_outGainFader, Qt::AlignHCenter );
|
||||
mainLayout->setRowMinimumHeight( 0,200 );
|
||||
mainLayout->setRowMinimumHeight( 1, 40 );
|
||||
mainLayout->setRowMinimumHeight(6,15);
|
||||
mainLayout->setContentsMargins( 0, 11, 0, 0 );
|
||||
mainLayout->setAlignment(m_inSpec, Qt::AlignCenter );
|
||||
mainLayout->setAlignment(m_outSpec, Qt::AlignCenter );
|
||||
|
||||
m_freqLabel = new QLabel(this);
|
||||
m_freqLabel->setText("- " + tr( "Frequency")+ " -" );
|
||||
m_freqLabel->move( 217 , 377 );
|
||||
|
||||
m_resLabel1 = new QLabel(this);
|
||||
m_resLabel1->setText("- " + tr( "Resonance")+ " -" );
|
||||
m_resLabel1->move( 62 , 444 );
|
||||
|
||||
m_resLabel2 = new QLabel(this);
|
||||
m_resLabel2->setText("- " + tr( "Resonance")+ " -" );
|
||||
m_resLabel2->move( 365 , 444 );
|
||||
|
||||
m_bandWidthLabel = new QLabel(this);
|
||||
m_bandWidthLabel->setText("- " + tr( "Bandwidth")+ " -" );
|
||||
m_bandWidthLabel->move( 215 , 444 );
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqControlsDialog::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
m_originalHeight = parentWidget()->height() == 150 ? m_originalHeight : parentWidget()->height() ;
|
||||
parentWidget()->setFixedHeight( parentWidget()->height() == m_originalHeight ? 150 : m_originalHeight );
|
||||
m_originalHeight = parentWidget()->height() == 283 ? m_originalHeight : parentWidget()->height() ;
|
||||
parentWidget()->setFixedHeight( parentWidget()->height() == m_originalHeight ? 283 : m_originalHeight );
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -31,8 +31,11 @@
|
||||
#include "LedCheckbox.h"
|
||||
#include "EqParameterWidget.h"
|
||||
#include "MainWindow.h"
|
||||
#include "qpushbutton.h"
|
||||
#include "EqSpectrumView.h"
|
||||
#include "PixmapButton.h"
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
|
||||
class EqControls;
|
||||
@@ -50,27 +53,33 @@ public:
|
||||
|
||||
private:
|
||||
EqControls * m_controls;
|
||||
|
||||
Fader* m_inGainFader;
|
||||
Fader* m_outGainFader;
|
||||
Fader* m_gainFader;
|
||||
Knob* m_resKnob;
|
||||
Knob* m_freqKnob;
|
||||
LedCheckBox* m_activeBox;
|
||||
LedCheckBox* m_lp12Box;
|
||||
LedCheckBox* m_lp24Box;
|
||||
LedCheckBox* m_lp48Box;
|
||||
LedCheckBox* m_hp12Box;
|
||||
LedCheckBox* m_hp24Box;
|
||||
LedCheckBox* m_hp48Box;
|
||||
PixmapButton* m_inSpecB;
|
||||
PixmapButton* m_outSpecB;
|
||||
PixmapButton* m_activeBox;
|
||||
PixmapButton* m_lp12Box;
|
||||
PixmapButton* m_lp24Box;
|
||||
PixmapButton* m_lp48Box;
|
||||
PixmapButton* m_hp12Box;
|
||||
PixmapButton* m_hp24Box;
|
||||
PixmapButton* m_hp48Box;
|
||||
LedCheckBox* m_analyzeBox;
|
||||
EqParameterWidget* m_parameterWidget;
|
||||
EqSpectrumView* m_inSpec;
|
||||
EqSpectrumView* m_outSpec;
|
||||
QLabel* m_freqLabel;
|
||||
QLabel* m_resLabel1;
|
||||
QLabel* m_resLabel2;
|
||||
QLabel* m_bandWidthLabel;
|
||||
|
||||
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
|
||||
EqBand* setBand( int index, BoolModel* active, FloatModel* freq, FloatModel* res, FloatModel* gain, QColor color, QString name, float* peakL, float* peakR)
|
||||
EqBand* 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 )
|
||||
{
|
||||
EqBand* filterModels = m_parameterWidget->getBandModels( index );
|
||||
filterModels->active = active;
|
||||
@@ -80,10 +89,17 @@ private:
|
||||
filterModels->gain = gain;
|
||||
filterModels->peakL = peakL;
|
||||
filterModels->peakR = peakR;
|
||||
filterModels->hp12 = hp12;
|
||||
filterModels->hp24 = hp24;
|
||||
filterModels->hp48 = hp48;
|
||||
filterModels->lp12 = lp12;
|
||||
filterModels->lp24 = lp24;
|
||||
filterModels->lp48 = lp48;
|
||||
return filterModels;
|
||||
}
|
||||
|
||||
int m_originalHeight;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
818
plugins/Eq/EqCurve.cpp
Normal file
@@ -0,0 +1,818 @@
|
||||
/*
|
||||
* EqCurve.cpp - declaration of EqCurve and EqHandle classes.
|
||||
*
|
||||
* Copyright (c) 2015 Steffen Baranowsky <BaraMGB/at/freenet/dot/de>
|
||||
*
|
||||
* This file is part of LMMS - http://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EqCurve.h"
|
||||
#include "lmms_math.h"
|
||||
#include "Effect.h"
|
||||
#include "embed.h"
|
||||
|
||||
EqHandle::EqHandle( int num, int x, int y )
|
||||
{
|
||||
PI = LD_PI;
|
||||
m_numb = num;
|
||||
setMouseHover( false );
|
||||
m_width = x;
|
||||
m_heigth = y;
|
||||
m_mousePressed = false;
|
||||
m_active = false;
|
||||
setFlag( ItemIsMovable );
|
||||
setFlag( ItemSendsGeometryChanges );
|
||||
setAcceptHoverEvents( true );
|
||||
float totalHeight = 36;
|
||||
m_pixelsPerUnitHeight = ( m_heigth ) / ( totalHeight );
|
||||
m_handleMoved = false;
|
||||
QObject::connect( this,SIGNAL( positionChanged() ) , this, SLOT( handleMoved() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QRectF EqHandle::boundingRect() const
|
||||
{
|
||||
return QRectF( -11, -11, 23, 23 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::handleMoved()
|
||||
{
|
||||
m_handleMoved = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
|
||||
{
|
||||
painter->setRenderHint( QPainter::Antialiasing, true) ;
|
||||
if ( m_mousePressed )
|
||||
{
|
||||
emit positionChanged();
|
||||
|
||||
}
|
||||
|
||||
// graphics for the handles
|
||||
QString fileName = "handle" + QString::number(m_numb+1);
|
||||
if ( !isActiveHandle() ) { fileName = fileName + "inactive"; }
|
||||
QPixmap circlePixmap = PLUGIN_NAME::getIconPixmap( fileName.toLatin1() );
|
||||
painter->drawPixmap( -12, -12, circlePixmap );
|
||||
|
||||
// on mouse hover draw an info box and change the pixmap of the handle
|
||||
if ( isMouseHover() )
|
||||
{
|
||||
// keeps the info box in view
|
||||
float rectX = -40;
|
||||
float rectY = -40;
|
||||
if ( EqHandle::y() < 40 )
|
||||
{
|
||||
rectY = rectY + 40 - EqHandle::y();
|
||||
}
|
||||
if ( EqHandle::x() < 40 )
|
||||
{
|
||||
rectX = rectX + 40 - EqHandle::x();
|
||||
}
|
||||
if ( EqHandle::x() > m_width - 40 )
|
||||
{
|
||||
rectX = rectX - (40 - (m_width - EqHandle::x() ) );
|
||||
}
|
||||
|
||||
painter->drawPixmap( -12, -12, PLUGIN_NAME::getIconPixmap( "handlehover" ) );
|
||||
QRectF textRect = QRectF ( rectX, rectY, 80, 30 );
|
||||
QRectF textRect2 = QRectF ( rectX+1, rectY+1, 80, 30 );
|
||||
QString freq = QString::number( xPixelToFreq(EqHandle::x() )) ;
|
||||
QString res;
|
||||
if ( getType() < 3 || getType() > 3 )
|
||||
{
|
||||
res = tr( "Reso: ") + QString::number( getResonance() );
|
||||
}
|
||||
else
|
||||
{
|
||||
res = tr( "BW: " ) + QString::number( getResonance() );
|
||||
}
|
||||
|
||||
painter->setPen( QColor( 255, 255, 255 ) );
|
||||
painter->drawRect( textRect );
|
||||
painter->fillRect( textRect, QBrush( QColor( 128, 128, 255 , 64 ) ) );
|
||||
|
||||
painter->setPen ( QColor( 0, 0, 0 ) );
|
||||
painter->drawText( textRect2, Qt::AlignCenter,
|
||||
QString( tr( "Freq: " ) + freq + "\n" + res ) );
|
||||
painter->setPen( QColor( 255, 255, 255 ) );
|
||||
painter->drawText( textRect, Qt::AlignCenter,
|
||||
QString( tr( "Freq: " ) + freq + "\n" + res ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QPainterPath EqHandle::getCurvePath()
|
||||
{
|
||||
QPainterPath path;
|
||||
float y = m_heigth*0.5;
|
||||
for ( float x=0 ; x < m_width; x++ )
|
||||
{
|
||||
if ( m_type == 1 ) y = getLowCutCurve( x );
|
||||
if ( m_type == 2 ) y = getLowShelfCurve( x );
|
||||
if ( m_type == 3 ) y = getPeakCurve( x );
|
||||
if ( m_type == 4 ) y = getHighShelfCurve( x );
|
||||
if ( m_type == 5 ) y = getHighCutCurve( x );
|
||||
if ( x==0 ) path.moveTo( x, y ); // sets the begin of Path
|
||||
path.lineTo( x, y );
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float EqHandle::getPeakCurve(float x)
|
||||
{
|
||||
double freqZ = xPixelToFreq( EqHandle::x() );
|
||||
const int SR = Engine::mixer()->processingSampleRate();
|
||||
double w0 = 2* PI * freqZ / SR ;
|
||||
double c = cosf( w0 );
|
||||
double s = sinf( w0 );
|
||||
double Q = getResonance();
|
||||
double A = pow( 10, yPixelToGain(EqHandle::y()) / 40 );
|
||||
double alpha = s * sinh( log( 2 ) / 2 * Q * w0 / sinf( w0 ) );
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = 1 + alpha*A;
|
||||
b1 = -2*c;
|
||||
b2 = 1 - alpha*A;
|
||||
a0 = 1 + alpha/A;
|
||||
a1 = -2*c;
|
||||
a2 = 1 - alpha/A;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
b2 /= a0;
|
||||
a1 /= a0;
|
||||
a2 /= a0;
|
||||
a0 = 1;
|
||||
|
||||
double w;
|
||||
double PHI;
|
||||
double gain;
|
||||
double freq = xPixelToFreq( x );
|
||||
w = 2*PI * freq / SR;
|
||||
PHI = pow( sin( w/2 ), 2 )*4;
|
||||
gain = 10* log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1*(b0+b2 )+ 4*b0*b2 ) ) *PHI )
|
||||
- 10*log10( pow( 1+ a1+ a2 ,2 ) + ( 1* a2 * PHI - ( a1 * ( 1+ a2 ) +4 *1 * a2 ) ) *PHI );
|
||||
float y= gainToYPixel( gain );
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float EqHandle::getHighShelfCurve( float x )
|
||||
{
|
||||
double freqZ = xPixelToFreq( EqHandle::x() );
|
||||
const int SR = Engine::mixer()->processingSampleRate();
|
||||
double w0 = 2 * PI * freqZ / SR;
|
||||
double c = cosf( w0 );
|
||||
double s = sinf( w0 );
|
||||
double A = pow( 10, yPixelToGain( EqHandle::y() ) * 0.025 );
|
||||
double beta = sqrt( A ) / m_resonance;
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = A *( ( A +1 ) + ( A - 1 ) * c + beta * s);
|
||||
b1 = -2 * A * ( ( A - 1 ) + ( A + 1 ) * c );
|
||||
b2 = A * ( ( A + 1 ) + ( A - 1 ) * c - beta * s);
|
||||
a0 = ( A + 1 ) - ( A - 1 ) * c + beta * s;
|
||||
a1 = 2 * ( ( A - 1 ) - ( A + 1 ) * c );
|
||||
a2 = ( A + 1) - ( A - 1 ) * c - beta * s;
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
b2 /= a0;
|
||||
a1 /= a0;
|
||||
a2 /= a0;
|
||||
a0 = 1;
|
||||
|
||||
double w;
|
||||
double PHI;
|
||||
double gain;
|
||||
double freq = xPixelToFreq( x );
|
||||
w = 2* PI * freq / SR ;
|
||||
PHI = pow(sin( w/2 ), 2 ) * 4;
|
||||
gain = 10* log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1*( b0+b2 )+ 4*b0*b2 ) ) *PHI )
|
||||
- 10*log10( pow(1+ a1+ a2 ,2 ) + ( 1* a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2) ) *PHI );
|
||||
float y= gainToYPixel( gain );
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float EqHandle::getLowShelfCurve( float x )
|
||||
{
|
||||
double freqZ = xPixelToFreq( EqHandle::x() );
|
||||
const int SR = Engine::mixer()->processingSampleRate();
|
||||
double w0 = 2 * PI * freqZ / SR ;
|
||||
double c = cosf( w0 );
|
||||
double s = sinf( w0 );
|
||||
double A = pow( 10, yPixelToGain( EqHandle::y() ) / 40 );
|
||||
double beta = sqrt( A ) / m_resonance;
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
b0 = A * ( ( A+1 ) - ( A-1 ) * c + beta * s );
|
||||
b1 = 2 * A * ( ( A - 1 ) - ( A + 1 ) * c) ;
|
||||
b2 = A * ( ( A + 1 ) - ( A - 1 ) * c - beta * s);
|
||||
a0 = ( A + 1 ) + ( A - 1 ) * c + beta * s;
|
||||
a1 = -2 * ( ( A - 1 ) + ( A + 1 ) * c );
|
||||
a2 = ( A + 1 ) + ( A - 1) * c - beta * s;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
b2 /= a0;
|
||||
a1 /= a0;
|
||||
a2 /= a0;
|
||||
a0 = 1;
|
||||
|
||||
double w;
|
||||
double PHI;
|
||||
double gain;
|
||||
double freq = xPixelToFreq( x );
|
||||
w = 2* PI * freq / SR ;
|
||||
PHI = pow( sin( w/2 ), 2 ) * 4;
|
||||
gain = 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0+b2 ) + 4 * b0 * b2 ) ) *PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI );
|
||||
float y= gainToYPixel( gain );
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float EqHandle::getLowCutCurve( float x )
|
||||
{
|
||||
double freqZ = xPixelToFreq( EqHandle::x() );
|
||||
const int SR = Engine::mixer()->processingSampleRate();
|
||||
double w0 = 2 * PI * freqZ / SR ;
|
||||
double c = cosf( w0 );
|
||||
double s = sinf( w0 );
|
||||
double resonance = getResonance();
|
||||
double A = pow( 10, yPixelToGain( EqHandle::y() ) / 20);
|
||||
double alpha = s / 2 * sqrt ( ( A +1/A ) * ( 1 / resonance -1 ) +2 );
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
b0 = ( 1 + c ) * 0.5;
|
||||
b1 = ( -( 1 + c ) );
|
||||
b2 = ( 1 + c ) * 0.5;
|
||||
a0 = 1 + alpha;
|
||||
a1 = ( -2 * c );
|
||||
a2 = 1 - alpha;
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
b2 /= a0;
|
||||
a1 /= a0;
|
||||
a2 /= a0;
|
||||
a0 = 1;
|
||||
|
||||
double w;
|
||||
double PHI;
|
||||
double gain;
|
||||
double freq = xPixelToFreq( x );
|
||||
w = 2 * PI * freq / SR ;
|
||||
PHI = pow( sin( w/2), 2 ) * 4;
|
||||
gain = 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI );
|
||||
|
||||
if ( m_hp24 )
|
||||
{
|
||||
gain = gain + 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI );
|
||||
|
||||
}
|
||||
|
||||
if ( m_hp48 )
|
||||
{
|
||||
gain = gain + 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI );
|
||||
|
||||
gain = gain + ( 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI ));
|
||||
|
||||
}
|
||||
|
||||
float y= gainToYPixel( gain );
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float EqHandle::getHighCutCurve( float x )
|
||||
{
|
||||
double freqZ = xPixelToFreq( EqHandle::x() );
|
||||
const int SR = Engine::mixer()->processingSampleRate();
|
||||
double w0 = 2 * PI * freqZ / SR ;
|
||||
double c = cosf( w0 );
|
||||
double s = sinf( w0 );
|
||||
double resonance = getResonance();
|
||||
double A = pow( 10, yPixelToGain(EqHandle::y() ) / 20 );
|
||||
double alpha = s / 2 * sqrt ( ( A + 1 / A ) * ( 1 / resonance -1 ) +2 );
|
||||
double a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
|
||||
b0 = ( 1 - c ) * 0.5;
|
||||
b1 = 1 - c;
|
||||
b2 = ( 1 - c ) * 0.5;
|
||||
a0 = 1 + alpha;
|
||||
a1 = -2 * c;
|
||||
a2 = 1 - alpha;
|
||||
|
||||
//normalise
|
||||
b0 /= a0;
|
||||
b1 /= a0;
|
||||
b2 /= a0;
|
||||
a1 /= a0;
|
||||
a2 /= a0;
|
||||
a0 = 1;
|
||||
|
||||
double w;
|
||||
double PHI;
|
||||
double gain;
|
||||
double freq = xPixelToFreq( x );
|
||||
w = 2 * PI * freq / SR ;
|
||||
PHI = pow(sin( w/2),2 )*4;
|
||||
|
||||
gain = 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI );
|
||||
|
||||
if ( m_lp24 )
|
||||
{
|
||||
gain = gain + ( 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI ) );
|
||||
|
||||
}
|
||||
|
||||
if ( m_lp48 )
|
||||
{
|
||||
gain = gain + ( 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI ) );
|
||||
|
||||
gain = gain + ( 10 * log10( pow( b0 + b1 + b2 , 2 )
|
||||
+ ( b0 * b2 * PHI - ( b1 * ( b0 + b2 ) + 4 * b0 * b2 ) ) * PHI )
|
||||
- 10 * log10( pow( 1 + a1 + a2, 2 ) + ( 1 * a2 * PHI - ( a1 * ( 1 + a2 ) + 4 * 1 * a2 ) ) * PHI ) );
|
||||
}
|
||||
|
||||
|
||||
float y= gainToYPixel( gain );
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float EqHandle::getResonance()
|
||||
{
|
||||
return m_resonance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EqHandle::getNum()
|
||||
{
|
||||
return m_numb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setType(int t)
|
||||
{
|
||||
EqHandle::m_type = t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setResonance(float r)
|
||||
{
|
||||
EqHandle::m_resonance = r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool EqHandle::isMouseHover()
|
||||
{
|
||||
return m_mouseHover;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setMouseHover(bool d)
|
||||
{
|
||||
m_mouseHover = d;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EqHandle::getType()
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool EqHandle::isActiveHandle()
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setHandleActive( bool a )
|
||||
{
|
||||
EqHandle::m_active = a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setHandleMoved( bool a )
|
||||
{
|
||||
m_handleMoved = a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool EqHandle::getHandleMoved()
|
||||
{
|
||||
return m_handleMoved;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::sethp12()
|
||||
{
|
||||
m_hp12 = true;
|
||||
m_hp24 = false;
|
||||
m_hp48 = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::sethp24()
|
||||
{
|
||||
m_hp12 = false;
|
||||
m_hp24 = true;
|
||||
m_hp48 = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::sethp48()
|
||||
{
|
||||
m_hp12 = false;
|
||||
m_hp24 = false;
|
||||
m_hp48 = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setlp12()
|
||||
{
|
||||
m_lp12 = true;
|
||||
m_lp24 = false;
|
||||
m_lp48 = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setlp24()
|
||||
{
|
||||
m_lp12 = false;
|
||||
m_lp24 = true;
|
||||
m_lp48 = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::setlp48()
|
||||
{
|
||||
m_lp12 = false;
|
||||
m_lp24 = false;
|
||||
m_lp48 = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::mousePressEvent( QGraphicsSceneMouseEvent *event )
|
||||
{
|
||||
m_mousePressed = true;
|
||||
QGraphicsItem::mousePressEvent( event );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
|
||||
{
|
||||
m_mousePressed = false;
|
||||
QGraphicsItem::mouseReleaseEvent( event );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::wheelEvent( QGraphicsSceneWheelEvent *wevent )
|
||||
{
|
||||
float highestBandwich;
|
||||
if ( m_type < 3 || m_type > 3 )
|
||||
{
|
||||
highestBandwich = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
highestBandwich = 4;
|
||||
}
|
||||
|
||||
int numDegrees = wevent->delta() / 120;
|
||||
float numSteps = 0;
|
||||
if ( wevent->modifiers() == Qt::ControlModifier )
|
||||
{
|
||||
numSteps = numDegrees * 0.01;
|
||||
}
|
||||
else
|
||||
{
|
||||
numSteps = numDegrees * 0.15;
|
||||
}
|
||||
|
||||
if ( wevent->orientation() == Qt::Vertical )
|
||||
{
|
||||
m_resonance = m_resonance + ( numSteps );
|
||||
|
||||
if ( m_resonance < 0.1 )
|
||||
{
|
||||
m_resonance = 0.1;
|
||||
}
|
||||
|
||||
if ( m_resonance > highestBandwich )
|
||||
{
|
||||
m_resonance = highestBandwich;
|
||||
}
|
||||
emit positionChanged();
|
||||
}
|
||||
wevent->accept();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::hoverEnterEvent( QGraphicsSceneHoverEvent *hevent )
|
||||
{
|
||||
setMouseHover( true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqHandle::hoverLeaveEvent( QGraphicsSceneHoverEvent *hevent )
|
||||
{
|
||||
setMouseHover( false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QVariant EqHandle::itemChange( QGraphicsItem::GraphicsItemChange change, const QVariant &value )
|
||||
{
|
||||
if ( change == ItemPositionChange )
|
||||
{
|
||||
// pass filter don't move in y direction
|
||||
if ( EqHandle::m_type == 1 || EqHandle::m_type == 5 )
|
||||
{
|
||||
float newX = value.toPointF().x();
|
||||
if ( newX < 0 )
|
||||
{
|
||||
newX = 0;
|
||||
}
|
||||
if ( newX > m_width )
|
||||
{
|
||||
newX = m_width;
|
||||
}
|
||||
return QPointF(newX, m_heigth/2);
|
||||
}
|
||||
}
|
||||
|
||||
QPointF newPos = value.toPointF();
|
||||
QRectF rect = QRectF( 0, 0, m_width, m_heigth );
|
||||
if ( !rect.contains( newPos ) )
|
||||
{
|
||||
// Keep the item inside the scene rect.
|
||||
newPos.setX( qMin( rect.right(), qMax( newPos.x(), rect.left() ) ) );
|
||||
newPos.setY( qMin( rect.bottom(), qMax( newPos.y(), rect.top() ) ) );
|
||||
return newPos;
|
||||
}
|
||||
return QGraphicsItem::itemChange( change, value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// Class EqCurve
|
||||
//
|
||||
// Every Handle calculates its own curve.
|
||||
// But EqCurve generates an average curve.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
EqCurve::EqCurve( QList<EqHandle*> *handle, int x, int y )
|
||||
{
|
||||
m_width = x;
|
||||
m_heigth = y;
|
||||
m_handle = handle;
|
||||
m_alpha = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QRectF EqCurve::boundingRect() const
|
||||
{
|
||||
return QRect( 0, 0, m_width, m_heigth );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqCurve::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
|
||||
{
|
||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
|
||||
//Computes the main curve
|
||||
//if a band is active the curve will be computed by averaging the curves of each band
|
||||
QMap<float,float> mainCurve;
|
||||
for ( int x = 0; x < m_width ; x++ )
|
||||
{
|
||||
mainCurve[x] = 0;
|
||||
}
|
||||
int activeHandles=0;
|
||||
for ( int thatHandle = 0; thatHandle<m_handle->count(); thatHandle++ )
|
||||
{
|
||||
if ( m_handle->at(thatHandle)->isActiveHandle() == true )
|
||||
{
|
||||
activeHandles++;
|
||||
}
|
||||
}
|
||||
for ( int thatHandle = 0; thatHandle<m_handle->count(); thatHandle++ )
|
||||
{
|
||||
if ( m_handle->at(thatHandle)->isActiveHandle() == true )
|
||||
{
|
||||
for ( int x = 0; x < m_width ; x=x+1 )
|
||||
{
|
||||
if ( m_handle->at( thatHandle )->getType() == 1 )
|
||||
{
|
||||
mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getLowCutCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
|
||||
}
|
||||
if ( m_handle->at(thatHandle)->getType() == 2 )
|
||||
{
|
||||
mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getLowShelfCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
|
||||
}
|
||||
if ( m_handle->at( thatHandle )->getType() == 3 )
|
||||
{
|
||||
mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getPeakCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
|
||||
}
|
||||
if ( m_handle->at( thatHandle )->getType() == 4 )
|
||||
{
|
||||
mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getHighShelfCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
|
||||
}
|
||||
if ( m_handle->at(thatHandle)->getType() == 5 )
|
||||
{
|
||||
mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getHighCutCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPainterPath mCurve;
|
||||
//compute a QPainterPath
|
||||
for ( int x = 0; x < m_width ; x++ )
|
||||
{
|
||||
mainCurve[x] = ( ( mainCurve[x] / activeHandles ) ) - ( m_heigth/2 );
|
||||
if ( x==0 )
|
||||
{
|
||||
mCurve.moveTo( x, mainCurve[x] );
|
||||
}
|
||||
mCurve.lineTo( x, mainCurve[x] );
|
||||
}
|
||||
//and paint it with Pathstroker
|
||||
QPainterPathStroker stroke;
|
||||
QPainterPath strokeP;
|
||||
stroke.setWidth( 2 );
|
||||
strokeP = stroke.createStroke( mCurve );
|
||||
painter->fillPath( strokeP, QBrush( Qt::white ) );
|
||||
|
||||
// if mouse hover a handle, m_alpha counts up slow for blend in the filled EQ curve
|
||||
// todo: a smarter way of this "if-monster"
|
||||
QColor curveColor;
|
||||
if ( m_handle->at( 0 )->isMouseHover()
|
||||
|| m_handle->at( 1 )->isMouseHover()
|
||||
|| m_handle->at( 2 )->isMouseHover()
|
||||
|| m_handle->at( 3 )->isMouseHover()
|
||||
|| m_handle->at( 4 )->isMouseHover()
|
||||
|| m_handle->at( 5 )->isMouseHover()
|
||||
|| m_handle->at( 6 )->isMouseHover()
|
||||
|| m_handle->at( 7 )->isMouseHover()
|
||||
)
|
||||
{
|
||||
if ( m_alpha < 40 )
|
||||
m_alpha = m_alpha + 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_alpha > 0 )
|
||||
m_alpha = m_alpha - 10;
|
||||
}
|
||||
|
||||
//draw on mouse hover the curve of hovered filter
|
||||
for ( int i = 0; i < m_handle->count(); i++ )
|
||||
{
|
||||
if ( m_handle->at(i)->isMouseHover() )
|
||||
{
|
||||
switch ( i+1 )
|
||||
{
|
||||
case 1: curveColor = QColor( 163, 23, 23, 10*m_alpha/4 );break;
|
||||
case 2: curveColor = QColor( 229,108,0, 10*m_alpha/4 );break;
|
||||
case 3: curveColor = QColor( 255,240,0, 10*m_alpha/4 );break;
|
||||
case 4: curveColor = QColor( 12, 255, 0, 10*m_alpha/4 );break;
|
||||
case 5: curveColor = QColor( 0, 252, 255, 10*m_alpha/4 );break;
|
||||
case 6: curveColor = QColor( 59, 96, 235, 10*m_alpha/4 );break;
|
||||
case 7: curveColor = QColor( 112, 73, 255, 10*m_alpha/4 );break;
|
||||
case 8: curveColor = QColor( 255, 71, 227, 10*m_alpha/4 );
|
||||
}
|
||||
QPen pen ( curveColor);
|
||||
pen.setWidth( 2 );
|
||||
painter->setPen( pen );
|
||||
painter->drawPath( m_handle->at( i )->getCurvePath() );
|
||||
}
|
||||
}
|
||||
// draw on mouse hover the EQ curve filled. with m_alpha it blends in and out smooth
|
||||
QPainterPath cPath;
|
||||
cPath.addPath( mCurve );
|
||||
cPath.lineTo( cPath.currentPosition().x(), m_heigth );
|
||||
cPath.lineTo( cPath.elementAt( 0 ).x , m_heigth );
|
||||
painter->fillPath( cPath, QBrush ( QColor( 255,255,255, m_alpha ) ) );
|
||||
|
||||
}
|
||||
209
plugins/Eq/EqCurve.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* EqCurve.h - defination of EqCurve and EqHandle classes.
|
||||
*
|
||||
* Copyright (c) 2015 Steffen Baranowsky <BaraMGB/at/freenet/dot/de>
|
||||
*
|
||||
* This file is part of LMMS - http://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EQCURVE_H
|
||||
#define EQCURVE_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QGraphicsSceneWheelEvent>
|
||||
#include "lmms_math.h"
|
||||
|
||||
|
||||
enum{
|
||||
highpass=1,
|
||||
lowshelf,
|
||||
para,
|
||||
highshelf,
|
||||
lowpass
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// implements the Eq_Handle to control a band
|
||||
class EqHandle : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EqHandle( int num, int x, int y );
|
||||
void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget );
|
||||
QPainterPath getCurvePath();
|
||||
float getPeakCurve( float x );
|
||||
float getHighShelfCurve( float x );
|
||||
float getLowShelfCurve( float x );
|
||||
float getLowCutCurve( float x );
|
||||
float getHighCutCurve( float x );
|
||||
float getResonance();
|
||||
int getNum();
|
||||
int getType();
|
||||
void setType( int t );
|
||||
void setResonance( float r );
|
||||
bool isMouseHover();
|
||||
void setMouseHover( bool d );
|
||||
bool isActiveHandle();
|
||||
void setHandleActive( bool a );
|
||||
void setHandleMoved(bool a);
|
||||
bool getHandleMoved();
|
||||
void sethp12();
|
||||
void sethp24();
|
||||
void sethp48();
|
||||
void setlp12();
|
||||
void setlp24();
|
||||
void setlp48();
|
||||
private:
|
||||
long double PI;
|
||||
float m_pixelsPerUnitWidth;
|
||||
float m_pixelsPerUnitHeight;
|
||||
float m_scale;
|
||||
bool m_hp12;
|
||||
bool m_hp24;
|
||||
bool m_hp48;
|
||||
bool m_lp12;
|
||||
bool m_lp24;
|
||||
bool m_lp48;
|
||||
bool m_mouseHover;
|
||||
bool m_active;
|
||||
int m_type, m_numb;
|
||||
float m_resonance;
|
||||
float m_width, m_heigth;
|
||||
bool m_mousePressed;
|
||||
bool m_handleMoved;
|
||||
QRectF boundingRect() const;
|
||||
|
||||
|
||||
|
||||
|
||||
inline float freqToXPixel( float freq )
|
||||
{
|
||||
float min = log ( 27) / log( 10 );
|
||||
float max = log ( 20000 )/ log( 10 );
|
||||
float range = max - min;
|
||||
return ( log( freq ) / log( 10 ) - min ) / range * m_width;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float xPixelToFreq( float x )
|
||||
{
|
||||
float min = log ( 27) / log( 10 );
|
||||
float max = log ( 20000 ) / log( 10 );
|
||||
float range = max - min;
|
||||
return pow( 10 , x * ( range / m_width ) + min );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float gainToYPixel( float gain )
|
||||
{
|
||||
return ( m_heigth ) - ( gain * m_pixelsPerUnitHeight ) - ( ( m_heigth ) * 0.5 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float yPixelToGain( float y )
|
||||
{
|
||||
return ( ( 0.5 * m_heigth ) - y ) / m_pixelsPerUnitHeight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void positionChanged();
|
||||
private slots:
|
||||
void handleMoved();
|
||||
|
||||
|
||||
protected:
|
||||
void mousePressEvent( QGraphicsSceneMouseEvent *event );
|
||||
void mouseReleaseEvent( QGraphicsSceneMouseEvent *event );
|
||||
void wheelEvent( QGraphicsSceneWheelEvent *wevent );
|
||||
void hoverEnterEvent( QGraphicsSceneHoverEvent *hevent );
|
||||
void hoverLeaveEvent( QGraphicsSceneHoverEvent *hevent );
|
||||
QVariant itemChange( GraphicsItemChange change, const QVariant &value );
|
||||
};
|
||||
|
||||
|
||||
|
||||
class EqCurve : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EqCurve( QList<EqHandle*> *handle, int x, int y );
|
||||
QList<EqHandle*> *m_handle;
|
||||
QRectF boundingRect() const;
|
||||
void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget );
|
||||
private:
|
||||
int m_width, m_heigth;
|
||||
int m_alpha;
|
||||
|
||||
float m_pixelsPerUnitHeight;
|
||||
float m_scale;
|
||||
|
||||
|
||||
|
||||
|
||||
inline float freqToXPixel( float freq )
|
||||
{
|
||||
float min = log ( 27) / log( 10 );
|
||||
float max = log ( 20000 ) / log( 10 );
|
||||
float range = max - min;
|
||||
return ( log( freq ) / log( 10 ) - min ) / range * m_width;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float xPixelToFreq( float x )
|
||||
{
|
||||
float min = log ( 27) / log( 10 );
|
||||
float max = log ( 20000 ) / log( 10 );
|
||||
float range = max - min;
|
||||
return pow( 10 , x * ( range / m_width ) + min );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float gainToYPixel( float gain )
|
||||
{
|
||||
return ( m_heigth ) - ( gain * m_pixelsPerUnitHeight ) - ( ( m_heigth ) * 0.5 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float yPixelToGain( float y )
|
||||
{
|
||||
return ( ( 0.5 * m_heigth ) - y ) / m_pixelsPerUnitHeight;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // EQCURVE_H
|
||||
@@ -188,7 +188,7 @@ bool EqEffect::processAudioBuffer(sampleFrame *buf, const fpp_t frames)
|
||||
const int sampleRate = Engine::mixer()->processingSampleRate();
|
||||
sampleFrame m_inPeak = { 0, 0 };
|
||||
|
||||
if(m_eqControls.m_analyseIn )
|
||||
if(m_eqControls.m_analyseInModel.value( true ) )
|
||||
{
|
||||
m_eqControls.m_inFftBands.analyze( buf, frames );
|
||||
}
|
||||
@@ -326,7 +326,7 @@ bool EqEffect::processAudioBuffer(sampleFrame *buf, const fpp_t frames)
|
||||
m_eqControls.m_outPeakR = m_eqControls.m_outPeakR < outPeak[1] ? outPeak[1] : m_eqControls.m_outPeakR;
|
||||
|
||||
checkGate( outSum / frames );
|
||||
if(m_eqControls.m_analyseOut )
|
||||
if(m_eqControls.m_analyseOutModel.value( true ) )
|
||||
{
|
||||
m_eqControls.m_outFftBands.analyze( buf, frames );
|
||||
setBandPeaks( &m_eqControls.m_outFftBands , ( int )( sampleRate * 0.5 ) );
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#include "EffectControls.h"
|
||||
#include "MainWindow.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "qwidget.h"
|
||||
#include "TextFloat.h"
|
||||
#include "qlist.h"
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ class EqFader : public Fader
|
||||
public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
EqFader( FloatModel * model, const QString & name, QWidget * parent, float* lPeak, float* rPeak ) :
|
||||
Fader( model, name, parent)
|
||||
EqFader( FloatModel * model, const QString & name, QWidget * parent, QPixmap * back, QPixmap * leds, QPixmap * knob, float* lPeak, float* rPeak ) :
|
||||
Fader( model, name, parent, back, leds, knob )
|
||||
{
|
||||
setMinimumSize( 23, 116 );
|
||||
setMaximumSize( 23, 116 );
|
||||
@@ -53,6 +53,19 @@ public:
|
||||
setPeak_R( 0 );
|
||||
}
|
||||
|
||||
EqFader( FloatModel * model, const QString & name, QWidget * parent, float* lPeak, float* rPeak ) :
|
||||
Fader( model, name, parent )
|
||||
{
|
||||
setMinimumSize( 23, 116 );
|
||||
setMaximumSize( 23, 116 );
|
||||
resize( 23, 116 );
|
||||
m_lPeak = lPeak;
|
||||
m_rPeak = rPeak;
|
||||
connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateVuMeters() ) );
|
||||
m_model = model;
|
||||
setPeak_L( 0 );
|
||||
setPeak_R( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
plugins/Eq/EqLayout1BG.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
@@ -2,6 +2,7 @@
|
||||
* eqparameterwidget.cpp - defination of EqParameterWidget class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
* Copyright (c) 2015 Steffen Baranowsky <BaraMGB/at/freenet/dot/de>
|
||||
*
|
||||
* This file is part of LMMS - http://lmms.io
|
||||
*
|
||||
@@ -23,34 +24,55 @@
|
||||
*/
|
||||
|
||||
#include "EqParameterWidget.h"
|
||||
#include "QPainter"
|
||||
#include "qwidget.h"
|
||||
#include "lmms_math.h"
|
||||
#include "MainWindow.h"
|
||||
#include "QMouseEvent"
|
||||
#include "EqControls.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) :
|
||||
QWidget( parent ),
|
||||
m_bands ( 0 ),
|
||||
m_selectedBand ( 0 )
|
||||
m_displayWidth ( 400 ),
|
||||
m_displayHeigth ( 200 ),
|
||||
m_notFirst ( false ),
|
||||
m_controls ( controls )
|
||||
|
||||
{
|
||||
m_bands = new EqBand[8];
|
||||
resize( 250, 116 );
|
||||
// connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) );
|
||||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
timer->start(100);
|
||||
float totalLength = log10( 21000 );
|
||||
m_pixelsPerUnitWidth = width( ) / totalLength ;
|
||||
float totalHeight = 80;
|
||||
m_pixelsPerUnitHeight = (height() - 4) / ( totalHeight );
|
||||
m_scale = 1.5;
|
||||
resize( m_displayWidth, m_displayHeigth );
|
||||
float totalHeight = 36; // gain range from -18 to +18
|
||||
m_pixelsPerUnitHeight = m_displayHeigth / totalHeight;
|
||||
m_pixelsPerOctave = freqToXPixel( 10000 ) - freqToXPixel( 5000 );
|
||||
m_controls = controls;
|
||||
tf = new TextFloat();
|
||||
tf->hide();
|
||||
|
||||
//GraphicsScene and GraphicsView stuff
|
||||
m_scene = new QGraphicsScene();
|
||||
m_scene->setSceneRect( 0, 0, m_displayWidth, m_displayHeigth );
|
||||
m_view = new QGraphicsView(this);
|
||||
m_view->setStyleSheet( "border-style: none; background: transparent;");
|
||||
m_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
m_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
m_view->setScene( m_scene );
|
||||
|
||||
//adds the handles
|
||||
m_handleList = new QList<EqHandle*>;
|
||||
for ( int i = 0; i < bandCount(); i++ )
|
||||
{
|
||||
m_handle = new EqHandle ( i, m_displayWidth, m_displayHeigth );
|
||||
m_handleList->append( m_handle );
|
||||
m_handle->setZValue(1);
|
||||
m_scene->addItem( m_handle );
|
||||
}
|
||||
|
||||
//adds the curve widget
|
||||
m_eqcurve = new EqCurve( m_handleList, m_displayWidth, m_displayHeigth );
|
||||
m_scene->addItem( m_eqcurve );
|
||||
for ( int i = 0; i < bandCount(); i++ )
|
||||
{
|
||||
// if the data of handle position has changed update the models
|
||||
QObject::connect( m_handleList->at( i ) ,SIGNAL( positionChanged() ), this ,SLOT( updateModels() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +80,7 @@ EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) :
|
||||
|
||||
EqParameterWidget::~EqParameterWidget()
|
||||
{
|
||||
if(m_bands)
|
||||
if( m_bands )
|
||||
{
|
||||
delete[] m_bands;
|
||||
m_bands = 0;
|
||||
@@ -68,174 +90,122 @@ EqParameterWidget::~EqParameterWidget()
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::paintEvent( QPaintEvent *event )
|
||||
void EqParameterWidget::updateView()
|
||||
{
|
||||
QPainter painter( this );
|
||||
//Draw Frequecy maker lines
|
||||
painter.setPen( QPen( QColor( 100, 100, 100, 200 ), 1, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin ) );
|
||||
for( int x = 20 ; x < 100; x += 10)
|
||||
{
|
||||
painter.drawLine( freqToXPixel( x ) , 0, freqToXPixel( x ) , height() );
|
||||
}
|
||||
for( int x = 100 ; x < 1000; x += 100)
|
||||
{
|
||||
painter.drawLine( freqToXPixel( x ) , 0, freqToXPixel( x ) , height() );
|
||||
}
|
||||
for( int x = 1000 ; x < 11000; x += 1000)
|
||||
{
|
||||
painter.drawLine( freqToXPixel( x ) , 0, freqToXPixel( x ) , height() );
|
||||
}
|
||||
//draw 0dB line
|
||||
painter.drawLine(0, gainToYPixel( 0 ) , width(), gainToYPixel( 0 ) );
|
||||
|
||||
for( int i = 0 ; i < bandCount() ; i++ )
|
||||
{
|
||||
m_bands[i].color.setAlpha( m_bands[i].active->value() ? activeAplha() : inactiveAlpha() );
|
||||
painter.setPen( QPen( m_bands[i].color, 1, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin ) );
|
||||
float x = freqToXPixel( m_bands[i].freq->value() );
|
||||
float y = height() * 0.5;
|
||||
float gain = 1;
|
||||
if( m_bands[i].gain )
|
||||
if ( m_handleList->at( i )->getHandleMoved() == false ) //prevents a short circuit between handle and data model
|
||||
{
|
||||
gain = m_bands[i].gain->value();
|
||||
}
|
||||
y = gainToYPixel( gain );
|
||||
float bw = m_bands[i].freq->value() * m_bands[i].res->value();
|
||||
m_bands[i].x = x; m_bands[i].y = y;
|
||||
const int radius = 7;
|
||||
painter.drawEllipse( x - radius , y - radius, radius * 2 ,radius * 2 );
|
||||
QString msg = QString ( "%1" ).arg ( QString::number (i + 1) );
|
||||
painter.drawText(x - ( radius * 0.5 ), y + ( radius * 0.85 ), msg );
|
||||
painter.setPen( QPen( m_bands[i].color, 1, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin ) );
|
||||
if( i == 0 || i == bandCount() - 1 )
|
||||
{
|
||||
painter.drawLine(x , y, x, y - (m_bands[i].res->value() * 4 ) );
|
||||
//sets the band on active if a fader or a knob is moved
|
||||
bool hover= false; // prevents an action if handle is moved
|
||||
for ( int j = 0; j < bandCount(); j++ )
|
||||
{
|
||||
if ( m_handleList->at(j)->isMouseHover() ) hover = true;
|
||||
}
|
||||
if ( !hover )
|
||||
{
|
||||
if ( sender() == m_bands[i].gain ) m_bands[i].active->setValue( true );
|
||||
if ( sender() == m_bands[i].freq ) m_bands[i].active->setValue( true );
|
||||
if ( sender() == m_bands[i].res ) m_bands[i].active->setValue( true );
|
||||
}
|
||||
|
||||
changeHandle(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.drawLine(freqToXPixel(m_bands[i].freq->value()-(bw * 0.5)),y,freqToXPixel(m_bands[i].freq->value()+(bw * 0.5)),y);
|
||||
m_handleList->at( i )->setHandleActive( m_bands[i].active->value() );
|
||||
m_handleList->at( i )->setHandleMoved( false );
|
||||
}
|
||||
}
|
||||
|
||||
m_notFirst = true;
|
||||
if ( m_bands[0].hp12->value() ) m_handleList->at( 0 )->sethp12();
|
||||
if ( m_bands[0].hp24->value() ) m_handleList->at( 0 )->sethp24();
|
||||
if ( m_bands[0].hp48->value() ) m_handleList->at( 0 )->sethp48();
|
||||
if ( m_bands[7].lp12->value() ) m_handleList->at( 7 )->setlp12();
|
||||
if ( m_bands[7].lp24->value() ) m_handleList->at( 7 )->setlp24();
|
||||
if ( m_bands[7].lp48->value() ) m_handleList->at( 7 )->setlp48();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::mousePressEvent( QMouseEvent *event )
|
||||
void EqParameterWidget::changeHandle( int i )
|
||||
{
|
||||
m_oldX = event->x(); m_oldY = event->y();
|
||||
m_selectedBand = selectNearestHandle( event->x(), event->y() );
|
||||
m_mouseAction = none;
|
||||
if ( event->button() == Qt::LeftButton ) m_mouseAction = drag;
|
||||
if ( event->button() == Qt::RightButton ) m_mouseAction = res;
|
||||
//fill x, y, and bw with data from model
|
||||
float x = freqToXPixel( m_bands[i].freq->value() );
|
||||
float y = m_handleList->at( i )->y();
|
||||
//for pass filters there is no gain model
|
||||
if( m_bands[i].gain )
|
||||
{
|
||||
float gain = m_bands[i].gain->value();
|
||||
y = gainToYPixel( gain );
|
||||
}
|
||||
float bw = m_bands[i].res->value();
|
||||
|
||||
// set the handle position, filter type for each handle
|
||||
switch ( i )
|
||||
{
|
||||
case 0 :
|
||||
m_handleList->at( i )->setType( highpass );
|
||||
m_handleList->at( i )->setPos( x, m_displayHeigth/2 );
|
||||
break;
|
||||
case 1:
|
||||
m_handleList->at( i )->setType( lowshelf );
|
||||
m_handleList->at( i )->setPos( x, y );
|
||||
break;
|
||||
case 2:
|
||||
m_handleList->at( i )->setType( para );
|
||||
m_handleList->at( i )->setPos( x, y );
|
||||
break;
|
||||
case 3:
|
||||
m_handleList->at( i )->setType( para );
|
||||
m_handleList->at( i )->setPos( x, y );
|
||||
break;
|
||||
case 4:
|
||||
m_handleList->at( i )->setType( para );
|
||||
m_handleList->at( i )->setPos( x, y );
|
||||
break;
|
||||
case 5:
|
||||
m_handleList->at( i )->setType( para );
|
||||
m_handleList->at( i )->setPos( x, y );
|
||||
break;
|
||||
case 6:
|
||||
m_handleList->at( i )->setType( highshelf );
|
||||
m_handleList->at( i )->setPos( x, y );
|
||||
break;
|
||||
case 7:
|
||||
m_handleList->at( i )->setType( lowpass );
|
||||
m_handleList->at( i )->setPos( QPointF( x, m_displayHeigth/2 ) );
|
||||
break;
|
||||
}
|
||||
|
||||
// set resonance/bandwidth for each handle
|
||||
if ( m_handleList->at( i )->getResonance() != bw )
|
||||
{
|
||||
m_handleList->at( i )->setResonance( bw );
|
||||
}
|
||||
|
||||
// and the active status
|
||||
m_handleList->at( i )->setHandleActive( m_bands[i].active->value() );
|
||||
m_handleList->at( i )->update();
|
||||
m_eqcurve->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::mouseReleaseEvent( QMouseEvent *event )
|
||||
void EqParameterWidget::updateModels()
|
||||
{
|
||||
m_selectedBand = 0;
|
||||
m_mouseAction = none;
|
||||
const int inXmin = 228;
|
||||
const int inXmax = 250;
|
||||
const int inYmin = 20;
|
||||
const int inYmax = 30;
|
||||
|
||||
const int outXmin = 228;
|
||||
const int outXmax = 250;
|
||||
const int outYmin = 30;
|
||||
const int outYmax = 40;
|
||||
|
||||
if(event->x() > inXmin && event->x() < inXmax && event->y() > inYmin && event->y() < inYmax )
|
||||
for ( int i=0 ; i < bandCount(); i++ )
|
||||
{
|
||||
m_controls->m_analyseIn = !m_controls->m_analyseIn;
|
||||
m_bands[i].freq->setValue( xPixelToFreq( m_handleList->at(i)->x() ) );
|
||||
if( m_bands[i].gain ) m_bands[i].gain->setValue( yPixelToGain( m_handleList->at(i)->y() ) );
|
||||
m_bands[i].res->setValue( m_handleList->at( i )->getResonance() );
|
||||
//sets the band on active if the handle is moved
|
||||
if ( sender() == m_handleList->at( i ) ) m_bands[i].active->setValue( true );
|
||||
}
|
||||
|
||||
if(event->x() > outXmin && event->x() < outXmax && event->y() > outYmin && event->y() < outYmax )
|
||||
{
|
||||
m_controls->m_analyseOut = !m_controls->m_analyseOut;
|
||||
}
|
||||
|
||||
tf->hide();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::mouseMoveEvent( QMouseEvent *event )
|
||||
{
|
||||
int deltaX = event->x() - m_oldX;
|
||||
int deltaR = event->y() - m_oldY;
|
||||
m_oldX = event->x(); m_oldY = event->y();
|
||||
if(m_selectedBand && m_selectedBand->active->value() )
|
||||
{
|
||||
switch ( m_mouseAction ) {
|
||||
case none :
|
||||
break;
|
||||
case drag:
|
||||
if( m_selectedBand->freq ) m_selectedBand->freq->setValue( xPixelToFreq( m_oldX ) );
|
||||
if( m_selectedBand->gain )m_selectedBand->gain->setValue( yPixelToGain( m_oldY ) );
|
||||
break;
|
||||
case res:
|
||||
if( m_selectedBand->res )m_selectedBand->res->incValue( ( deltaX) * resPixelMultiplyer() );
|
||||
if( m_selectedBand->res )m_selectedBand->res->incValue( (-deltaR) * resPixelMultiplyer() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( m_oldX > 0 && m_oldX < width() && m_oldY > 0 && m_oldY < height() )
|
||||
{
|
||||
tf->setText( QString::number(xPixelToFreq( m_oldX )) + tr( "Hz ") );
|
||||
tf->show();
|
||||
const int x = event->x() > width() * 0.5 ?
|
||||
m_oldX - tf->width() :
|
||||
m_oldX;
|
||||
tf->moveGlobal(this, QPoint( x, m_oldY - tf->height() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::mouseDoubleClickEvent( QMouseEvent *event )
|
||||
{
|
||||
EqBand* selected = selectNearestHandle( event->x() , event->y() );
|
||||
if( selected )
|
||||
{
|
||||
selected->active->setValue( selected->active->value() ? 0 : 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EqBand* EqParameterWidget::selectNearestHandle( const int x, const int y )
|
||||
{
|
||||
EqBand* selectedModel = 0;
|
||||
float* distanceToHandles = new float[bandCount()];
|
||||
//calc distance to each handle
|
||||
for( int i = 0 ; i < bandCount() ; i++ )
|
||||
{
|
||||
int xOffset = m_bands[i].x - x;
|
||||
int yOffset = m_bands[i].y - y;
|
||||
distanceToHandles[i] = fabs( sqrt( ( xOffset * xOffset ) + ( yOffset * yOffset ) ) );
|
||||
}
|
||||
//select band
|
||||
int shortestBand = 0;
|
||||
for ( int i = 1 ; i < bandCount() ; i++ )
|
||||
{
|
||||
if ( distanceToHandles [i] < distanceToHandles[shortestBand] ){
|
||||
shortestBand = i;
|
||||
}
|
||||
}
|
||||
if(distanceToHandles[shortestBand] < maxDistanceFromHandle() )
|
||||
{
|
||||
selectedModel = &m_bands[shortestBand];
|
||||
}
|
||||
delete[] distanceToHandles;
|
||||
return selectedModel;
|
||||
m_eqcurve->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* eqparameterwidget.cpp - defination of EqParameterWidget class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
* Copyright (c) 2015 Steffen Baranowsky <BaraMGB/at/freenet/dot/de>
|
||||
*
|
||||
* This file is part of LMMS - http://lmms.io
|
||||
*
|
||||
@@ -26,8 +27,13 @@
|
||||
#ifndef EQPARAMETERWIDGET_H
|
||||
#define EQPARAMETERWIDGET_H
|
||||
#include <QWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsView>
|
||||
#include "EffectControls.h"
|
||||
#include "TextFloat.h"
|
||||
#include "EqCurve.h"
|
||||
|
||||
|
||||
class EqControls;
|
||||
|
||||
@@ -40,6 +46,12 @@ public :
|
||||
FloatModel* res;
|
||||
FloatModel* freq;
|
||||
BoolModel* active;
|
||||
BoolModel* hp12;
|
||||
BoolModel* hp24;
|
||||
BoolModel* hp48;
|
||||
BoolModel* lp12;
|
||||
BoolModel* lp24;
|
||||
BoolModel* lp48;
|
||||
QColor color;
|
||||
int x;
|
||||
int y;
|
||||
@@ -58,6 +70,10 @@ class EqParameterWidget : public QWidget
|
||||
public:
|
||||
explicit EqParameterWidget( QWidget *parent = 0, EqControls * controls = 0);
|
||||
~EqParameterWidget();
|
||||
QList<EqHandle*> *m_handleList;
|
||||
|
||||
void changeHandle(int i);
|
||||
|
||||
const int bandCount()
|
||||
{
|
||||
return 8;
|
||||
@@ -65,13 +81,6 @@ public:
|
||||
|
||||
|
||||
|
||||
const int maxDistanceFromHandle()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EqBand* getBandModels( int i )
|
||||
{
|
||||
@@ -79,88 +88,65 @@ public:
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const int activeAplha()
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const int inactiveAlpha()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const float resPixelMultiplyer()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
virtual void paintEvent ( QPaintEvent * event );
|
||||
virtual void mousePressEvent(QMouseEvent * event );
|
||||
virtual void mouseReleaseEvent(QMouseEvent * event);
|
||||
virtual void mouseMoveEvent(QMouseEvent * event);
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent * event);
|
||||
|
||||
private:
|
||||
|
||||
EqBand *m_bands;
|
||||
int m_displayWidth, m_displayHeigth;
|
||||
bool m_notFirst;
|
||||
EqControls *m_controls;
|
||||
|
||||
QGraphicsView *m_view;
|
||||
QGraphicsScene *m_scene;
|
||||
EqHandle *m_handle;
|
||||
EqCurve *m_eqcurve;
|
||||
|
||||
float m_pixelsPerUnitWidth;
|
||||
float m_pixelsPerUnitHeight;
|
||||
float m_pixelsPerOctave;
|
||||
float m_scale;
|
||||
EqBand* m_selectedBand;
|
||||
TextFloat *tf;
|
||||
|
||||
EqBand* selectNearestHandle( const int x, const int y );
|
||||
|
||||
enum MouseAction { none, drag, res } m_mouseAction;
|
||||
int m_oldX, m_oldY;
|
||||
int *m_xGridBands;
|
||||
|
||||
|
||||
inline int freqToXPixel( float freq )
|
||||
|
||||
|
||||
inline float freqToXPixel( float freq )
|
||||
{
|
||||
return ( log10( freq ) * m_pixelsPerUnitWidth * m_scale ) - ( width() * 0.5 );
|
||||
float min = log ( 27) / log( 10 );
|
||||
float max = log ( 20000 )/ log( 10 );
|
||||
float range = max - min;
|
||||
return ( log( freq ) / log( 10 ) - min ) / range * m_displayWidth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float xPixelToFreq( int x )
|
||||
|
||||
inline float xPixelToFreq( float x )
|
||||
{
|
||||
return pow( 10, ( x + ( width() * 0.5 ) ) / ( m_pixelsPerUnitWidth * m_scale ) );
|
||||
float min = log ( 27 ) / log( 10 );
|
||||
float max = log ( 20000 ) / log( 10 );
|
||||
float range = max - min;
|
||||
return pow( 10 , x * ( range / m_displayWidth ) + min );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline int gainToYPixel( float gain )
|
||||
inline float gainToYPixel( float gain )
|
||||
{
|
||||
return ( height() - 3) - ( gain * m_pixelsPerUnitHeight ) - ( (height() -3 ) * 0.5);
|
||||
return m_displayHeigth - ( gain * m_pixelsPerUnitHeight ) - ( m_displayHeigth * 0.5 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float yPixelToGain( int y )
|
||||
inline float yPixelToGain( float y )
|
||||
{
|
||||
return ( ( 0.5 * height() ) - y) / m_pixelsPerUnitHeight;
|
||||
return ( ( 0.5 * m_displayHeigth ) - y ) / m_pixelsPerUnitHeight;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void updateModels();
|
||||
void updateView();
|
||||
};
|
||||
|
||||
|
||||
#endif // EQPARAMETERWIDGET_H
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
#ifndef EQSPECTRUMVIEW_H
|
||||
#define EQSPECTRUMVIEW_H
|
||||
|
||||
#include "qpainter.h"
|
||||
//#include "eqeffect.h"
|
||||
#include "qwidget.h"
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
#include "fft_helpers.h"
|
||||
#include "Engine.h"
|
||||
|
||||
|
||||
|
||||
const int MAX_BANDS = 2048;
|
||||
|
||||
class EqAnalyser
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
m_active ( true )
|
||||
{
|
||||
m_inProgress=false;
|
||||
m_specBuf = (fftwf_complex *) fftwf_malloc( ( FFT_BUFFER_SIZE + 1 ) * sizeof( fftwf_complex ) );
|
||||
m_specBuf = ( fftwf_complex * ) fftwf_malloc( ( FFT_BUFFER_SIZE + 1 ) * sizeof( fftwf_complex ) );
|
||||
m_fftPlan = fftwf_plan_dft_r2c_1d( FFT_BUFFER_SIZE*2, m_buffer, m_specBuf, FFTW_MEASURE );
|
||||
clear();
|
||||
}
|
||||
@@ -121,6 +121,8 @@ public:
|
||||
( int )( LOWEST_FREQ * ( FFT_BUFFER_SIZE + 1 ) / ( float )( m_sr / 2 ) ),
|
||||
( int )( HIGHEST_FREQ * ( FFT_BUFFER_SIZE + 1) / ( float )( m_sr / 2 ) ) );
|
||||
m_energy = maximum( m_bands, MAX_BANDS ) / maximum( m_buffer, FFT_BUFFER_SIZE );
|
||||
|
||||
|
||||
m_framesFilledUp = 0;
|
||||
m_inProgress = false;
|
||||
m_active = false;
|
||||
@@ -139,16 +141,20 @@ public:
|
||||
QWidget( _parent ),
|
||||
m_sa( b )
|
||||
{
|
||||
setFixedSize( 250, 116 );
|
||||
setFixedSize( 400, 200 );
|
||||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
timer->start(2000);
|
||||
timer->start(100);
|
||||
setAttribute( Qt::WA_TranslucentBackground, true );
|
||||
m_skipBands = MAX_BANDS * 0.5;
|
||||
float totalLength = log10( 21000);
|
||||
m_pixelsPerUnitWidth = width( ) / totalLength ;
|
||||
float totalLength = log10( 20000 );
|
||||
m_pixelsPerUnitWidth = width( ) / totalLength ;
|
||||
m_scale = 1.5;
|
||||
color = QColor( 255, 255, 255, 255 );
|
||||
for ( int i=0 ; i < MAX_BANDS ; i++ )
|
||||
{
|
||||
m_bandHeight.append( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +174,7 @@ public:
|
||||
{
|
||||
m_sa->m_active = isVisible();
|
||||
const int fh = height();
|
||||
const int LOWER_Y = -60; // dB
|
||||
const int LOWER_Y = -36; // dB
|
||||
QPainter p( this );
|
||||
p.setPen( QPen( color, 1, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin ) );
|
||||
const float e = m_sa->m_energy;
|
||||
@@ -183,13 +189,28 @@ public:
|
||||
}
|
||||
pp = QPainterPath();
|
||||
float * b = m_sa->m_bands;
|
||||
int h;
|
||||
float h;
|
||||
pp.moveTo( 0,height() );
|
||||
for( int x = 0; x < MAX_BANDS; ++x, ++b )
|
||||
{
|
||||
h = (int)( fh * 2.0 / 3.0 * ( 20 * ( log10 ( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) );
|
||||
if( h < 0 ) h = 0; else if( h >= fh ) continue;
|
||||
pp.lineTo( freqToXPixel(bandToFreq( x ) ), fh-h );
|
||||
h = ( fh * 2.0 / 3.0 * ( 20 * ( log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) );
|
||||
if( h < 0 )
|
||||
{
|
||||
h = 0;
|
||||
}
|
||||
else if( h >= fh )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (h > m_bandHeight.at(x))
|
||||
{
|
||||
m_bandHeight[x] = h;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bandHeight[x] = m_bandHeight[x] -1;
|
||||
}
|
||||
pp.lineTo( freqToXPixel( bandToFreq( x ) ), fh - m_bandHeight.at( x ) );
|
||||
}
|
||||
pp.lineTo( width(), height() );
|
||||
pp.closeSubpath();
|
||||
@@ -205,21 +226,29 @@ public:
|
||||
return ( log10( band - m_skipBands ) * m_pixelsPerUnitWidth * m_scale );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float bandToFreq ( int index )
|
||||
{
|
||||
return index * m_sa->m_sr / (MAX_BANDS * 2 );
|
||||
}
|
||||
|
||||
|
||||
inline int freqToXPixel( float freq )
|
||||
|
||||
|
||||
inline float freqToXPixel( float freq )
|
||||
{
|
||||
return ( log10( freq ) * m_pixelsPerUnitWidth * m_scale ) - ( width() * 0.5 );
|
||||
float min = log ( 27) / log( 10 );
|
||||
float max = log ( 20000 )/ log( 10 );
|
||||
float range = max - min;
|
||||
return ( log( freq ) / log( 10 ) - min ) / range * width();
|
||||
}
|
||||
|
||||
private:
|
||||
float m_pixelsPerUnitWidth;
|
||||
float m_scale;
|
||||
int m_skipBands;
|
||||
QList<float> m_bandHeight;
|
||||
} ;
|
||||
|
||||
|
||||
#endif // EQSPECTRUMVIEW_H
|
||||
|
||||
|
Before Width: | Height: | Size: 27 KiB |
BIN
plugins/Eq/bandLabel1.png
Normal file
|
After Width: | Height: | Size: 413 B |
BIN
plugins/Eq/bandLabel1on.png
Normal file
|
After Width: | Height: | Size: 457 B |
BIN
plugins/Eq/bandLabel2.png
Normal file
|
After Width: | Height: | Size: 487 B |
BIN
plugins/Eq/bandLabel2on.png
Normal file
|
After Width: | Height: | Size: 544 B |
BIN
plugins/Eq/bandLabel3.png
Normal file
|
After Width: | Height: | Size: 488 B |
BIN
plugins/Eq/bandLabel3on.png
Normal file
|
After Width: | Height: | Size: 537 B |
BIN
plugins/Eq/bandLabel4.png
Normal file
|
After Width: | Height: | Size: 467 B |
BIN
plugins/Eq/bandLabel4on.png
Normal file
|
After Width: | Height: | Size: 525 B |
BIN
plugins/Eq/bandLabel5.png
Normal file
|
After Width: | Height: | Size: 458 B |
BIN
plugins/Eq/bandLabel5on.png
Normal file
|
After Width: | Height: | Size: 515 B |
BIN
plugins/Eq/bandLabel6.png
Normal file
|
After Width: | Height: | Size: 525 B |
BIN
plugins/Eq/bandLabel6on.png
Normal file
|
After Width: | Height: | Size: 605 B |
BIN
plugins/Eq/bandLabel7.png
Normal file
|
After Width: | Height: | Size: 446 B |
BIN
plugins/Eq/bandLabel7on.png
Normal file
|
After Width: | Height: | Size: 499 B |
BIN
plugins/Eq/bandLabel8.png
Normal file
|
After Width: | Height: | Size: 540 B |
BIN
plugins/Eq/bandLabel8on.png
Normal file
|
After Width: | Height: | Size: 614 B |
BIN
plugins/Eq/circle1.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
plugins/Eq/handle1.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
plugins/Eq/handle1inactive.png
Normal file
|
After Width: | Height: | Size: 734 B |
BIN
plugins/Eq/handle2.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
plugins/Eq/handle2inactive.png
Normal file
|
After Width: | Height: | Size: 942 B |
BIN
plugins/Eq/handle3.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
plugins/Eq/handle3inactive.png
Normal file
|
After Width: | Height: | Size: 920 B |
BIN
plugins/Eq/handle4.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
plugins/Eq/handle4inactive.png
Normal file
|
After Width: | Height: | Size: 818 B |
BIN
plugins/Eq/handle5.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
plugins/Eq/handle5inactive.png
Normal file
|
After Width: | Height: | Size: 918 B |
BIN
plugins/Eq/handle6.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
plugins/Eq/handle6inactive.png
Normal file
|
After Width: | Height: | Size: 944 B |
BIN
plugins/Eq/handle7.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
plugins/Eq/handle7inactive.png
Normal file
|
After Width: | Height: | Size: 833 B |
BIN
plugins/Eq/handle8.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
plugins/Eq/handle8inactive.png
Normal file
|
After Width: | Height: | Size: 948 B |
BIN
plugins/Eq/handlehover.png
Normal file
|
After Width: | Height: | Size: 967 B |