From bac22e96072fe91cefa43222e23569d9edbf4d36 Mon Sep 17 00:00:00 2001 From: Dave French Date: Wed, 17 Dec 2014 02:57:49 +0000 Subject: [PATCH] EQ tidy up, --- plugins/Eq/CMakeLists.txt | 4 +- plugins/Eq/EqControls.cpp | 2 + plugins/Eq/EqEffect.cpp | 3 +- plugins/Eq/EqFader.h | 4 +- plugins/Eq/EqFilter.h | 4 +- plugins/Eq/EqParameterWidget.cpp | 8 +- plugins/Eq/EqParameterWidget.h | 129 ++++++++++++++++--------------- plugins/Eq/EqSpectrumView.h | 7 +- 8 files changed, 89 insertions(+), 72 deletions(-) diff --git a/plugins/Eq/CMakeLists.txt b/plugins/Eq/CMakeLists.txt index 294005af0..3cd4b8885 100644 --- a/plugins/Eq/CMakeLists.txt +++ b/plugins/Eq/CMakeLists.txt @@ -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 ../../src/gui/widgets/Fader.cpp -MOCFILES EqControls.h EqParameterWidget.h EqFader.h ../../include/Fader.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 +MOCFILES EqControls.h EqParameterWidget.h EqFader.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") diff --git a/plugins/Eq/EqControls.cpp b/plugins/Eq/EqControls.cpp index 62d71cabc..19b63fc4a 100644 --- a/plugins/Eq/EqControls.cpp +++ b/plugins/Eq/EqControls.cpp @@ -85,6 +85,8 @@ EqControls::EqControls( EqEffect *effect ) : m_para1GainModel.setScaleLogarithmic( true ); m_inPeakL = 0; m_inPeakR = 0; + m_outPeakL = 0; + m_outPeakR = 0; m_lowShelfPeakL = 0; m_lowShelfPeakR = 0; m_para1PeakL = 0; m_para1PeakR = 0; m_para2PeakL = 0; m_para2PeakR = 0; diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index f344ed519..ee78f459d 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -51,7 +51,8 @@ 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_eqControls( this ), + m_upBufFrames( 0 ) { m_dFilterCount = 4; m_downsampleFilters = new EqLinkwitzRiley[m_dFilterCount]; diff --git a/plugins/Eq/EqFader.h b/plugins/Eq/EqFader.h index 1057b60c0..0e1a3cc2d 100644 --- a/plugins/Eq/EqFader.h +++ b/plugins/Eq/EqFader.h @@ -32,7 +32,7 @@ -class EqFader : public Fader +class EXPORT EqFader : public Fader { public: @@ -48,6 +48,8 @@ public: m_rPeak = rPeak; connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateVuMeters() ) ); m_model = model; + setPeak_L( 0 ); + setPeak_R( 0 ); } diff --git a/plugins/Eq/EqFilter.h b/plugins/Eq/EqFilter.h index d704ae517..b703edc95 100644 --- a/plugins/Eq/EqFilter.h +++ b/plugins/Eq/EqFilter.h @@ -336,7 +336,9 @@ class EqLinkwitzRiley : public StereoLinkwitzRiley { public: EqLinkwitzRiley() : - StereoLinkwitzRiley( 44100) + StereoLinkwitzRiley( 44100), + m_freq(0 ), + m_sr( 1 ) { } diff --git a/plugins/Eq/EqParameterWidget.cpp b/plugins/Eq/EqParameterWidget.cpp index 0cbcd1bfb..4d3cb6e9a 100644 --- a/plugins/Eq/EqParameterWidget.cpp +++ b/plugins/Eq/EqParameterWidget.cpp @@ -46,6 +46,7 @@ EqParameterWidget::EqParameterWidget( QWidget *parent ) : m_pixelsPerUnitHeight = (height() - 4) / ( totalHeight ); m_scale = 1.5; m_pixelsPerOctave = freqToXPixel( 10000 ) - freqToXPixel( 5000 ); + } @@ -56,6 +57,7 @@ EqParameterWidget::~EqParameterWidget() if(m_bands) { delete m_bands; + m_bands = 0; } } @@ -210,6 +212,10 @@ EqBand::EqBand() : res ( 0 ), freq ( 0 ), color ( QColor( 255, 255, 255 ) ), - name ( QString( "" ) ) + x( 0 ), + y( 0 ), + name ( QString( "" ) ), + peakL( 0 ), + peakR( 0 ) { } diff --git a/plugins/Eq/EqParameterWidget.h b/plugins/Eq/EqParameterWidget.h index c47ea259d..6cc7f1a89 100644 --- a/plugins/Eq/EqParameterWidget.h +++ b/plugins/Eq/EqParameterWidget.h @@ -32,18 +32,19 @@ class EqBand { public : - EqBand(); - FloatModel* gain; - FloatModel* res; - FloatModel* freq; - BoolModel* active; - QColor color; - int x; - int y; - QString name; + EqBand(); + FloatModel* gain; + FloatModel* res; + FloatModel* freq; + BoolModel* active; + QColor color; + int x; + int y; + QString name; float* peakL; float* peakR; + }; @@ -52,51 +53,51 @@ class EqParameterWidget : public QWidget { public: - explicit EqParameterWidget( QWidget *parent = 0 ); - ~EqParameterWidget(); - const int bandCount() - { - return 8; - } + explicit EqParameterWidget( QWidget *parent = 0 ); + ~EqParameterWidget(); + const int bandCount() + { + return 8; + } - const int maxDistanceFromHandle() - { - return 20; - } + const int maxDistanceFromHandle() + { + return 20; + } - EqBand* getBandModels( int i ) - { - return &m_bands[i]; - } + EqBand* getBandModels( int i ) + { + return &m_bands[i]; + } - const int activeAplha() - { - return 200; - } + const int activeAplha() + { + return 200; + } - const int inactiveAlpha() - { + const int inactiveAlpha() + { return 100; - } + } - const float resPixelMultiplyer() - { - return 100; - } + const float resPixelMultiplyer() + { + return 100; + } signals: @@ -104,55 +105,55 @@ 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); + 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 *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 ); + EqBand* selectNearestHandle( const int x, const int y ); - enum MouseAction { none, drag, res } m_mouseAction; - int m_oldX, m_oldY; + enum MouseAction { none, drag, res } m_mouseAction; + int m_oldX, m_oldY; int *m_xGridBands; - inline int freqToXPixel( float freq ) - { - return ( log10( freq ) * m_pixelsPerUnitWidth * m_scale ) - ( width() * 0.5 ); - } + 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 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 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; - } + inline float yPixelToGain( int y ) + { + return ( ( 0.5 * height() ) - y) / m_pixelsPerUnitHeight; + } }; diff --git a/plugins/Eq/EqSpectrumView.h b/plugins/Eq/EqSpectrumView.h index d86899eea..71c64f5a4 100644 --- a/plugins/Eq/EqSpectrumView.h +++ b/plugins/Eq/EqSpectrumView.h @@ -46,7 +46,10 @@ public: int m_sr; - EqAnalyser() + EqAnalyser() : + m_framesFilledUp ( 0 ), + m_energy ( 0 ), + m_sr ( 1 ) { m_inProgress=false; m_specBuf = (fftwf_complex *) fftwf_malloc( ( FFT_BUFFER_SIZE + 1 ) * sizeof( fftwf_complex ) ); @@ -73,7 +76,7 @@ public: m_framesFilledUp = 0; m_energy = 0; memset( m_buffer, 0, sizeof( m_buffer ) ); - + memset( m_bands, 0, sizeof( m_bands ) ); }