@@ -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 EqParameterWidget.h EqFader.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
|
||||
BUILD_PLUGIN(eq EqEffect.cpp EqControls.cpp EqControlsDialog.cpp EqFilter.h EqParameterWidget.cpp EqFader.h EqSpectrumView.h DBvModel.cpp DBvModel.h
|
||||
MOCFILES EqControls.h EqParameterWidget.h EqFader.h DBvModel.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
|
||||
|
||||
14
plugins/Eq/DBvModel.cpp
Normal file
14
plugins/Eq/DBvModel.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "DBvModel.h"
|
||||
|
||||
DBvModel::DBvModel(float val, float min, float max, float step,
|
||||
Model *parent, const QString &displayName,
|
||||
bool defaultConstructed) :
|
||||
FloatModel( val, min, max, step, parent, displayName, defaultConstructed )
|
||||
{
|
||||
connect(this, SIGNAL( dataChanged() ), this,SLOT( calcAmp() ) );
|
||||
}
|
||||
|
||||
void DBvModel::calcAmp()
|
||||
{
|
||||
m_amp = dbvToAmp( value() );
|
||||
}
|
||||
31
plugins/Eq/DBvModel.h
Normal file
31
plugins/Eq/DBvModel.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef DBVMODEL
|
||||
#define DBVMODEL
|
||||
|
||||
#include "AutomatableModel.h"
|
||||
|
||||
|
||||
class DBvModel : public FloatModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DBvModel( float val = 0, float min = 0, float max = 0, float step = 0,
|
||||
Model * parent = NULL,
|
||||
const QString& displayName = QString(),
|
||||
bool defaultConstructed = false );
|
||||
inline float getAmp() const
|
||||
{
|
||||
return m_amp;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void calcAmp();
|
||||
|
||||
private:
|
||||
float m_amp;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DBVMODEL
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
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_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" ) ),
|
||||
@@ -41,12 +41,12 @@ EqControls::EqControls( EqEffect *effect ) :
|
||||
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_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_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" ) ),
|
||||
m_para2BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 2 BW" ) ),
|
||||
m_para3BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 3 BW" ) ),
|
||||
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" ) ),
|
||||
@@ -70,7 +70,6 @@ EqControls::EqControls( EqEffect *effect ) :
|
||||
m_hp12Model( false, 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_lpTypeModel( 0,0,2,this, tr( "low pass type") ) ,
|
||||
m_hpTypeModel( 0,0,2,this, tr( "high pass type") )
|
||||
{
|
||||
@@ -94,6 +93,10 @@ 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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -111,10 +114,10 @@ void EqControls::loadSettings( const QDomElement &_this )
|
||||
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_para1BwModel.loadSettings( _this ,"Peak1bw" );
|
||||
m_para2BwModel.loadSettings( _this ,"Peak2bw" );
|
||||
m_para3BwModel.loadSettings( _this ,"Peak3bw" );
|
||||
m_para4BwModel.loadSettings( _this ,"Peak4bw" );
|
||||
m_highShelfResModel.loadSettings( _this, "HighShelfres" );
|
||||
m_lpResModel.loadSettings( _this, "LPres");
|
||||
m_hpFeqModel.loadSettings( _this, "HPfreq" );
|
||||
@@ -139,7 +142,6 @@ void EqControls::loadSettings( const QDomElement &_this )
|
||||
m_hp12Model.loadSettings( _this , "HP12" );
|
||||
m_hp24Model.loadSettings( _this , "HP24" );
|
||||
m_hp48Model.loadSettings( _this , "HP48" );
|
||||
m_analyzeModel.loadSettings( _this, "Analyzeenable");
|
||||
m_lpTypeModel.loadSettings( _this, "LP" );
|
||||
m_hpTypeModel.loadSettings( _this, "HP" );
|
||||
}
|
||||
@@ -160,10 +162,10 @@ void EqControls::saveSettings( QDomDocument &doc, QDomElement &parent )
|
||||
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_para1BwModel.saveSettings( doc, parent,"Peak1bw" );
|
||||
m_para2BwModel.saveSettings( doc, parent,"Peak2bw" );
|
||||
m_para3BwModel.saveSettings( doc, parent,"Peak3bw" );
|
||||
m_para4BwModel.saveSettings( doc, parent,"Peak4bw" );
|
||||
m_highShelfResModel.saveSettings( doc, parent, "HighShelfres" );
|
||||
m_lpResModel.saveSettings( doc, parent, "LPres");
|
||||
m_hpFeqModel.saveSettings( doc, parent, "HPfreq" );
|
||||
@@ -188,7 +190,6 @@ void EqControls::saveSettings( QDomDocument &doc, QDomElement &parent )
|
||||
m_hp12Model.saveSettings( doc, parent, "HP12" );
|
||||
m_hp24Model.saveSettings( doc, parent, "HP24" );
|
||||
m_hp48Model.saveSettings( doc, parent, "HP48" );
|
||||
m_analyzeModel.saveSettings( doc, parent, "Analyzeenable");
|
||||
m_lpTypeModel.saveSettings( doc, parent, "LP" );
|
||||
m_hpTypeModel.saveSettings( doc, parent, "HP" );
|
||||
}
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
#include "EffectControls.h"
|
||||
#include "EqControlsDialog.h"
|
||||
#include "Knob.h"
|
||||
#include "DBvModel.h"
|
||||
|
||||
class EqEffect;
|
||||
|
||||
|
||||
class EqControls : public EffectControls
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -64,6 +66,8 @@ 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;
|
||||
@@ -79,8 +83,8 @@ public:
|
||||
private:
|
||||
EqEffect* m_effect;
|
||||
|
||||
FloatModel m_inGainModel;
|
||||
FloatModel m_outGainModel;
|
||||
DBvModel m_inGainModel;
|
||||
DBvModel m_outGainModel;
|
||||
FloatModel m_lowShelfGainModel;
|
||||
FloatModel m_para1GainModel;
|
||||
FloatModel m_para2GainModel;
|
||||
@@ -90,10 +94,10 @@ private:
|
||||
|
||||
FloatModel m_hpResModel;
|
||||
FloatModel m_lowShelfResModel;
|
||||
FloatModel m_para1ResModel;
|
||||
FloatModel m_para2ResModel;
|
||||
FloatModel m_para3ResModel;
|
||||
FloatModel m_para4ResModel;
|
||||
FloatModel m_para1BwModel;
|
||||
FloatModel m_para2BwModel;
|
||||
FloatModel m_para3BwModel;
|
||||
FloatModel m_para4BwModel;
|
||||
FloatModel m_highShelfResModel;
|
||||
FloatModel m_lpResModel;
|
||||
|
||||
@@ -123,8 +127,6 @@ private:
|
||||
BoolModel m_hp24Model;
|
||||
BoolModel m_hp48Model;
|
||||
|
||||
BoolModel m_analyzeModel;
|
||||
|
||||
IntModel m_lpTypeModel;
|
||||
IntModel m_hpTypeModel;
|
||||
|
||||
|
||||
@@ -54,15 +54,15 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
|
||||
m_outSpec = new EqSpectrumView( &controls->m_outFftBands, this);
|
||||
m_outSpec->move( 51, 2 );
|
||||
m_outSpec->color = QColor(145, 205, 22, 80);
|
||||
m_parameterWidget = new EqParameterWidget( this );
|
||||
m_parameterWidget = new EqParameterWidget( this , controls );
|
||||
m_parameterWidget->move( 51, 2 );
|
||||
|
||||
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_para1ResModel, &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_para2ResModel, &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_para3ResModel, &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_para4ResModel, &controls->m_para4GainModel, QColor(255 ,255, 255), tr( "Peak 4" ), &controls->m_para4PeakL, &controls->m_para4PeakR );
|
||||
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
|
||||
@@ -70,10 +70,15 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
|
||||
|
||||
m_inGainFader = new EqFader( &controls->m_inGainModel, tr( "In Gain" ), this, &controls->m_inPeakL, &controls->m_inPeakR);
|
||||
m_inGainFader->move( 10, 5 );
|
||||
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->setDisplayConversion( false );
|
||||
m_outGainFader->setHintText( tr( "Gain" ), "dBv");
|
||||
//gain faders
|
||||
|
||||
int fo = (cw * 0.5) - (m_outGainFader->width() * 0.5 );
|
||||
@@ -100,7 +105,8 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
|
||||
}
|
||||
m_resKnob->setVolumeKnob(false);
|
||||
m_resKnob->setModel( m_parameterWidget->getBandModels( i )->res );
|
||||
m_resKnob->setHintText( tr( "Resonance:") , "");
|
||||
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 )
|
||||
@@ -156,13 +162,6 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) :
|
||||
hpBtnGrp->addButton( m_hp48Box );
|
||||
hpBtnGrp->setModel( &m_controls->m_hpTypeModel,false);
|
||||
|
||||
//Analize Box
|
||||
m_analyzeBox = new LedCheckBox( tr( "Analyze" ), this , "" , LedCheckBox::Green );
|
||||
m_analyzeBox->move( cw*1 + ko + 5, 15 );
|
||||
m_analyzeBox->setModel( &controls->m_analyzeModel );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void EqControlsDialog::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "interpolation.h"
|
||||
#include "Engine.h"
|
||||
#include "MainWindow.h"
|
||||
#include "EqFader.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -51,17 +52,9 @@ Plugin::Descriptor PLUGIN_EXPORT eq_plugin_descriptor =
|
||||
|
||||
EqEffect::EqEffect(Model *parent, const Plugin::Descriptor::SubPluginFeatures::Key *key) :
|
||||
Effect( &eq_plugin_descriptor, parent, key ),
|
||||
m_eqControls( this ),
|
||||
m_upBufFrames( 0 )
|
||||
m_eqControls( this )
|
||||
{
|
||||
m_dFilterCount = 2;
|
||||
m_downsampleFilters = new EqLinkwitzRiley[m_dFilterCount];
|
||||
for( int i = 0; i < m_dFilterCount; i++)
|
||||
{
|
||||
m_downsampleFilters[i].setFrequency(21000);
|
||||
m_downsampleFilters[i].setSR(Engine::mixer()->processingSampleRate() * 2 );
|
||||
}
|
||||
m_upBuf = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -69,10 +62,6 @@ EqEffect::EqEffect(Model *parent, const Plugin::Descriptor::SubPluginFeatures::K
|
||||
|
||||
EqEffect::~EqEffect()
|
||||
{
|
||||
if(m_upBuf)
|
||||
{
|
||||
delete m_upBuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,11 +79,11 @@ bool EqEffect::processAudioBuffer(sampleFrame *buf, const fpp_t frames)
|
||||
{
|
||||
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
|
||||
}
|
||||
const float outGain = m_eqControls.m_outGainModel.value();
|
||||
const int sampleRate = Engine::mixer()->processingSampleRate() * 2;
|
||||
const float outGain = m_eqControls.m_outGainModel.getAmp();
|
||||
const int sampleRate = Engine::mixer()->processingSampleRate();
|
||||
sampleFrame m_inPeak = { 0, 0 };
|
||||
|
||||
if(m_eqControls.m_analyzeModel.value() )
|
||||
if(m_eqControls.m_analyseIn )
|
||||
{
|
||||
m_eqControls.m_inFftBands.analyze( buf, frames );
|
||||
}
|
||||
@@ -102,99 +91,94 @@ bool EqEffect::processAudioBuffer(sampleFrame *buf, const fpp_t frames)
|
||||
{
|
||||
m_eqControls.m_inFftBands.clear();
|
||||
}
|
||||
upsample( buf, frames );
|
||||
gain(m_upBuf , m_upBufFrames, m_eqControls.m_inGainModel.value(), &m_inPeak );
|
||||
gain(buf , frames, m_eqControls.m_inGainModel.getAmp() , &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[1] : m_eqControls.m_inPeakR;
|
||||
|
||||
if(m_eqControls.m_hpActiveModel.value() ){
|
||||
|
||||
m_hp12.setParameters( sampleRate, m_eqControls.m_hpFeqModel.value(), m_eqControls.m_hpResModel.value(), 1 );
|
||||
m_hp12.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_hp12.processBuffer( buf, frames );
|
||||
|
||||
if( m_eqControls.m_hp24Model.value() || m_eqControls.m_hp48Model.value() )
|
||||
{
|
||||
m_hp24.setParameters( sampleRate, m_eqControls.m_hpFeqModel.value(), m_eqControls.m_hpResModel.value(), 1 );
|
||||
m_hp24.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_hp24.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_hp48Model.value() )
|
||||
{
|
||||
m_hp480.setParameters( sampleRate, m_eqControls.m_hpFeqModel.value(), m_eqControls.m_hpResModel.value(), 1 );
|
||||
m_hp480.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_hp480.processBuffer( buf, frames );
|
||||
|
||||
m_hp481.setParameters( sampleRate, m_eqControls.m_hpFeqModel.value(), m_eqControls.m_hpResModel.value(), 1 );
|
||||
m_hp481.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_hp481.processBuffer( buf, frames );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_eqControls.m_lowShelfActiveModel.value() )
|
||||
{
|
||||
m_lowShelf.setParameters( sampleRate, m_eqControls.m_lowShelfFreqModel.value(), m_eqControls.m_lowShelfResModel .value(), m_eqControls.m_lowShelfGainModel.value() );
|
||||
m_lowShelf.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_lowShelf.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para1ActiveModel.value() )
|
||||
{
|
||||
m_para1.setParameters( sampleRate, m_eqControls.m_para1FreqModel.value(), m_eqControls.m_para1ResModel.value(), m_eqControls.m_para1GainModel.value() );
|
||||
m_para1.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_para1.setParameters( sampleRate, m_eqControls.m_para1FreqModel.value(), m_eqControls.m_para1BwModel.value(), m_eqControls.m_para1GainModel.value() );
|
||||
m_para1.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para2ActiveModel.value() )
|
||||
{
|
||||
m_para2.setParameters( sampleRate, m_eqControls.m_para2FreqModel.value(), m_eqControls.m_para2ResModel.value(), m_eqControls.m_para2GainModel.value() );
|
||||
m_para2.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_para2.setParameters( sampleRate, m_eqControls.m_para2FreqModel.value(), m_eqControls.m_para2BwModel.value(), m_eqControls.m_para2GainModel.value() );
|
||||
m_para2.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para3ActiveModel.value() )
|
||||
{
|
||||
m_para3.setParameters( sampleRate, m_eqControls.m_para3FreqModel.value(), m_eqControls.m_para3ResModel.value(), m_eqControls.m_para3GainModel.value() );
|
||||
m_para3.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_para3.setParameters( sampleRate, m_eqControls.m_para3FreqModel.value(), m_eqControls.m_para3BwModel.value(), m_eqControls.m_para3GainModel.value() );
|
||||
m_para3.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_para4ActiveModel.value() )
|
||||
{
|
||||
m_para4.setParameters( sampleRate, m_eqControls.m_para4FreqModel.value(), m_eqControls.m_para4ResModel.value(), m_eqControls.m_para4GainModel.value() );
|
||||
m_para4.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_para4.setParameters( sampleRate, m_eqControls.m_para4FreqModel.value(), m_eqControls.m_para4BwModel.value(), m_eqControls.m_para4GainModel.value() );
|
||||
m_para4.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_highShelfActiveModel.value() )
|
||||
{
|
||||
m_highShelf.setParameters( sampleRate, m_eqControls.m_highShelfFreqModel.value(), m_eqControls.m_highShelfResModel.value(), m_eqControls.m_highShelfGainModel.value());
|
||||
m_highShelf.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_highShelf.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if(m_eqControls.m_lpActiveModel.value() ){
|
||||
m_lp12.setParameters( sampleRate, m_eqControls.m_lpFreqModel.value(), m_eqControls.m_lpResModel.value(), 1 );
|
||||
m_lp12.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_lp12.processBuffer( buf, frames );
|
||||
|
||||
if( m_eqControls.m_lp24Model.value() || m_eqControls.m_lp48Model.value() )
|
||||
{
|
||||
m_lp24.setParameters( sampleRate, m_eqControls.m_lpFreqModel.value(), m_eqControls.m_lpResModel.value(), 1 );
|
||||
m_lp24.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_lp24.processBuffer( buf, frames );
|
||||
}
|
||||
|
||||
if( m_eqControls.m_lp48Model.value() )
|
||||
{
|
||||
m_lp480.setParameters( sampleRate, m_eqControls.m_lpFreqModel.value(), m_eqControls.m_lpResModel.value(), 1 );
|
||||
m_lp480.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_lp480.processBuffer( buf, frames );
|
||||
|
||||
m_lp481.setParameters( sampleRate, m_eqControls.m_lpFreqModel.value(), m_eqControls.m_lpResModel.value(), 1 );
|
||||
m_lp481.processBuffer( m_upBuf , m_upBufFrames );
|
||||
m_lp481.processBuffer( buf, frames );
|
||||
}
|
||||
}
|
||||
|
||||
sampleFrame outPeak = { 0, 0 };
|
||||
gain( m_upBuf , m_upBufFrames, outGain, &outPeak );
|
||||
gain( buf, frames, 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[1] : m_eqControls.m_outPeakR;
|
||||
for( int i =0; i < m_dFilterCount; i++)
|
||||
{
|
||||
m_downsampleFilters[i].processBuffer(m_upBuf , m_upBufFrames );
|
||||
}
|
||||
downSample( buf, frames );
|
||||
|
||||
checkGate( outSum / frames );
|
||||
if(m_eqControls.m_analyzeModel.value() )
|
||||
if(m_eqControls.m_analyseOut )
|
||||
{
|
||||
m_eqControls.m_outFftBands.analyze( buf, frames );
|
||||
setBandPeaks( &m_eqControls.m_outFftBands , ( int )( sampleRate * 0.5 ) );
|
||||
@@ -234,30 +218,30 @@ void EqEffect::setBandPeaks(EqAnalyser *fft, int samplerate )
|
||||
|
||||
m_eqControls.m_para1PeakL = m_eqControls.m_para1PeakR =
|
||||
peakBand( m_eqControls.m_para1FreqModel.value()
|
||||
- (m_eqControls.m_para1FreqModel.value() / m_eqControls.m_para1ResModel.value() * 0.5),
|
||||
- (m_eqControls.m_para1FreqModel.value() * m_eqControls.m_para1BwModel.value() * 0.5),
|
||||
m_eqControls.m_para1FreqModel.value()
|
||||
+ (m_eqControls.m_para1FreqModel.value() / m_eqControls.m_para1ResModel.value() * 0.5),
|
||||
+ (m_eqControls.m_para1FreqModel.value() * m_eqControls.m_para1BwModel.value() * 0.5),
|
||||
fft , samplerate );
|
||||
|
||||
m_eqControls.m_para2PeakL = m_eqControls.m_para2PeakR =
|
||||
peakBand( m_eqControls.m_para2FreqModel.value()
|
||||
- (m_eqControls.m_para2FreqModel.value() / m_eqControls.m_para2ResModel.value() * 0.5),
|
||||
- (m_eqControls.m_para2FreqModel.value() * m_eqControls.m_para2BwModel.value() * 0.5),
|
||||
m_eqControls.m_para2FreqModel.value()
|
||||
+ (m_eqControls.m_para2FreqModel.value() / m_eqControls.m_para2ResModel.value() * 0.5),
|
||||
+ (m_eqControls.m_para2FreqModel.value() * m_eqControls.m_para2BwModel.value() * 0.5),
|
||||
fft , samplerate );
|
||||
|
||||
m_eqControls.m_para3PeakL = m_eqControls.m_para3PeakR =
|
||||
peakBand( m_eqControls.m_para3FreqModel.value()
|
||||
- (m_eqControls.m_para3FreqModel.value() / m_eqControls.m_para3ResModel.value() * 0.5),
|
||||
- (m_eqControls.m_para3FreqModel.value() * m_eqControls.m_para3BwModel.value() * 0.5),
|
||||
m_eqControls.m_para3FreqModel.value()
|
||||
+ (m_eqControls.m_para3FreqModel.value() / m_eqControls.m_para3ResModel.value() * 0.5),
|
||||
+ (m_eqControls.m_para3FreqModel.value() * m_eqControls.m_para3BwModel.value() * 0.5),
|
||||
fft , samplerate );
|
||||
|
||||
m_eqControls.m_para4PeakL = m_eqControls.m_para4PeakR =
|
||||
peakBand( m_eqControls.m_para4FreqModel.value()
|
||||
- (m_eqControls.m_para4FreqModel.value() / m_eqControls.m_para4ResModel.value() * 0.5),
|
||||
- (m_eqControls.m_para4FreqModel.value() * m_eqControls.m_para4BwModel.value() * 0.5),
|
||||
m_eqControls.m_para4FreqModel.value()
|
||||
+ (m_eqControls.m_para4FreqModel.value() / m_eqControls.m_para4ResModel.value() * 0.5),
|
||||
+ (m_eqControls.m_para4FreqModel.value() * m_eqControls.m_para4BwModel.value() * 0.5),
|
||||
fft , samplerate );
|
||||
|
||||
m_eqControls.m_highShelfPeakL = m_eqControls.m_highShelfPeakR =
|
||||
|
||||
@@ -84,46 +84,6 @@ private:
|
||||
EqLp12Filter m_lp24;
|
||||
EqLp12Filter m_lp480;
|
||||
EqLp12Filter m_lp481;
|
||||
EqLinkwitzRiley* m_downsampleFilters;
|
||||
int m_dFilterCount;
|
||||
sampleFrame* m_upBuf;
|
||||
fpp_t m_upBufFrames;
|
||||
sampleFrame m_lastUpFrame;
|
||||
|
||||
inline void 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline void downSample( sampleFrame *buf, const fpp_t frames )
|
||||
{
|
||||
for( int f = 0, f2 = 0; f < frames; ++f, f2 += 2 )
|
||||
{
|
||||
buf[f][0] = m_upBuf[f2+1][0];
|
||||
buf[f][1] = m_upBuf[f2+1][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ protected:
|
||||
float m_freq;
|
||||
float m_res;
|
||||
float m_gain;
|
||||
float m_bw;
|
||||
};
|
||||
|
||||
|
||||
@@ -258,7 +259,7 @@ public:
|
||||
float c = cosf( w0 );
|
||||
float s = sinf( w0 );
|
||||
float A = pow( 10, m_gain * 0.025);
|
||||
float alpha = s / ( 2 * m_res );
|
||||
float alpha = s * sinh( log( 2 ) / 2 * m_bw * w0 / sinf(w0) );
|
||||
|
||||
float a0, a1, a2, b0, b1, b2; // coeffs to calculate
|
||||
|
||||
@@ -280,6 +281,33 @@ public:
|
||||
|
||||
setCoeffs( a1, a2, b0, b1, b2 );
|
||||
}
|
||||
|
||||
virtual inline void setParameters( float sampleRate, float freq, float bw, float gain )
|
||||
{
|
||||
bool hasChanged = false;
|
||||
if( sampleRate != m_sampleRate )
|
||||
{
|
||||
m_sampleRate = sampleRate;
|
||||
hasChanged = true;
|
||||
}
|
||||
if ( freq != m_freq )
|
||||
{
|
||||
m_freq = freq;
|
||||
hasChanged = true;
|
||||
}
|
||||
if ( bw != m_bw )
|
||||
{
|
||||
m_bw = bw;
|
||||
hasChanged = true;
|
||||
}
|
||||
if ( gain != m_gain )
|
||||
{
|
||||
m_gain = gain;
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
if ( hasChanged ) { calcCoefficents(); }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
#include "lmms_math.h"
|
||||
#include "MainWindow.h"
|
||||
#include "QMouseEvent"
|
||||
#include "EqControls.h"
|
||||
|
||||
EqParameterWidget::EqParameterWidget( QWidget *parent ) :
|
||||
EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) :
|
||||
QWidget( parent ),
|
||||
m_bands ( 0 ),
|
||||
m_selectedBand ( 0 )
|
||||
@@ -46,6 +47,9 @@ EqParameterWidget::EqParameterWidget( QWidget *parent ) :
|
||||
m_pixelsPerUnitHeight = (height() - 4) / ( totalHeight );
|
||||
m_scale = 1.5;
|
||||
m_pixelsPerOctave = freqToXPixel( 10000 ) - freqToXPixel( 5000 );
|
||||
m_controls = controls;
|
||||
tf = new TextFloat();
|
||||
tf->hide();
|
||||
|
||||
}
|
||||
|
||||
@@ -96,7 +100,7 @@ void EqParameterWidget::paintEvent( QPaintEvent *event )
|
||||
gain = m_bands[i].gain->value();
|
||||
}
|
||||
y = gainToYPixel( gain );
|
||||
float bw = m_bands[i].freq->value() / m_bands[i].res->value();
|
||||
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 );
|
||||
@@ -133,6 +137,27 @@ void EqParameterWidget::mouseReleaseEvent( QMouseEvent *event )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
m_controls->m_analyseIn = !m_controls->m_analyseIn;
|
||||
}
|
||||
|
||||
if(event->x() > outXmin && event->x() < outXmax && event->y() > outYmin && event->y() < outYmax )
|
||||
{
|
||||
m_controls->m_analyseOut = !m_controls->m_analyseOut;
|
||||
}
|
||||
|
||||
tf->hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -153,13 +178,22 @@ void EqParameterWidget::mouseMoveEvent( QMouseEvent *event )
|
||||
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( ( 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() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#define EQPARAMETERWIDGET_H
|
||||
#include <QWidget>
|
||||
#include "EffectControls.h"
|
||||
#include "TextFloat.h"
|
||||
|
||||
class EqControls;
|
||||
|
||||
|
||||
class EqBand
|
||||
@@ -51,9 +54,9 @@ public :
|
||||
|
||||
class EqParameterWidget : public QWidget
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EqParameterWidget( QWidget *parent = 0 );
|
||||
explicit EqParameterWidget( QWidget *parent = 0, EqControls * controls = 0);
|
||||
~EqParameterWidget();
|
||||
const int bandCount()
|
||||
{
|
||||
@@ -113,11 +116,13 @@ protected:
|
||||
|
||||
private:
|
||||
EqBand *m_bands;
|
||||
EqControls *m_controls;
|
||||
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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user