re initial, no working fft, faders, checkboxes
This commit is contained in:
@@ -9,6 +9,7 @@ ADD_SUBDIRECTORY(carlarack)
|
||||
ADD_SUBDIRECTORY(delay)
|
||||
ADD_SUBDIRECTORY(DualFilter)
|
||||
ADD_SUBDIRECTORY(dynamics_processor)
|
||||
ADD_SUBDIRECTORY(eq)
|
||||
ADD_SUBDIRECTORY(flanger)
|
||||
ADD_SUBDIRECTORY(flp_import)
|
||||
ADD_SUBDIRECTORY(HydrogenImport)
|
||||
|
||||
3
plugins/eq/CMakeLists.txt
Normal file
3
plugins/eq/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
INCLUDE(BuildPlugin)
|
||||
|
||||
BUILD_PLUGIN(eq eqeffect.cpp eqcontrols.cpp eqcontrolsdialog.cpp eqfilter.h eqparameterwidget.cpp eqfader.h MOCFILES eqcontrols.h eqparameterwidget.h eqfader.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
|
||||
BIN
plugins/eq/artwork.png
Normal file
BIN
plugins/eq/artwork.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
201
plugins/eq/eqcontrols.cpp
Normal file
201
plugins/eq/eqcontrols.cpp
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* eqcontrols.cpp - defination of EqControls class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 <QtXml/QDomElement>
|
||||
|
||||
#include "eqcontrols.h"
|
||||
#include "eqeffect.h"
|
||||
|
||||
|
||||
|
||||
|
||||
EqControls::EqControls( EqEffect *effect ) :
|
||||
EffectControls( effect ),
|
||||
m_effect( effect ),
|
||||
m_inGainModel( 1.0, 0.0, 2.0, 0.001, this, tr( "Input gain") ),
|
||||
m_outGainModel( 1.0, 0.0, 2.0, 0.001, this, tr( "Output gain" ) ),
|
||||
m_lowShelfGainModel( 0.0 , -20, 20, 0.001, this, tr( "Low shelf gain" ) ),
|
||||
m_para1GainModel( 0.0 , -20, 20, 0.001, this, tr( "Peak 1 gain" ) ),
|
||||
m_para2GainModel( 0.0 , -20, 20, 0.001, this, tr( "Peak 2 gain" ) ),
|
||||
m_para3GainModel( 0.0 , -20, 20, 0.001, this, tr( "Peak 3 gain" ) ),
|
||||
m_para4GainModel( 0.0 , -20, 20, 0.001, this, tr( "Peak 4 gain" ) ),
|
||||
m_highShelfGainModel( 0.0 , -20, 20, 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.0, 10.0 , 0.001, this , tr( "Low Shelf res" ) ),
|
||||
m_para1ResModel( 1.4 ,0.55, 10.0 , 0.001, this , tr( "Peak 1 res" ) ),
|
||||
m_para2ResModel( 1.4, 0.55, 10.0 , 0.001, this , tr( "Peak 2 res" ) ),
|
||||
m_para3ResModel( 1.4, 0.55, 10.0 , 0.001, this , tr( "Peak 3 res" ) ),
|
||||
m_para4ResModel( 1.4, 0.55, 10.0 , 0.001, this , tr( "Peak 4 res" ) ),
|
||||
m_highShelfResModel( 1.4, 0.001, 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_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( 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( true, this , tr( "LP 12" ) ),
|
||||
m_lp24Model( false, this , tr( "LP 24" ) ),
|
||||
m_lp48Model( false, this , tr( "LP 48" ) ),
|
||||
m_hp12Model( true, this , tr( "HP 12" ) ),
|
||||
m_hp24Model( false, this , tr( "HP 24" ) ),
|
||||
m_hp48Model( false, this , tr( "HP 48" ) ),
|
||||
m_analyzeModel( true, this , tr( "Analyze enable" ) )
|
||||
|
||||
{
|
||||
m_hpFeqModel.setScaleLogarithmic( true );
|
||||
m_lowShelfFreqModel.setScaleLogarithmic( true );
|
||||
m_para1FreqModel.setScaleLogarithmic( true );
|
||||
m_para2FreqModel.setScaleLogarithmic( true );
|
||||
m_para3FreqModel.setScaleLogarithmic( true );
|
||||
m_para4FreqModel.setScaleLogarithmic( true );
|
||||
m_highShelfFreqModel.setScaleLogarithmic( true );
|
||||
m_lpFreqModel.setScaleLogarithmic( true );
|
||||
|
||||
m_para1GainModel.setScaleLogarithmic( true );
|
||||
m_inPeakL = 0;
|
||||
m_inPeakR = 0;
|
||||
m_lowShelfPeakL = 0; m_lowShelfPeakR = 0;
|
||||
m_para1PeakL = 0; m_para1PeakR = 0;
|
||||
m_para2PeakL = 0; m_para2PeakR = 0;
|
||||
m_para3PeakL = 0; m_para3PeakR = 0;
|
||||
m_para4PeakL = 0; m_para4PeakR = 0;
|
||||
m_highShelfPeakL = 0; m_highShelfPeakR = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqControls::loadSettings( const QDomElement &_this )
|
||||
{
|
||||
m_inGainModel.loadSettings( _this, "Inputgain" );
|
||||
m_outGainModel.loadSettings( _this, "Outputgain");
|
||||
m_lowShelfGainModel.loadSettings( _this , "Lowshelfgain" );
|
||||
m_para1GainModel.loadSettings( _this, "Peak1gain" );
|
||||
m_para2GainModel.loadSettings( _this, "Peak2gain" );
|
||||
m_para3GainModel.loadSettings( _this, "Peak3gain" );
|
||||
m_para4GainModel.loadSettings( _this, "Peak4gain" );
|
||||
m_highShelfGainModel.loadSettings( _this , "HighShelfgain");
|
||||
|
||||
m_hpResModel.loadSettings( _this ,"HPres");
|
||||
m_lowShelfResModel.loadSettings( _this, "LowShelfres" );
|
||||
m_para1ResModel.loadSettings( _this ,"Peak1res" );
|
||||
m_para2ResModel.loadSettings( _this ,"Peak2res" );
|
||||
m_para3ResModel.loadSettings( _this ,"Peak3res" );
|
||||
m_para4ResModel.loadSettings( _this ,"Peak4res" );
|
||||
m_highShelfResModel.loadSettings( _this, "HighShelfres" );
|
||||
m_lpResModel.loadSettings( _this, "LPres");
|
||||
|
||||
m_hpFeqModel.loadSettings( _this, "HPfreq" );
|
||||
m_lowShelfFreqModel.loadSettings( _this, "LowShelffreq" );
|
||||
m_para1FreqModel.loadSettings( _this, "Peak1freq" );
|
||||
m_para2FreqModel.loadSettings( _this, "Peak2freq" );
|
||||
m_para3FreqModel.loadSettings( _this, "Peak3freq" );
|
||||
m_para4FreqModel.loadSettings( _this, "Peak4freq" );
|
||||
m_highShelfFreqModel.loadSettings( _this, "Highshelffreq" );
|
||||
m_lpFreqModel.loadSettings( _this, "LPfreq" );
|
||||
|
||||
m_hpActiveModel.loadSettings( _this, "HPactive" );
|
||||
m_lowShelfActiveModel.loadSettings( _this, "Lowshelfactive" );
|
||||
m_para1ActiveModel.loadSettings( _this, "Peak1active");
|
||||
m_para2ActiveModel.loadSettings( _this, "Peak2active");
|
||||
m_para3ActiveModel.loadSettings( _this, "Peak3active");
|
||||
m_para4ActiveModel.loadSettings( _this, "Peak4active");
|
||||
m_highShelfActiveModel.loadSettings( _this, "Highshelfactive" );
|
||||
m_lpActiveModel.loadSettings( _this, "LPactive" );
|
||||
|
||||
m_lp12Model.loadSettings( _this , "LP12" );
|
||||
m_lp24Model.loadSettings( _this , "LP24" );
|
||||
m_lp48Model.loadSettings( _this , "LP48" );
|
||||
|
||||
m_hp12Model.loadSettings( _this , "HP12" );
|
||||
m_hp24Model.loadSettings( _this , "HP24" );
|
||||
m_hp48Model.loadSettings( _this , "HP48" );
|
||||
m_analyzeModel.loadSettings( _this, "Analyzeenable");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqControls::saveSettings( QDomDocument &doc, QDomElement &parent )
|
||||
{
|
||||
|
||||
m_inGainModel.saveSettings( doc, parent, "Inputgain" );
|
||||
m_outGainModel.saveSettings( doc, parent, "Outputgain");
|
||||
m_lowShelfGainModel.saveSettings( doc, parent , "Lowshelfgain" );
|
||||
m_para1GainModel.saveSettings( doc, parent, "Peak1gain" );
|
||||
m_para2GainModel.saveSettings( doc, parent, "Peak2gain" );
|
||||
m_para3GainModel.saveSettings( doc, parent, "Peak3gain" );
|
||||
m_para4GainModel.saveSettings( doc, parent, "Peak4gain" );
|
||||
m_highShelfGainModel.saveSettings( doc, parent, "HighShelfgain");
|
||||
|
||||
m_hpResModel.saveSettings( doc, parent ,"HPres");
|
||||
m_lowShelfResModel.saveSettings( doc, parent, "LowShelfres" );
|
||||
m_para1ResModel.saveSettings( doc, parent,"Peak1res" );
|
||||
m_para2ResModel.saveSettings( doc, parent,"Peak2res" );
|
||||
m_para3ResModel.saveSettings( doc, parent,"Peak3res" );
|
||||
m_para4ResModel.saveSettings( doc, parent,"Peak4res" );
|
||||
m_highShelfResModel.saveSettings( doc, parent, "HighShelfres" );
|
||||
m_lpResModel.saveSettings( doc, parent, "LPres");
|
||||
|
||||
m_hpFeqModel.saveSettings( doc, parent, "HPfreq" );
|
||||
m_lowShelfFreqModel.saveSettings( doc, parent, "LowShelffreq" );
|
||||
m_para1FreqModel.saveSettings( doc, parent, "Peak1freq" );
|
||||
m_para2FreqModel.saveSettings( doc, parent, "Peak2freq" );
|
||||
m_para3FreqModel.saveSettings( doc, parent, "Peak3freq" );
|
||||
m_para4FreqModel.saveSettings( doc, parent, "Peak4freq" );
|
||||
m_highShelfFreqModel.saveSettings( doc, parent, "Highshelffreq" );
|
||||
m_lpFreqModel.saveSettings( doc, parent, "LPfreq" );
|
||||
|
||||
m_hpActiveModel.saveSettings( doc, parent, "HPactive" );
|
||||
m_lowShelfActiveModel.saveSettings( doc, parent, "Lowshelfactive" );
|
||||
m_para1ActiveModel.saveSettings( doc, parent, "Peak1active" );
|
||||
m_para2ActiveModel.saveSettings( doc, parent, "Peak2active" );
|
||||
m_para3ActiveModel.saveSettings( doc, parent, "Peak3active" );
|
||||
m_para4ActiveModel.saveSettings( doc, parent, "Peak4active" );
|
||||
m_highShelfActiveModel.saveSettings( doc, parent, "Highshelfactive" );
|
||||
m_lpActiveModel.saveSettings( doc, parent, "LPactive" );
|
||||
|
||||
m_lp12Model.saveSettings( doc, parent, "LP12" );
|
||||
m_lp24Model.saveSettings( doc, parent, "LP24" );
|
||||
m_lp48Model.saveSettings( doc, parent, "LP48" );
|
||||
|
||||
m_hp12Model.saveSettings( doc, parent, "HP12" );
|
||||
m_hp24Model.saveSettings( doc, parent, "HP24" );
|
||||
m_hp48Model.saveSettings( doc, parent, "HP48" );
|
||||
m_analyzeModel.saveSettings( doc, parent, "Analyzeenable");
|
||||
|
||||
}
|
||||
|
||||
127
plugins/eq/eqcontrols.h
Normal file
127
plugins/eq/eqcontrols.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* eqcontrols.h - defination of EqControls class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 EQCONTROLS_H
|
||||
#define EQCONTROLS_H
|
||||
|
||||
#include "EffectControls.h"
|
||||
#include "eqcontrolsdialog.h"
|
||||
#include "Knob.h"
|
||||
|
||||
class EqEffect;
|
||||
|
||||
class EqControls : public EffectControls
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EqControls( EqEffect* effect );
|
||||
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()
|
||||
{
|
||||
printf("create dialog\n");
|
||||
return new EqControlsDialog( this );
|
||||
}
|
||||
|
||||
float m_inPeakL;
|
||||
float m_inPeakR;
|
||||
float m_outPeakL;
|
||||
float m_outPeakR;
|
||||
float m_lowShelfPeakL, m_lowShelfPeakR;
|
||||
float m_para1PeakL, m_para1PeakR;
|
||||
float m_para2PeakL, m_para2PeakR;
|
||||
float m_para3PeakL, m_para3PeakR;
|
||||
float m_para4PeakL, m_para4PeakR;
|
||||
float m_highShelfPeakL, m_highShelfPeakR;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
EqEffect* m_effect;
|
||||
|
||||
FloatModel m_inGainModel;
|
||||
FloatModel m_outGainModel;
|
||||
FloatModel m_lowShelfGainModel;
|
||||
FloatModel m_para1GainModel;
|
||||
FloatModel m_para2GainModel;
|
||||
FloatModel m_para3GainModel;
|
||||
FloatModel m_para4GainModel;
|
||||
FloatModel m_highShelfGainModel;
|
||||
|
||||
FloatModel m_hpResModel;
|
||||
FloatModel m_lowShelfResModel;
|
||||
FloatModel m_para1ResModel;
|
||||
FloatModel m_para2ResModel;
|
||||
FloatModel m_para3ResModel;
|
||||
FloatModel m_para4ResModel;
|
||||
FloatModel m_highShelfResModel;
|
||||
FloatModel m_lpResModel;
|
||||
|
||||
FloatModel m_hpFeqModel;
|
||||
FloatModel m_lowShelfFreqModel;
|
||||
FloatModel m_para1FreqModel;
|
||||
FloatModel m_para2FreqModel;
|
||||
FloatModel m_para3FreqModel;
|
||||
FloatModel m_para4FreqModel;
|
||||
FloatModel m_highShelfFreqModel;
|
||||
FloatModel m_lpFreqModel;
|
||||
|
||||
BoolModel m_hpActiveModel;
|
||||
BoolModel m_lowShelfActiveModel;
|
||||
BoolModel m_para1ActiveModel;
|
||||
BoolModel m_para2ActiveModel;
|
||||
BoolModel m_para3ActiveModel;
|
||||
BoolModel m_para4ActiveModel;
|
||||
BoolModel m_highShelfActiveModel;
|
||||
BoolModel m_lpActiveModel;
|
||||
|
||||
BoolModel m_lp12Model;
|
||||
BoolModel m_lp24Model;
|
||||
BoolModel m_lp48Model;
|
||||
|
||||
BoolModel m_hp12Model;
|
||||
BoolModel m_hp24Model;
|
||||
BoolModel m_hp48Model;
|
||||
|
||||
BoolModel m_analyzeModel;
|
||||
|
||||
friend class EqControlsDialog;
|
||||
friend class EqEffect;
|
||||
|
||||
};
|
||||
|
||||
#endif // EQCONTROLS_H
|
||||
164
plugins/eq/eqcontrolsdialog.cpp
Normal file
164
plugins/eq/eqcontrolsdialog.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* eqcontrolsdialog.cpp - defination of EqControlsDialog class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 "eqcontrolsdialog.h"
|
||||
#include "eqcontrols.h"
|
||||
#include "embed.h"
|
||||
#include "Fader.h"
|
||||
#include "eqfader.h"
|
||||
#include "Engine.h"
|
||||
#include "AutomatableButton.h"
|
||||
#include "QWidget"
|
||||
#include "MainWindow.h"
|
||||
#include "LedCheckbox.h"
|
||||
|
||||
|
||||
|
||||
|
||||
EqControlsDialog::EqControlsDialog(EqControls *controls) :
|
||||
EffectControlDialog( controls )
|
||||
|
||||
{
|
||||
m_controls = controls;
|
||||
setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
|
||||
setPalette( pal );
|
||||
setFixedSize( 350, 275 );
|
||||
|
||||
m_parameterWidget = new EqParameterWidget( this );
|
||||
m_parameterWidget->move( 50, 5 );
|
||||
// m_inSpec = new EqSpectrumView( controls->m_effect, this);
|
||||
|
||||
setBand( 0, &controls->m_hpActiveModel, &controls->m_hpFeqModel, &controls->m_hpResModel, 0, QColor(173, 115, 57), tr( "HP" ) ,0,0);
|
||||
setBand( 1, &controls->m_lowShelfActiveModel, &controls->m_lowShelfFreqModel, &controls->m_lowShelfResModel, &controls->m_lowShelfGainModel, QColor(255, 0, 0), tr( "Low Shelf" ), &controls->m_lowShelfPeakL , &controls->m_lowShelfPeakR );
|
||||
setBand( 2, &controls->m_para1ActiveModel, &controls->m_para1FreqModel, &controls->m_para1ResModel, &controls->m_para1GainModel, QColor(255, 173, 115), tr( "Peak 1" ), &controls->m_para1PeakL, &controls->m_para1PeakR );
|
||||
setBand( 3, &controls->m_para2ActiveModel, &controls->m_para2FreqModel, &controls->m_para2ResModel, &controls->m_para2GainModel, QColor(255, 255, 0), tr( "Peak 2" ), &controls->m_para2PeakL, &controls->m_para2PeakR );
|
||||
setBand( 4, &controls->m_para3ActiveModel, &controls->m_para3FreqModel, &controls->m_para3ResModel, &controls->m_para3GainModel, QColor(0, 255, 0), tr( "Peak 3" ), &controls->m_para3PeakL, &controls->m_para3PeakR );
|
||||
setBand( 5, &controls->m_para4ActiveModel, &controls->m_para4FreqModel, &controls->m_para4ResModel, &controls->m_para4GainModel, QColor(0, 186, 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(222, 0, 222 ), tr( "High Shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR );
|
||||
setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(156, 156, 156 ), 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 );
|
||||
|
||||
m_inGainFader = new EqFader( &controls->m_inGainModel, tr( "In Gain" ), this, &controls->m_inPeakL, &controls->m_inPeakR);
|
||||
m_inGainFader->move( 10, 5 );
|
||||
|
||||
m_outGainFader = new EqFader( &controls->m_outGainModel, tr( "Out Gain" ), this, &controls->m_outPeakL, &controls->m_outPeakR );
|
||||
m_outGainFader->move( 315, 5 );
|
||||
//gain faders
|
||||
|
||||
int fo = (cw * 0.5) - (m_outGainFader->width() * 0.5 );
|
||||
|
||||
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->setMinimumHeight(80);
|
||||
m_gainFader->resize(m_gainFader->width() , 80);
|
||||
}
|
||||
|
||||
for( int i = 0; i < m_parameterWidget->bandCount() ; i++)
|
||||
{
|
||||
m_resKnob = new Knob( knobBright_26, this );
|
||||
m_resKnob->move(cw * i + ko , 205 );
|
||||
m_resKnob->setVolumeKnob(false);
|
||||
m_resKnob->setModel( m_parameterWidget->getBandModels( i )->res );
|
||||
|
||||
m_freqKnob = new Knob( knobBright_26, this );
|
||||
m_freqKnob->move(cw * i + ko, 235 );
|
||||
m_freqKnob->setVolumeKnob( false );
|
||||
m_freqKnob->setModel( m_parameterWidget->getBandModels( i )->freq );
|
||||
|
||||
m_activeBox = new LedCheckBox( m_parameterWidget->getBandModels( i )->name , this );
|
||||
m_activeBox->move( cw * i + fo + 3, 260 );
|
||||
m_activeBox->setModel( m_parameterWidget->getBandModels( i )->active );
|
||||
}
|
||||
|
||||
//hp filter type
|
||||
|
||||
m_hp12Box = new LedCheckBox( tr( "12dB" ), this );
|
||||
m_hp12Box->move( cw*0 + ko, 175 );
|
||||
m_hp12Box->setModel( &controls->m_hp12Model );
|
||||
m_hp24Box = new LedCheckBox( tr( "24dB" ), this );
|
||||
m_hp24Box->move( cw*0 + ko, 155 );
|
||||
m_hp24Box->setModel( &controls->m_hp24Model );
|
||||
|
||||
m_hp48Box = new LedCheckBox( tr( "48dB" ), this );
|
||||
m_hp48Box->move( cw*0 + ko, 135 );
|
||||
m_hp48Box->setModel( &controls->m_hp48Model );
|
||||
|
||||
//LP filter type
|
||||
|
||||
m_lp12Box = new LedCheckBox( tr( "12dB"), this );
|
||||
m_lp12Box->move( cw*7 + ko -5 , 175 );
|
||||
m_lp12Box->setModel( &controls->m_lp12Model );
|
||||
m_lp24Box = new LedCheckBox( tr( "24dB"), this );
|
||||
m_lp24Box->move( cw*7 + ko - 5, 155 );
|
||||
m_lp24Box->setModel( &controls->m_lp24Model );
|
||||
m_lp48Box = new LedCheckBox( tr( "48dB"), this );
|
||||
m_lp48Box->move( cw*7 + ko - 5, 135 );
|
||||
m_lp48Box->setModel( &controls->m_lp48Model );
|
||||
|
||||
automatableButtonGroup *lpBtnGrp = new automatableButtonGroup(this,tr ( "lp grp" ) );
|
||||
lpBtnGrp->addButton(m_lp12Box);
|
||||
lpBtnGrp->addButton(m_lp24Box );
|
||||
lpBtnGrp->addButton(m_lp48Box );
|
||||
connect( m_lp12Box, SIGNAL( clicked() ), lpBtnGrp , SLOT( updateButtons() ) );
|
||||
connect( m_lp24Box, SIGNAL( clicked() ), lpBtnGrp , SLOT( updateButtons() ) );
|
||||
connect( m_lp48Box, SIGNAL( clicked() ), lpBtnGrp , SLOT( updateButtons() ) );
|
||||
connect( &controls->m_lp12Model, SIGNAL( dataChanged() ), lpBtnGrp, SLOT( updateButtons() ) );
|
||||
connect( &controls->m_lp24Model, SIGNAL( dataChanged() ), lpBtnGrp, SLOT( updateButtons() ) );
|
||||
connect( &controls->m_lp48Model, SIGNAL( dataChanged() ), lpBtnGrp, SLOT( updateButtons() ) );
|
||||
|
||||
|
||||
|
||||
automatableButtonGroup *hpBtnGrp = new automatableButtonGroup( this, tr( "hp grp" ) );
|
||||
hpBtnGrp->addButton(m_hp12Box );
|
||||
hpBtnGrp->addButton(m_hp24Box );
|
||||
hpBtnGrp->addButton(m_hp48Box );
|
||||
connect( m_hp12Box, SIGNAL ( clicked() ), hpBtnGrp, SLOT( updateButtons() ) );
|
||||
connect( m_hp24Box, SIGNAL ( clicked() ), hpBtnGrp, SLOT( updateButtons() ) );
|
||||
connect( m_hp48Box, SIGNAL ( clicked() ), hpBtnGrp, SLOT( updateButtons() ) );
|
||||
connect( &controls->m_hp12Model, SIGNAL( dataChanged() ), hpBtnGrp, SLOT( updateButtons() ) );
|
||||
connect( &controls->m_hp24Model, SIGNAL( dataChanged() ), hpBtnGrp, SLOT( updateButtons() ) );
|
||||
connect( &controls->m_hp48Model, SIGNAL( dataChanged() ), hpBtnGrp, SLOT( updateButtons() ) );
|
||||
|
||||
|
||||
|
||||
|
||||
//Analize Box
|
||||
m_analyzeBox = new LedCheckBox( tr( "Analyze" ), this );
|
||||
m_analyzeBox->move( cw*1 + ko + 5, 10 );
|
||||
m_analyzeBox->setModel( &controls->m_analyzeModel );
|
||||
|
||||
}
|
||||
|
||||
void EqControlsDialog::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
m_originalHeight = parentWidget()->height() == 150 ? m_originalHeight : parentWidget()->height() ;
|
||||
parentWidget()->setFixedHeight( parentWidget()->height() == m_originalHeight ? 150 : m_originalHeight );
|
||||
update();
|
||||
}
|
||||
94
plugins/eq/eqcontrolsdialog.h
Normal file
94
plugins/eq/eqcontrolsdialog.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* eqcontrolsdialog.h - defination of EqControlsDialog class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 EQCONTROLSDIALOG_H
|
||||
#define EQCONTROLSDIALOG_H
|
||||
|
||||
#include "EffectControlDialog.h"
|
||||
#include "Fader.h"
|
||||
#include "Knob.h"
|
||||
#include "LedCheckbox.h"
|
||||
#include "eqparameterwidget.h"
|
||||
#include "MainWindow.h"
|
||||
#include "qpushbutton.h"
|
||||
//#include "eqspectrumview.h"
|
||||
|
||||
class EqControls;
|
||||
|
||||
class EqControlsDialog : public EffectControlDialog
|
||||
{
|
||||
|
||||
public:
|
||||
EqControlsDialog( EqControls* controls );
|
||||
virtual ~EqControlsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
EqBand * setBand(EqControls *controls);
|
||||
|
||||
private slots:
|
||||
void updateVuMeters();
|
||||
|
||||
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;
|
||||
|
||||
LedCheckBox* m_analyzeBox;
|
||||
|
||||
EqParameterWidget* m_parameterWidget;
|
||||
// EqSpectrumView* m_inSpec;
|
||||
|
||||
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* filterModels = m_parameterWidget->getBandModels( index );
|
||||
filterModels->active = active;
|
||||
filterModels->freq = freq;
|
||||
filterModels->res = res;
|
||||
filterModels->color = color;
|
||||
filterModels->gain = gain;
|
||||
filterModels->peakL = peakL;
|
||||
filterModels->peakR = peakR;
|
||||
return filterModels;
|
||||
}
|
||||
|
||||
int m_originalHeight;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // EQCONTROLSDIALOG_H
|
||||
314
plugins/eq/eqeffect.cpp
Normal file
314
plugins/eq/eqeffect.cpp
Normal file
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* eqeffect.cpp - defination of EqEffect class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 "eqeffect.h"
|
||||
#include "embed.cpp"
|
||||
#include "lmms_math.h"
|
||||
#include "BasicFilters.h"
|
||||
#include "interpolation.h"
|
||||
#include "Engine.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
//TODO
|
||||
//re write to store data from each filter(models,name, storeage name ) in a class, stored in array
|
||||
//then just loop ever array for each section
|
||||
|
||||
const int MAX_BANDS = 249;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
Plugin::Descriptor PLUGIN_EXPORT eq_plugin_descriptor =
|
||||
{
|
||||
STRINGIFY( PLUGIN_NAME ),
|
||||
"Eq",
|
||||
QT_TRANSLATE_NOOP( "pluginBrowser", "A native eq plugin" ),
|
||||
"Dave French <contact/dot/dave/dot/french3/at/googlemail/dot/com>",
|
||||
0x0100,
|
||||
Plugin::Effect,
|
||||
new PluginPixmapLoader( "logo" ),
|
||||
NULL,
|
||||
NULL
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
EqEffect::EqEffect(Model *parent, const Plugin::Descriptor::SubPluginFeatures::Key *key) :
|
||||
Effect( &eq_plugin_descriptor, parent, key ),
|
||||
m_eqControls( this )
|
||||
|
||||
|
||||
|
||||
{
|
||||
m_dFilterCount = 4;
|
||||
m_downsampleFilters = new EqLp12Filter[m_dFilterCount];
|
||||
for( int i = 0; i < m_dFilterCount; i++)
|
||||
{
|
||||
m_downsampleFilters[i].setFrequency(20000);
|
||||
m_downsampleFilters[i].setQ(0.66);
|
||||
m_downsampleFilters[i].setGain(0);
|
||||
m_downsampleFilters[i].setSampleRate(Engine::mixer()->processingSampleRate() * 2 );
|
||||
}
|
||||
m_upBuf = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EqEffect::~EqEffect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool EqEffect::processAudioBuffer(sampleFrame *buf, const fpp_t frames)
|
||||
{
|
||||
if( !isEnabled() || !isRunning () )
|
||||
{
|
||||
return( false );
|
||||
}
|
||||
double outSum = 0.0;
|
||||
const float d = dryLevel();
|
||||
const float w = wetLevel();
|
||||
const float outGain = m_eqControls.m_outGainModel.value();
|
||||
const int sampleRate = Engine::mixer()->processingSampleRate() * 2;
|
||||
sample_t dryS[2];
|
||||
sampleFrame m_inPeak;
|
||||
|
||||
//TODO UPSAMPLE
|
||||
upsample( buf, frames );
|
||||
|
||||
gain(m_upBuf , m_upBufFrames, m_eqControls.m_inGainModel.value(), &m_inPeak );
|
||||
m_eqControls.m_inPeakL = m_eqControls.m_inPeakL < m_inPeak[0] ? m_inPeak[0] : m_eqControls.m_inPeakL;
|
||||
m_eqControls.m_inPeakR = m_eqControls.m_inPeakR < m_inPeak[1] ? m_inPeak[0] : m_eqControls.m_inPeakR;
|
||||
|
||||
if(m_eqControls.m_hpActiveModel.value() ){
|
||||
m_hp12.setSampleRate( sampleRate );
|
||||
m_hp12.setFrequency( m_eqControls.m_hpFeqModel.value() );
|
||||
m_hp12.setQ( m_eqControls.m_hpResModel.value() );
|
||||
m_hp12.processBuffer( m_upBuf , m_upBufFrames );
|
||||
|
||||
if( m_eqControls.m_hp24Model.value() || m_eqControls.m_hp48Model.value() )
|
||||
{
|
||||
m_hp24.setSampleRate( sampleRate );
|
||||
m_hp24.setFrequency( m_eqControls.m_hpFeqModel.value() );
|
||||
m_hp24.setQ( m_eqControls.m_hpResModel.value() );
|
||||
m_hp24.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_hp48Model.value() )
|
||||
{
|
||||
m_hp480.setSampleRate( sampleRate );
|
||||
m_hp480.setFrequency( m_eqControls.m_hpFeqModel.value() );
|
||||
m_hp480.setQ( m_eqControls.m_hpResModel.value() );
|
||||
m_hp480.processBuffer( m_upBuf , m_upBufFrames );
|
||||
|
||||
m_hp481.setSampleRate( sampleRate );
|
||||
m_hp481.setFrequency( m_eqControls.m_hpFeqModel.value() );
|
||||
m_hp481.setQ( m_eqControls.m_hpResModel.value() );
|
||||
m_hp481.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_eqControls.m_lowShelfActiveModel.value() )
|
||||
{
|
||||
m_lowShelf.setSampleRate( sampleRate );
|
||||
m_lowShelf.setFrequency( m_eqControls.m_lowShelfFreqModel.value() );
|
||||
m_lowShelf.setQ( m_eqControls.m_lowShelfResModel .value() );
|
||||
m_lowShelf.setGain( m_eqControls.m_lowShelfGainModel.value() );
|
||||
m_lowShelf.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para1ActiveModel.value() )
|
||||
{
|
||||
m_para1.setSampleRate(sampleRate );
|
||||
m_para1.setFrequency( m_eqControls.m_para1FreqModel.value() );
|
||||
m_para1.setQ( m_eqControls.m_para1ResModel.value() );
|
||||
m_para1.setGain( m_eqControls.m_para1GainModel.value() );
|
||||
m_para1.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para2ActiveModel.value() )
|
||||
{
|
||||
m_para2.setSampleRate( sampleRate );
|
||||
m_para2.setFrequency( m_eqControls.m_para2FreqModel.value() );
|
||||
m_para2.setQ( m_eqControls.m_para2ResModel.value() );
|
||||
m_para2.setGain( m_eqControls.m_para2GainModel.value() );
|
||||
m_para2.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para3ActiveModel.value() )
|
||||
{
|
||||
m_para3.setSampleRate( sampleRate);
|
||||
m_para3.setFrequency( m_eqControls.m_para3FreqModel.value() );
|
||||
m_para3.setQ( m_eqControls.m_para3ResModel.value() );
|
||||
m_para3.setGain( m_eqControls.m_para3GainModel.value() );
|
||||
m_para3.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para4ActiveModel.value() )
|
||||
{
|
||||
m_para4.setSampleRate( sampleRate );
|
||||
m_para4.setFrequency( m_eqControls.m_para4FreqModel.value() );
|
||||
m_para4.setQ( m_eqControls.m_para4ResModel.value() );
|
||||
m_para4.setGain( m_eqControls.m_para4GainModel.value() );
|
||||
m_para4.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_highShelfActiveModel.value() )
|
||||
{
|
||||
m_highShelf.setSampleRate( sampleRate );
|
||||
m_highShelf.setFrequency( m_eqControls.m_highShelfFreqModel.value() );
|
||||
m_highShelf.setQ( m_eqControls.m_highShelfResModel.value() );
|
||||
m_highShelf.setGain( m_eqControls.m_highShelfGainModel.value() );
|
||||
m_highShelf.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if(m_eqControls.m_lpActiveModel.value() ){
|
||||
m_lp12.setSampleRate( sampleRate );
|
||||
m_lp12.setFrequency( m_eqControls.m_lpFreqModel.value() );
|
||||
m_lp12.setQ( m_eqControls.m_lpResModel.value() );
|
||||
m_lp12.processBuffer( m_upBuf , m_upBufFrames );
|
||||
|
||||
if( m_eqControls.m_lp24Model.value() || m_eqControls.m_lp48Model.value() )
|
||||
{
|
||||
m_lp24.setSampleRate( sampleRate );
|
||||
m_lp24.setFrequency( m_eqControls.m_lpFreqModel.value() );
|
||||
m_lp24.setQ( m_eqControls.m_lpResModel.value() );
|
||||
m_lp24.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_lp48Model.value() )
|
||||
{
|
||||
m_lp480.setSampleRate( sampleRate );
|
||||
m_lp480.setFrequency( m_eqControls.m_lpFreqModel.value() );
|
||||
m_lp480.setQ( m_eqControls.m_lpResModel.value() );
|
||||
m_lp480.processBuffer( m_upBuf , m_upBufFrames );
|
||||
|
||||
m_lp481.setSampleRate( sampleRate );
|
||||
m_lp481.setFrequency( m_eqControls.m_lpFreqModel.value() );
|
||||
m_lp481.setQ( m_eqControls.m_lpResModel.value() );
|
||||
m_lp481.processBuffer( m_upBuf , m_upBufFrames );
|
||||
}
|
||||
}
|
||||
|
||||
sampleFrame outPeak;
|
||||
gain( m_upBuf , m_upBufFrames, outGain, &outPeak );
|
||||
m_eqControls.m_outPeakL = m_eqControls.m_outPeakL < outPeak[0] ? outPeak[0] : m_eqControls.m_outPeakL;
|
||||
m_eqControls.m_outPeakR = m_eqControls.m_outPeakR < outPeak[1] ? outPeak[0] : m_eqControls.m_outPeakR;
|
||||
|
||||
//TODO lp filter before downsample
|
||||
for( int i =0; i < m_dFilterCount; i++)
|
||||
{
|
||||
m_downsampleFilters[i].processBuffer(m_upBuf , m_upBufFrames );
|
||||
}
|
||||
|
||||
downSample( buf, frames );
|
||||
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
buf[f][0] = ( d * dryS[0] ) + ( w * buf[f][0] );
|
||||
buf[f][1] = ( d * dryS[1] ) + ( w * buf[f][1] );
|
||||
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
|
||||
}
|
||||
checkGate( outSum / frames );
|
||||
|
||||
return isRunning();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqEffect::gain(sampleFrame *buf, const fpp_t frames, float scale, sampleFrame* peak)
|
||||
{
|
||||
peak[0][0] = 0.0f; peak[0][1] = 0.0f;
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
buf[f][0] *= scale;
|
||||
buf[f][1] *= scale;
|
||||
|
||||
if( fabs( buf[f][0] ) > peak[0][0] )
|
||||
{
|
||||
peak[0][0] = fabs( buf[f][0] );
|
||||
}
|
||||
if( fabs( buf[f][1] ) > peak[0][1] )
|
||||
{
|
||||
peak[0][1] = fabs( buf[f][0] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sampleFrame m_lastUpFrame;
|
||||
void EqEffect::upsample(sampleFrame *buf, const fpp_t frames)
|
||||
{
|
||||
|
||||
if(m_upBufFrames != frames * 2 )
|
||||
{
|
||||
if( m_upBuf )
|
||||
{
|
||||
delete m_upBuf;
|
||||
}
|
||||
m_upBuf = new sampleFrame[frames * 2];
|
||||
m_upBufFrames = frames * 2;
|
||||
}
|
||||
|
||||
for( int f = 0, f2 = 0; f < frames; ++f, f2 += 2 )
|
||||
{
|
||||
m_upBuf[f2][0] = linearInterpolate(m_lastUpFrame[0],buf[f][0], 0.5);
|
||||
m_upBuf[f2][1] = linearInterpolate(m_lastUpFrame[1],buf[f][1], 0.5);
|
||||
m_upBuf[f2+1][0] = buf[f][0];
|
||||
m_upBuf[f2+1][1] = buf[f][1];
|
||||
|
||||
m_lastUpFrame[0] = buf[f][0];
|
||||
m_lastUpFrame[1] = buf[f][1];
|
||||
}
|
||||
}
|
||||
|
||||
void EqEffect::downSample(sampleFrame *buf, const fpp_t frames)
|
||||
{
|
||||
for( int f = 0, f2 = 0; f < frames; ++f, f2 += 2 )
|
||||
{
|
||||
buf[f][0] = m_upBuf[f2][0];
|
||||
buf[f][1] = m_upBuf[f2][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
//needed for getting plugin out of shared lib
|
||||
Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data )
|
||||
{
|
||||
return new EqEffect( parent , static_cast<const Plugin::Descriptor::SubPluginFeatures::Key *>( data ) );
|
||||
}
|
||||
|
||||
}}
|
||||
80
plugins/eq/eqeffect.h
Normal file
80
plugins/eq/eqeffect.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* eqeffect.h - defination of EqEffect class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 EQEFFECT_H
|
||||
#define EQEFFECT_H
|
||||
|
||||
#include "Effect.h"
|
||||
#include "eqcontrols.h"
|
||||
#include "lmms_math.h"
|
||||
#include "BasicFilters.h"
|
||||
#include "eqfilter.h"
|
||||
|
||||
class EqEffect : public Effect
|
||||
{
|
||||
public:
|
||||
EqEffect( Model* parent , const Descriptor::SubPluginFeatures::Key* key );
|
||||
virtual ~EqEffect();
|
||||
virtual bool processAudioBuffer( sampleFrame *buf, const fpp_t frames );
|
||||
virtual EffectControls* controls()
|
||||
{
|
||||
return &m_eqControls;
|
||||
}
|
||||
void gain( sampleFrame *buf, const fpp_t frames, float scale, sampleFrame* peak );
|
||||
|
||||
private:
|
||||
EqControls m_eqControls;
|
||||
|
||||
EqHp12Filter m_hp12;
|
||||
EqHp12Filter m_hp24;
|
||||
EqHp12Filter m_hp480;
|
||||
EqHp12Filter m_hp481;
|
||||
|
||||
EqLowShelfFilter m_lowShelf;
|
||||
|
||||
EqPeakFilter m_para1;
|
||||
EqPeakFilter m_para2;
|
||||
EqPeakFilter m_para3;
|
||||
EqPeakFilter m_para4;
|
||||
|
||||
EqHighShelfFilter m_highShelf;
|
||||
|
||||
EqLp12Filter m_lp12;
|
||||
EqLp12Filter m_lp24;
|
||||
EqLp12Filter m_lp480;
|
||||
EqLp12Filter m_lp481;
|
||||
EqLp12Filter* m_downsampleFilters;
|
||||
int m_dFilterCount;
|
||||
sampleFrame* m_upBuf;
|
||||
fpp_t m_upBufFrames;
|
||||
|
||||
// const static int MAX_BANDS = 249;
|
||||
void upsample( sampleFrame *buf, const fpp_t frames );
|
||||
void downSample( sampleFrame *buf, const fpp_t frames );
|
||||
// float m_bands[MAX_BANDS];
|
||||
// float m_energy;
|
||||
|
||||
};
|
||||
|
||||
#endif // EQEFFECT_H
|
||||
0
plugins/eq/eqfader.cpp
Normal file
0
plugins/eq/eqfader.cpp
Normal file
111
plugins/eq/eqfader.h
Normal file
111
plugins/eq/eqfader.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* eqfader.h - defination of EqFader class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 EQFADER_H
|
||||
#define EQFADER_H
|
||||
#include "Fader.h"
|
||||
#include "EffectControls.h"
|
||||
#include "MainWindow.h"
|
||||
#include "qwidget.h"
|
||||
#include "TextFloat.h"
|
||||
#include "qlist.h"
|
||||
|
||||
|
||||
|
||||
class EqFader : public Fader
|
||||
{
|
||||
|
||||
public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
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( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateVuMeters() ) );
|
||||
m_text = 0;
|
||||
QList<TextFloat*> tfs = Engine::mainWindow()->findChildren<TextFloat*>();
|
||||
m_text = tfs.last();
|
||||
if(m_text)
|
||||
{
|
||||
printf("found text float\n");
|
||||
}
|
||||
connect(model , SIGNAL (dataChanged()) , this, SLOT (updateText () ));
|
||||
m_model = model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
~EqFader()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
void updateVuMeters()
|
||||
{
|
||||
const float opl = getPeak_L();
|
||||
const float opr = getPeak_R();
|
||||
const float fall_off = 1.2;
|
||||
if( *m_lPeak > opl )
|
||||
{
|
||||
setPeak_L( *m_lPeak );
|
||||
*m_lPeak = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
setPeak_L( opl/fall_off );
|
||||
}
|
||||
|
||||
if( *m_rPeak > opr )
|
||||
{
|
||||
setPeak_R( *m_rPeak );
|
||||
*m_rPeak = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
setPeak_R( opr/fall_off );
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void updateText()
|
||||
{
|
||||
m_text->setText(QString()+m_model->value());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
float* m_lPeak;
|
||||
float* m_rPeak;
|
||||
TextFloat* m_text;
|
||||
FloatModel* m_model;
|
||||
|
||||
};
|
||||
#endif // EQFADER_H
|
||||
5
plugins/eq/eqfilter.cpp
Normal file
5
plugins/eq/eqfilter.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "eqfilter.h"
|
||||
|
||||
|
||||
|
||||
|
||||
315
plugins/eq/eqfilter.h
Normal file
315
plugins/eq/eqfilter.h
Normal file
@@ -0,0 +1,315 @@
|
||||
/*
|
||||
* eqfilter.cpp - defination of EqFilterclass.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 EQFILTER_H
|
||||
#define EQFILTER_H
|
||||
|
||||
#include "BasicFilters.h"
|
||||
#include "lmms_math.h"
|
||||
|
||||
///
|
||||
/// \brief The EqFilter class.
|
||||
/// A wrapper for the StereoBiQuad class, giving it freq, res, and gain controls.
|
||||
/// It is designed to process periods in one pass, with recalculation of coefficents
|
||||
/// upon parameter changes. The intention is to use this as a bass class, children override
|
||||
/// the calcCoefficents() function, providing the coefficents a1, a2, b0, b1, b2.
|
||||
///
|
||||
class EqFilter : public StereoBiQuad
|
||||
{
|
||||
public:
|
||||
EqFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual inline void setSampleRate( int sampleRate )
|
||||
{
|
||||
if( sampleRate != m_sampleRate )
|
||||
{
|
||||
m_sampleRate = sampleRate;
|
||||
calcCoefficents();
|
||||
}
|
||||
}
|
||||
|
||||
virtual inline void setFrequency( float freq ){
|
||||
if ( freq != m_freq )
|
||||
{
|
||||
m_freq = freq;
|
||||
calcCoefficents();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void setQ( float res )
|
||||
{
|
||||
if ( res != m_res )
|
||||
{
|
||||
m_res = res;
|
||||
calcCoefficents();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void setGain( float gain )
|
||||
{
|
||||
if ( gain != m_gain )
|
||||
{
|
||||
m_gain = gain;
|
||||
calcCoefficents();
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief processBuffer
|
||||
/// \param buf Audio Buffer
|
||||
/// \param frames Count of sampleFrames in Audio Buffer
|
||||
///
|
||||
virtual void processBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
{
|
||||
for ( fpp_t f = 0 ; f < frames ; ++f)
|
||||
{
|
||||
buf[f][0] = update( buf[f][0] , 0);
|
||||
buf[f][1] = update( buf[f][1] , 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
///
|
||||
/// \brief calcCoefficents
|
||||
/// Override this in child classes to provide the coefficents, based on
|
||||
/// Freq, Res and Gain
|
||||
virtual void calcCoefficents(){
|
||||
setCoeffs( 0, 0, 0, 0, 0 );
|
||||
|
||||
}
|
||||
|
||||
float m_sampleRate;
|
||||
float m_freq;
|
||||
float m_res;
|
||||
float m_gain;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief The EqHp12Filter class
|
||||
/// A 2 pole High Pass Filter
|
||||
/// Coefficent calculations from http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
|
||||
class EqHp12Filter : public EqFilter
|
||||
{
|
||||
public :
|
||||
virtual void calcCoefficents()
|
||||
{
|
||||
|
||||
// calc intermediate
|
||||
float w0 = F_2PI * m_freq / m_sampleRate;
|
||||
float c = cosf( w0 );
|
||||
float s = sinf( w0 );
|
||||
float alpha = s / ( 2 * m_res );
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
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;
|
||||
|
||||
setCoeffs( a1, a2, b0, b1, b2 );
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// \brief The EqLp12Filter class.
|
||||
/// A 2 pole low pass filter
|
||||
/// Coefficent calculations from http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
|
||||
///
|
||||
class EqLp12Filter : public EqFilter
|
||||
{
|
||||
public :
|
||||
virtual void calcCoefficents()
|
||||
{
|
||||
|
||||
// calc intermediate
|
||||
float w0 = F_2PI * m_freq / m_sampleRate;
|
||||
float c = cosf( w0 );
|
||||
float s = sinf( w0 );
|
||||
float alpha = s / ( 2 * m_res );
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
//calc coefficents
|
||||
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;
|
||||
|
||||
setCoeffs( a1, a2, b0, b1, b2 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// \brief The EqPeakFilter class
|
||||
/// A Peak Filter
|
||||
/// Coefficent calculations from http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
|
||||
///
|
||||
class EqPeakFilter : public EqFilter
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
virtual void calcCoefficents()
|
||||
{
|
||||
// calc intermediate
|
||||
float w0 = F_2PI * m_freq / m_sampleRate;
|
||||
float c = cosf( w0 );
|
||||
float s = sinf( w0 );
|
||||
float A = pow( 10, m_gain * 0.025);
|
||||
float alpha = s / ( 2 * m_res );
|
||||
|
||||
float 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;
|
||||
|
||||
setCoeffs( a1, a2, b0, b1, b2 );
|
||||
}
|
||||
};
|
||||
|
||||
class EqLowShelfFilter : public EqFilter
|
||||
{
|
||||
public :
|
||||
virtual void calcCoefficents()
|
||||
{
|
||||
|
||||
// calc intermediate
|
||||
float w0 = F_2PI * m_freq / m_sampleRate;
|
||||
float c = cosf( w0 );
|
||||
float s = sinf( w0 );
|
||||
float A = pow( 10, m_gain * 0.025);
|
||||
// float alpha = s / ( 2 * m_res );
|
||||
float beta = sqrt( A ) / m_res;
|
||||
|
||||
float 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;
|
||||
|
||||
setCoeffs( a1, a2, b0, b1, b2 );
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class EqHighShelfFilter : public EqFilter
|
||||
{
|
||||
public :
|
||||
virtual void calcCoefficents()
|
||||
{
|
||||
|
||||
// calc intermediate
|
||||
float w0 = F_2PI * m_freq / m_sampleRate;
|
||||
float c = cosf( w0 );
|
||||
float s = sinf( w0 );
|
||||
float A = pow( 10, m_gain * 0.025 );
|
||||
float beta = sqrt( A ) / m_res;
|
||||
|
||||
float 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;
|
||||
|
||||
setCoeffs( a1, a2, b0, b1, b2 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // EQFILTER_H
|
||||
1
plugins/eq/eqhighshelffileter.h
Normal file
1
plugins/eq/eqhighshelffileter.h
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
0
plugins/eq/eqhp12.h
Normal file
0
plugins/eq/eqhp12.h
Normal file
3
plugins/eq/eqlowshelffilter.h
Normal file
3
plugins/eq/eqlowshelffilter.h
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
|
||||
0
plugins/eq/eqlp12.h
Normal file
0
plugins/eq/eqlp12.h
Normal file
197
plugins/eq/eqparameterwidget.cpp
Normal file
197
plugins/eq/eqparameterwidget.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* eqparameterwidget.cpp - defination of EqParameterWidget class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 "eqparameterwidget.h"
|
||||
#include "QPainter"
|
||||
#include "qwidget.h"
|
||||
#include "lmms_math.h"
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "QMouseEvent"
|
||||
|
||||
EqParameterWidget::EqParameterWidget( QWidget *parent ) :
|
||||
QWidget( parent ),
|
||||
m_bands ( 0 ),
|
||||
m_selectedBand ( 0 )
|
||||
{
|
||||
m_bands = new EqBand[8];
|
||||
resize( 250, 116 );
|
||||
connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) );
|
||||
float totalLength = log10( 21000 );
|
||||
m_pixelsPerUnitWidth = width( ) / totalLength ;
|
||||
float totalHeight = 40;
|
||||
m_pixelsPerUnitHeight = (height() - 4) / ( totalHeight );
|
||||
m_scale = 1.5;
|
||||
m_pixelsPerOctave = freqToXPixel( 10000 ) - freqToXPixel( 5000 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EqParameterWidget::~EqParameterWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::paintEvent( QPaintEvent *event )
|
||||
{
|
||||
QPainter painter( this );
|
||||
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, 3, 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 )
|
||||
{
|
||||
gain = m_bands[i].gain->value();
|
||||
}
|
||||
y = gainToYPixel( gain ) + 3;
|
||||
float bw = m_bands[i].freq->value() / m_bands[i].res->value();
|
||||
m_bands[i].x = x; m_bands[i].y = y;
|
||||
painter.drawPoint( x, y );
|
||||
painter.setPen( QPen( m_bands[i].color, 1, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin ) );
|
||||
if(i == 0 || i == bandCount() - 1 ){
|
||||
painter.drawLine(x, y, x, y - (m_bands[i].res->value() * 4 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.drawLine(freqToXPixel(m_bands[i].freq->value()-(bw * 0.5)),y,freqToXPixel(m_bands[i].freq->value()+(bw * 0.5)),y);
|
||||
}
|
||||
}
|
||||
//Draw color band
|
||||
int sectionLength = width() / bandCount();
|
||||
for( int i = 0; i < bandCount(); i++)
|
||||
{
|
||||
m_bands[i].color.setAlpha( 255 );
|
||||
painter.setPen( QPen( m_bands[i].color, 3, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin ) );
|
||||
painter.drawLine(sectionLength * i , 1, sectionLength * (i+1) , 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::mousePressEvent( QMouseEvent *event )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EqParameterWidget::mouseReleaseEvent( QMouseEvent *event )
|
||||
{
|
||||
m_selectedBand = 0;
|
||||
m_mouseAction = none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EqBand::EqBand() :
|
||||
gain ( 0 ),
|
||||
res ( 0 ),
|
||||
freq ( 0 ),
|
||||
color ( QColor( 255, 255, 255 ) ),
|
||||
name ( QString( "" ) )
|
||||
{
|
||||
}
|
||||
158
plugins/eq/eqparameterwidget.h
Normal file
158
plugins/eq/eqparameterwidget.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* eqparameterwidget.cpp - defination of EqParameterWidget class.
|
||||
*
|
||||
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
|
||||
*
|
||||
* 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 EQPARAMETERWIDGET_H
|
||||
#define EQPARAMETERWIDGET_H
|
||||
#include <QWidget>
|
||||
#include "EffectControls.h"
|
||||
|
||||
|
||||
class EqBand
|
||||
{
|
||||
public :
|
||||
EqBand();
|
||||
FloatModel* gain;
|
||||
FloatModel* res;
|
||||
FloatModel* freq;
|
||||
BoolModel* active;
|
||||
QColor color;
|
||||
int x;
|
||||
int y;
|
||||
QString name;
|
||||
float* peakL;
|
||||
float* peakR;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class EqParameterWidget : public QWidget
|
||||
{
|
||||
|
||||
public:
|
||||
explicit EqParameterWidget( QWidget *parent = 0 );
|
||||
~EqParameterWidget();
|
||||
const int bandCount()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const int maxDistanceFromHandle()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EqBand* getBandModels( int i )
|
||||
{
|
||||
return &m_bands[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
float m_pixelsPerUnitWidth;
|
||||
float m_pixelsPerUnitHeight;
|
||||
float m_pixelsPerOctave;
|
||||
float m_scale;
|
||||
EqBand* m_selectedBand;
|
||||
|
||||
EqBand* selectNearestHandle( const int x, const int y );
|
||||
|
||||
enum MouseAction { none, drag, res } m_mouseAction;
|
||||
int m_oldX, m_oldY;
|
||||
|
||||
inline int freqToXPixel( float freq )
|
||||
{
|
||||
return ( log10( freq ) * m_pixelsPerUnitWidth * m_scale ) - ( width() * 0.5 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float xPixelToFreq( int x )
|
||||
{
|
||||
return pow( 10, ( x + ( width() * 0.5 ) ) / ( m_pixelsPerUnitWidth * m_scale ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline int gainToYPixel( float gain )
|
||||
{
|
||||
return ( height() - 3) - ( gain * m_pixelsPerUnitHeight ) - ( (height() -3 ) * 0.5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline float yPixelToGain( int y )
|
||||
{
|
||||
return ( ( 0.5 * height() ) - y) / m_pixelsPerUnitHeight;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // EQPARAMETERWIDGET_H
|
||||
3
plugins/eq/eqpeekfilter.cpp
Normal file
3
plugins/eq/eqpeekfilter.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "eqpeekfilter.h"
|
||||
|
||||
|
||||
3
plugins/eq/eqpeekfilter.h
Normal file
3
plugins/eq/eqpeekfilter.h
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
|
||||
80
plugins/eq/eqspectrumview.h
Normal file
80
plugins/eq/eqspectrumview.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef EQSPECTRUMVIEW_H
|
||||
#define EQSPECTRUMVIEW_H
|
||||
|
||||
#include "qpainter.h"
|
||||
#include "eqeffect.h"
|
||||
#include "qwidget.h"
|
||||
|
||||
class EqParams
|
||||
{
|
||||
public:
|
||||
const static int MAX_BANDS = 249;
|
||||
float m_bands[MAX_BANDS];
|
||||
float m_energy;
|
||||
};
|
||||
|
||||
|
||||
class EqSpectrumView : public QWidget
|
||||
{
|
||||
public:
|
||||
EqSpectrumView( EqParams* s, QWidget * _parent = 0) :
|
||||
QWidget( _parent ),
|
||||
m_sa( s )
|
||||
{
|
||||
setFixedSize( 240, 116 );
|
||||
connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) );
|
||||
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
||||
}
|
||||
|
||||
virtual ~EqSpectrumView()
|
||||
{
|
||||
}
|
||||
EqParams *m_sa;
|
||||
virtual void paintEvent( QPaintEvent* event )
|
||||
{
|
||||
const int MAX_BANDS = 249;
|
||||
QPainter p( this );
|
||||
const float e = m_sa->m_energy;
|
||||
if( e <= 0 )
|
||||
{
|
||||
//dont draw anything
|
||||
return;
|
||||
}
|
||||
float * b = m_sa->m_bands;
|
||||
const int LOWER_Y = -60; // dB
|
||||
int h;
|
||||
const int fh = height();
|
||||
bool linX = true;
|
||||
if( linX )
|
||||
{
|
||||
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;
|
||||
p.drawPoint( x, fh-h );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int x = 0; x < 31; ++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; else h = ( h / 3 ) * 3;
|
||||
p.drawPoint(x * 8, fh-h );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
//EqParams *m_sa;
|
||||
// QImage m_backgroundPlain;
|
||||
// QImage m_background;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif // EQSPECTRUMVIEW_H
|
||||
BIN
plugins/eq/logo.png
Normal file
BIN
plugins/eq/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Reference in New Issue
Block a user