Mercurial > hg > easaier-soundaccess
changeset 232:70b88fbbfb5c
integrate simple equalizer filter
author | lbajardsilogic |
---|---|
date | Thu, 06 Mar 2008 14:56:40 +0000 |
parents | fd17abdbef2d |
children | 628531da16ef |
files | sv/filter/DSP.cpp sv/filter/DSP.h sv/filter/EqualizerFilter.cpp sv/filter/EqualizerFilter.h sv/filter/MultiRealTimeFilter.cpp sv/filter/MultiRealTimeFilter.h widgets/Plotter.cpp widgets/Plotter.h widgets/PropertyBox.cpp widgets/Slider.cpp widgets/Slider.h |
diffstat | 11 files changed, 402 insertions(+), 365 deletions(-) [+] |
line wrap: on
line diff
--- a/sv/filter/DSP.cpp Thu Mar 06 14:50:00 2008 +0000 +++ b/sv/filter/DSP.cpp Thu Mar 06 14:56:40 2008 +0000 @@ -24,20 +24,12 @@ //These variables are only required for find peaks...the same variables are passed in to other functions extern int numpeaks; extern float *peak_locations; -//extern float *p_mags; -//extern float *c_mags; extern float *L_mags; ///CURRENT FRAME MAGNITUDES extern float *R_mags; ///CURRENT FRAME MAGNITUDES extern float *pL_mags; ///PREVIOUS FRAME MAGNITUDES extern float *pR_mags; ///PREVIOUS FRAME MAGNITUDES -extern float *band1; -extern float *band2; -extern float *band3; -extern float *band4; -extern float *band5; - void intobyte(int num, char* pbyte1 ,char* pbyte2) { @@ -480,7 +472,7 @@ } -void log10plot2(float* L_mags, float* plotFFTarray, int framesize, int plotsize) +void log10plot2(QVector<int>& L_mags, float* plotFFTarray, int framesize, int plotsize) { float interpfactor1 = 10/100; //1 - 100hz bin 1 - 10 float interpfactor2 = 90/100; //100 - 1000hz bin 10 - 100 @@ -501,7 +493,7 @@ ratio=((((1+p)/100)*9)+1)-floor((float) temp); - plotFFTarray[i]=((((L_mags[temp+1]-L_mags[temp])*ratio)+L_mags[temp])); + plotFFTarray[i]=((((L_mags.at(temp+1)-L_mags.at(temp))*ratio)+L_mags.at(temp))); //plotFFTarray[i]=dec*plotFFTarray[i]+0.5*log((((L_mags[temp+1]-L_mags[temp])*ratio)+L_mags[temp])/1000); } @@ -509,7 +501,7 @@ { p=i; temp=floor((((1+p-plotsize/4)/100)*90)+10); - plotFFTarray[i]=(L_mags[temp]); + plotFFTarray[i]=(L_mags.at(temp)); //plotFFTarray[i]=dec*plotFFTarray[i]+0.5*log(L_mags[temp]/1000); } @@ -518,21 +510,21 @@ p=i; temp=floor((((1+p-(plotsize/4)*2)/100)*900)+100); - plotFFTarray[i]=(L_mags[temp]); + plotFFTarray[i]=(L_mags.at(temp)); //plotFFTarray[i]=dec*plotFFTarray[i]+0.5*log(L_mags[temp]/1000); } - for (i=(plotsize/4)*3 ; i<(plotsize/4)*4; i++) + for (i=(plotsize/4)*3 ; i<(plotsize/4)*4-1; i++) { p=i; temp=floor((((1+p-(plotsize/4)*3)/100)*1048)+1000); - plotFFTarray[i]=(L_mags[temp]); + plotFFTarray[i]=(L_mags.at(temp)); //plotFFTarray[i]=dec*plotFFTarray[i]+0.5*log(L_mags[temp]/1000); } } -void applyEQ(float* L_mags, float* R_mags, int framesize, int plotsize, QVector<int> eqcurve) +void applyEQ(float* L_mags, float* R_mags, int framesize, int plotsize, QVector<int>& eqcurve) { //(80,85,400,120,0) Screen Coordinates float gain, interpfactor, p,result; @@ -623,183 +615,13 @@ } -void bandeq(float* L_mags, float* R_mags, int gainband1, int gainband2, int gainband3, int gainband4, int gainband5, float* bandcurve, int framesize) +void bandeq(float* L_mags, float* R_mags, QVector<int>& eqcurve, int framesize) { - float maxcut=190; //18db of attenuation - float inc_cut=(1-(1/maxcut))/100; - - float maxboost=2; //6 db of gain - float inc_boost=(maxboost-1)/100; - float g1=1,g2=1,g3=1,g4=1,g5=1,instgain=1; - - if (gainband1 < 0){g1=(1/maxcut)+((100+ (float)gainband1)*inc_cut);} //not finished!!!! - if (gainband1 == 0){g1=1;} - if (gainband1 > 0){g1=1+(((float)gainband1)*inc_boost);} - //cout(g1); - if (gainband2 < 0){g2=(1/maxcut)+((100+ (float)gainband2)*inc_cut);} //not finished!!!! - if (gainband2 == 0){g2=1;} - if (gainband2 > 0){g2=1+(((float)gainband2)*inc_boost);} - - if (gainband3 < 0){g3=(1/maxcut)+((100+ (float)gainband3)*inc_cut);} //not finished!!!! - if (gainband3 == 0){g3=1;} - if (gainband3 > 0){g3=1+(((float)gainband3)*inc_boost);} - - if (gainband4 < 0){g4=(1/maxcut)+((100+ (float)gainband4)*inc_cut);} //not finished!!!! - if (gainband4 == 0){g4=1;} - if (gainband4 > 0){g4=1+(((float)gainband4)*inc_boost);} - - if (gainband5 < 0){g5=(1/maxcut)+((100+ (float)gainband5)*inc_cut);} //not finished!!!! - if (gainband5 == 0){g5=1;} - if (gainband5 > 0){g5=1+(((float)gainband5)*inc_boost);} - - - for (int i=0;i<framesize/2;i++) - { - instgain=(g1*band1[i])+(g2*band2[i])+(g3*band3[i])+(g4*band4[i])+(g5*band5[i]); - bandcurve[i]=instgain; - L_mags[i]*=instgain; - R_mags[i]*=instgain; - } - - - - -} - - -void create_filterbands(int framesize) - -{ - float binwidth = 44100/4096; - - float xover1 = 80; //100 - float xover2 = 700; //700 - float xover3 = 3000; //3000 - float xover4 = 9000; //9000 - - float width1 = 50; //50 - float width2 = 300; //100 - float width3 = 3000; //300 - float width4 = 1900; //900 - - int w; - - xover1=(xover1/binwidth); - xover2=(xover2/binwidth); - xover3=(xover3/binwidth); - xover4=(xover4/binwidth); - - width1=(width1/binwidth); - width2=(width2/binwidth); - width3=(width3/binwidth); - width4=(width4/binwidth); - - int p1 = 0; - int p2 = floor(xover1-(width1/2)); - int p3 = floor(xover1+(width1/2)); - int p4 = floor(xover2-(width2/2)); - int p5 = floor(xover2+(width2/2)); - int p6 = floor(xover3-(width3/2)); - int p7 = floor(xover3+(width3/2)); - int p8 = floor(xover4-(width4/2)); - int p9 = floor(xover4+(width4/2)); - int p10 = 2048; - - - //cout(p1); for (int i=0;i<framesize/2;i++) { - if (i < p2) - { - band1[i]=1; - band2[i]=0; - band3[i]=0; - band4[i]=0; - band5[i]=0; - } - - if (i >= p2 && i <= p3) - { - w = p3-p2+1; - band1[i]= (0.5*(1-cos(2*PI*((i-p2+w)+1)/((2*w))))); - band2[i]= (0.5*(1-cos(2*PI*((i-p2)+1)/((2*w))))); - band3[i]=0; - band4[i]=0; - band5[i]=0; - } - - - if (i > p3 && i < p4) - { - band1[i]=0; - band2[i]=1; - band3[i]=0; - band4[i]=0; - band5[i]=0; - } - - if (i >= p4 && i <= p5) - { - w = p4-p5+1; - band1[i]=0; - band2[i]= (0.5*(1-cos(2*PI*((i-p4+w)+1)/((2*w))))); - band3[i]= (0.5*(1-cos(2*PI*((i-p4)+1)/((2*w))))); - band4[i]=0; - band5[i]=0; - } - - if (i > p5 && i < p6) - { - band1[i]=0; - band2[i]=0; - band3[i]=1; - band4[i]=0; - band5[i]=0; - } - - if (i >= p6 && i <= p7) - { - w = p6-p7+1; - band1[i]=0; - band2[i]=0; - band3[i]= (0.5*(1-cos(2*PI*((i-p6+w)+1)/((2*w))))); - band4[i]= (0.5*(1-cos(2*PI*((i-p6)+1)/((2*w))))); - band5[i]=0; - } - - if (i > p7 && i < p8) - { - band1[i]=0; - band2[i]=0; - band3[i]=0; - band4[i]=1; - band5[i]=0; - } - - if (i >= p8 && i <= p9) - { - w = p8-p9+1; - band1[i]=0; - band2[i]=0; - band3[i]=0; - band4[i]= (0.5*(1-cos(2*PI*((i-p8+w)+1)/((2*w))))); - band5[i]= (0.5*(1-cos(2*PI*((i-p8)+1)/((2*w))))); - - } - - if (i > p9 && i < p10) - { - band1[i]=0; - band2[i]=0; - band3[i]=0; - band4[i]=0; - band5[i]=1; - } - + L_mags[i] *= eqcurve.at(i); + R_mags[i] *= eqcurve.at(i); } - - - -} \ No newline at end of file +}
--- a/sv/filter/DSP.h Thu Mar 06 14:50:00 2008 +0000 +++ b/sv/filter/DSP.h Thu Mar 06 14:56:40 2008 +0000 @@ -47,14 +47,12 @@ void log10plot(float* L_mags, float* plotFFTarray, int framesize, int plotsize); -void log10plot2(float* L_mags, float* plotFFTarray, int framesize, int plotsize); +void log10plot2(QVector<int>& L_mags, float* plotFFTarray, int framesize, int plotsize); -void applyEQ(float* L_mags, float* R_mags, int framesize, int plotsize, QVector<int> eqcurve); +void applyEQ(float* L_mags, float* R_mags, int framesize, int plotsize, QVector<int>& eqcurve); void stereo2ms(float* left, float* right, int framesize); void ms2stereo(float* left, float* right, int framesize); -void bandeq(float* L_mags, float* R_mags, int gainband1, int gainband2, int gainband3, int gainband4, int gainband5, float* bandcurve, int framesize); - -void create_filterbands(int framesize); +void bandeq(float* L_mags, float* R_mags, QVector<int>& eqcurve, int framesize);
--- a/sv/filter/EqualizerFilter.cpp Thu Mar 06 14:50:00 2008 +0000 +++ b/sv/filter/EqualizerFilter.cpp Thu Mar 06 14:56:40 2008 +0000 @@ -28,22 +28,43 @@ #include "main/MainWindow.h" -EqualizerFilter::EqualizerFilter() : PropertyContainer() +EqualizerFilter::EqualizerFilter(size_t framesize, QMutex *mutex) : PropertyContainer() , + m_simpleMode(false) , + m_nbBand(5), + m_framesize(framesize), + m_mutex(mutex), + m_resolution(400) { + for (int i=0; i<m_nbBand; i++) { + m_gainband[i] = 0; + } + setObjectName("Equalizer"); - for(int i = 0 ; i < 400 ; i++){ + for(int i = 0 ; i < m_resolution ; i++){ m_eqcurve.push_back(0); } - m_curve = (float *) calloc(400, sizeof(float)); + m_curve = (float *) calloc(m_resolution, sizeof(float)); + band = (float **)calloc(m_nbBand, sizeof(float*)); + for(int i = 0 ; i < m_nbBand ; i++){ + band[i]=(float *)calloc((m_framesize/2), sizeof(float)); + } + + m_plotbandcurve=(float *)malloc(sizeof(float)*(m_resolution)); + setFilterEnabled(false); } EqualizerFilter::~EqualizerFilter() { m_eqcurve.clear(); + + for(int i = 0 ; i < m_nbBand ; i++){ + delete band[i]; + } + delete band; } EqualizerFilter::PropertyList EqualizerFilter::getProperties() const @@ -51,12 +72,18 @@ PropertyList list; list.push_back("Equalizer"); list.push_back("Enable"); + list.push_back("SimpleMode"); + for (int i=0; i<m_nbBand; i++) { + QString name = "GainBand" + QString::number(i); + list.push_back(name); + } return list; } QString EqualizerFilter::getPropertyLabel(const PropertyName &name) const { if (name == "Equalizer") return tr("Equalizer"); + if (name == "SimpleMode") return tr("Simple Mode"); return ""; } @@ -64,8 +91,16 @@ { if (name == "Equalizer") return PlotProperty; if (name == "Enable") return InvalidProperty; + if (name == "SimpleMode") return ToggleProperty; + if (name.left(8) == "GainBand") return RangeProperty; return InvalidProperty; } + +QString EqualizerFilter::getPropertyGroupName(const PropertyName &name) const +{ + if (name.left(8) == "GainBand") return "GainBand"; + return QString(); +} int EqualizerFilter::getPropertyRangeAndValue(const PropertyName &name, int *min, int *max, int *deflt) const @@ -83,6 +118,19 @@ val = (m_enabled ? 1 : 0); } + if (name == "SimpleMode") { + if (deflt) *deflt = 0; + val = (m_simpleMode ? 1 : 0); + } + + if (name.left(8) == "GainBand") { + if (min) *min = -100; + if (max) *max = 100; + if (deflt) *deflt = 0; + int i = name.right(1).toInt(); + val = m_gainband[i]; + } + #ifdef DEBUG_FILTERS std::cerr << "EqualizerFilter::getPropertyRangeAndValue = " << val << std::endl; #endif @@ -108,7 +156,18 @@ m_enabled = false; } emit propertyChanged("Enable"); + } else if (name == "SimpleMode"){ + m_simpleMode = (value > 0) ? true : false; + if (m_simpleMode) + { + create_filterbands(); + } + } else if (name.left(8) == "GainBand"){ + int i = name.right(1).toInt(); + m_gainband[i] = value; + create_filterbands(); } + #ifdef DEBUG_FILTERS std::cerr << "EqualizerFilter::hopfactor = " << hopfactor << std::endl; std::cerr << "EqualizerFilter::m_interpfactor = " << m_interpfactor << std::endl; @@ -124,7 +183,6 @@ m_eqcurve.clear(); for (int i = 0; i < value.size(); i++) { - //if (i < m_eqcurve.size()) m_eqcurve.push_back(value.at(i)); } } @@ -142,8 +200,178 @@ void EqualizerFilter::emitPlotFFTArray(float *signal, int framesize) { - log10plot(signal, m_curve, framesize, m_eqcurve.size()); + log10plot(signal, m_curve, framesize, m_resolution); emit signalChanged(m_curve); } - \ No newline at end of file + + +void EqualizerFilter::create_filterbands() +{ + m_mutex->lock(); + + float binwidth = 44100/4096; + + float xover1 = 80; //100 + float xover2 = 700; //700 + float xover3 = 3000; //3000 + float xover4 = 9000; //9000 + + float width1 = 50; //50 + float width2 = 300; //100 + float width3 = 3000; //300 + float width4 = 1900; //900 + + int w; + + xover1=(xover1/binwidth); + xover2=(xover2/binwidth); + xover3=(xover3/binwidth); + xover4=(xover4/binwidth); + + width1=(width1/binwidth); + width2=(width2/binwidth); + width3=(width3/binwidth); + width4=(width4/binwidth); + + int p1 = 0; + int p2 = floor(xover1-(width1/2)); + int p3 = floor(xover1+(width1/2)); + int p4 = floor(xover2-(width2/2)); + int p5 = floor(xover2+(width2/2)); + int p6 = floor(xover3-(width3/2)); + int p7 = floor(xover3+(width3/2)); + int p8 = floor(xover4-(width4/2)); + int p9 = floor(xover4+(width4/2)); + int p10 = 2048; + + float maxcut=190; //18db of attenuation + float inc_cut=(1-(1/maxcut))/100; + + float maxboost=2; //6 db of gain + float inc_boost=(maxboost-1)/100; + float g1=1,g2=1,g3=1,g4=1,g5=1,instgain=1; + + if (m_gainband[0] < 0){g1=(1/maxcut)+((100+ (float)m_gainband[0])*inc_cut);} //not finished!!!! + if (m_gainband[0] == 0){g1=1;} + if (m_gainband[0] > 0){g1=1+(((float)m_gainband[0])*inc_boost);} + + if (m_gainband[1] < 0){g2=(1/maxcut)+((100+ (float)m_gainband[1])*inc_cut);} //not finished!!!! + if (m_gainband[1] == 0){g2=1;} + if (m_gainband[1] > 0){g2=1+(((float)m_gainband[1])*inc_boost);} + + if (m_gainband[2] < 0){g3=(1/maxcut)+((100+ (float)m_gainband[2])*inc_cut);} //not finished!!!! + if (m_gainband[2] == 0){g3=1;} + if (m_gainband[2] > 0){g3=1+(((float)m_gainband[2])*inc_boost);} + + if (m_gainband[3] < 0){g4=(1/maxcut)+((100+ (float)m_gainband[3])*inc_cut);} //not finished!!!! + if (m_gainband[3] == 0){g4=1;} + if (m_gainband[3] > 0){g4=1+(((float)m_gainband[3])*inc_boost);} + + if (m_gainband[4] < 0){g5=(1/maxcut)+((100+ (float)m_gainband[4])*inc_cut);} //not finished!!!! + if (m_gainband[4] == 0){g5=1;} + if (m_gainband[4] > 0){g5=1+(((float)m_gainband[4])*inc_boost);} + + m_eqcurve.clear(); + + + for (int i=0;i<m_framesize/2;i++) + { + if (i < p2) + { + band[0][i]=1; + band[1][i]=0; + band[2][i]=0; + band[3][i]=0; + band[4][i]=0; + } + + if (i >= p2 && i <= p3) + { + w = p3-p2+1; + band[0][i]= (0.5*(1-cos(2*PI*((i-p2+w)+1)/((2*w))))); + band[1][i]= (0.5*(1-cos(2*PI*((i-p2)+1)/((2*w))))); + band[2][i]=0; + band[3][i]=0; + band[4][i]=0; + } + + + if (i > p3 && i < p4) + { + band[0][i]=0; + band[1][i]=1; + band[2][i]=0; + band[3][i]=0; + band[4][i]=0; + } + + if (i >= p4 && i <= p5) + { + w = p4-p5+1; + band[0][i]=0; + band[1][i]= (0.5*(1-cos(2*PI*((i-p4+w)+1)/((2*w))))); + band[2][i]= (0.5*(1-cos(2*PI*((i-p4)+1)/((2*w))))); + band[3][i]=0; + band[4][i]=0; + } + + if (i > p5 && i < p6) + { + band[0][i]=0; + band[1][i]=0; + band[2][i]=1; + band[3][i]=0; + band[4][i]=0; + } + + if (i >= p6 && i <= p7) + { + w = p6-p7+1; + band[0][i]=0; + band[1][i]=0; + band[2][i]= (0.5*(1-cos(2*PI*((i-p6+w)+1)/((2*w))))); + band[3][i]= (0.5*(1-cos(2*PI*((i-p6)+1)/((2*w))))); + band[4][i]=0; + } + + if (i > p7 && i < p8) + { + band[0][i]=0; + band[1][i]=0; + band[2][i]=0; + band[3][i]=1; + band[4][i]=0; + } + + if (i >= p8 && i <= p9) + { + w = p8-p9+1; + band[0][i]=0; + band[1][i]=0; + band[2][i]=0; + band[3][i]= (0.5*(1-cos(2*PI*((i-p8+w)+1)/((2*w))))); + band[4][i]= (0.5*(1-cos(2*PI*((i-p8)+1)/((2*w))))); + + } + + if (i > p9 && i < p10) + { + band[0][i]=0; + band[1][i]=0; + band[2][i]=0; + band[3][i]=0; + band[4][i]=1; + } + + instgain=(g1*band[0][i])+(g2*band[1][i])+(g3*band[2][i])+(g4*band[3][i])+(g5*band[4][i]); + m_eqcurve.push_back(((int) instgain)); + } + + m_mutex->unlock(); + + log10plot2(m_eqcurve,m_plotbandcurve, m_framesize, m_resolution); + + emit filterChanged(m_plotbandcurve); + +} \ No newline at end of file
--- a/sv/filter/EqualizerFilter.h Thu Mar 06 14:50:00 2008 +0000 +++ b/sv/filter/EqualizerFilter.h Thu Mar 06 14:56:40 2008 +0000 @@ -19,22 +19,24 @@ #ifndef _EQUALIZER_FILTER_H_ #define _EQUALIZER_FILTER_H_ +#include <QMutex> + #include "base/PropertyContainer.h" -typedef QVector<int> VectorOfInt; - class EqualizerFilter : public PropertyContainer { Q_OBJECT public: - EqualizerFilter(); + EqualizerFilter(size_t framesize, QMutex *mutex); virtual ~EqualizerFilter(); virtual QString getPropertyContainerIconName() const {return "";} virtual QString getPropertyContainerName() const {return "Time and Pitch filter";} + virtual QString getPropertyGroupName(const PropertyName &) const; + virtual PropertyList getProperties() const; virtual QString getPropertyLabel(const PropertyName &) const; virtual PropertyType getPropertyType(const PropertyName &) const; @@ -49,14 +51,19 @@ inline bool isEnabled() {return m_enabled;} inline bool bypass() {return !m_enabled;} - - inline QVector<int> curve() {return m_eqcurve;} + inline bool simpleMode() {return m_simpleMode;} + inline int* gainband() {return m_gainband;} + + inline QVector<int>& curve() {return m_eqcurve;} void emitPlotFFTArray(float *signal, int framesize); + void create_filterbands(); + signals: void filterEnabled(bool); void signalChanged(float *); + void filterChanged(float *); public slots : void setFilterEnabled(bool b); @@ -66,9 +73,22 @@ QVector<int> m_eqcurve; float* m_curve; + float* m_plotbandcurve; bool m_enabled; + bool m_simpleMode; + + int m_gainband[5]; + int m_nbBand; + + int m_resolution; + + float **band; + + size_t m_framesize; + + QMutex * m_mutex; }; #endif \ No newline at end of file
--- a/sv/filter/MultiRealTimeFilter.cpp Thu Mar 06 14:50:00 2008 +0000 +++ b/sv/filter/MultiRealTimeFilter.cpp Thu Mar 06 14:56:40 2008 +0000 @@ -27,27 +27,6 @@ #include "system/System.h" #include "main/MainWindow.h" -/*float *audioframe; -float *prev_audioframe; -float *window; -float *processedframe; -float *outbuffer; -float *holdbuffer3; -float *holdbuffer2; -float *holdbuffer1; - -float *c_phase; ///CURRENT FRAME phases -float *p_phase; ///PREVIOUS FRAME phases -float *c_synthphase; -float *p_synthphase; -float *synthframe;*/ - -/* DAN removed -float *c_mags; ///CURRENT FRAME MAGNITUDES -float *p_mags; ///PREVIOUS FRAME MAGNITUDES -float *FFTframe; -*/ - // DAN added float *L_mags; ///CURRENT FRAME MAGNITUDES float *R_mags; ///CURRENT FRAME MAGNITUDES @@ -57,12 +36,6 @@ float *L_FFTframe; //Left FFT Frame float *R_FFTframe; //Right FFT Frame -float *band1; -float *band2; -float *band3; -float *band4; -float *band5; - extern float hopfactor; //need in DSP.cpp @@ -81,8 +54,10 @@ currentposition = m_hop; + m_mutex = new QMutex; + m_timeStretchFilter = new TimeStretchFilter(); - m_equalizerFilter = new EqualizerFilter(); + m_equalizerFilter = new EqualizerFilter(m_framesize, m_mutex); m_filterCollection.push_back(m_timeStretchFilter); m_filterCollection.push_back(m_equalizerFilter); @@ -108,12 +83,6 @@ L_processedframe=(float *)calloc((m_framesize), sizeof(float)); //The current frame R_processedframe=(float *)calloc((m_framesize), sizeof(float)); - //FFTframe=(float *)calloc((m_framesize), sizeof(float)); - //audioframe=(float *)calloc((m_framesize), sizeof(float)); //The current frame - //prev_audioframe=(float *)calloc((m_framesize), sizeof(float)); - //processedframe=(float *)calloc((m_framesize), sizeof(float)); //The current frame - //synthframe=(float *)calloc((m_framesize), sizeof(float)); - L_outbuffer=(float *)calloc((m_framesize/4), sizeof(float)); //The current output segment which is 1/4 framesize for 75% overlap L_holdbuffer3=(float *)calloc((m_framesize*0.75), sizeof(float)); //The hold buffer for the previous frame segment L_holdbuffer2=(float *)calloc((m_framesize/2), sizeof(float)); //The fold buffer for the frame segment 2 frames ago @@ -124,13 +93,6 @@ R_holdbuffer2=(float *)calloc((m_framesize/2), sizeof(float)); //The fold buffer for the frame segment 2 frames ago R_holdbuffer1=(float *)calloc((m_framesize/4), sizeof(float)); - /* - outbuffer=(float *)calloc((m_framesize/4), sizeof(float)); //The current output segment which is 1/4 framesize for 75% overlap - holdbuffer3=(float *)calloc((m_framesize*0.75), sizeof(float)); //The hold buffer for the previous frame segment - holdbuffer2=(float *)calloc((m_framesize/2), sizeof(float)); //The fold buffer for the frame segment 2 frames ago - holdbuffer1=(float *)calloc((m_framesize/4), sizeof(float)); - */ - L_mags=(float *)calloc((m_framesize/2), sizeof(float)); //The magnitude and phase arrays R_mags=(float *)calloc((m_framesize/2), sizeof(float)); L_phase=(float *)calloc((m_framesize/2), sizeof(float)); @@ -144,27 +106,6 @@ pL_synthphase=(float *)calloc((m_framesize/2), sizeof(float)); pR_synthphase=(float *)calloc((m_framesize/2), sizeof(float)); - /* - c_mags=(float *)calloc((m_framesize/2), sizeof(float)); //The magnitude and phase arrays - p_mags=(float *)calloc((m_framesize/2), sizeof(float)); - c_phase=(float *)calloc((m_framesize/2), sizeof(float)); - p_phase=(float *)calloc((m_framesize/2), sizeof(float)); - c_synthphase=(float *)calloc((m_framesize/2), sizeof(float)); - p_synthphase=(float *)calloc((m_framesize/2), sizeof(float)); - */ - - band1=(float *)calloc((m_framesize/2), sizeof(float)); - band2=(float *)calloc((m_framesize/2), sizeof(float)); - band3=(float *)calloc((m_framesize/2), sizeof(float)); - band4=(float *)calloc((m_framesize/2), sizeof(float)); - band5=(float *)calloc((m_framesize/2), sizeof(float)); - - - bandcurve=(float *)calloc((m_framesize/2), sizeof(float)); - plotFFTarray=(float *)calloc((400), sizeof(float)); - plotbandcurve=(float *)calloc((400), sizeof(float)); - //eqcurve=(float *)calloc((400), sizeof(float)); - peak_locations=(float *)calloc((m_framesize/2), sizeof(float)); hanning(window, m_framesize); @@ -199,17 +140,6 @@ delete L_processedframe; // delete R_processedframe; - /* DAN Removed - delete audioframe; - delete prev_audioframe; - delete processedframe; - delete synthframe; - delete holdbuffer3; - delete holdbuffer2; - delete holdbuffer1; - delete outbuffer; - */ - delete window; delete L_outbuffer; @@ -221,14 +151,6 @@ delete R_holdbuffer2; delete R_holdbuffer1; - /* - delete c_mags; - delete p_mags; - delete c_phase; - delete p_phase; - delete c_synthphase; - delete p_synthphase;*/ - delete L_phase; delete R_phase; delete pL_phase; @@ -240,23 +162,11 @@ delete peak_locations; - delete band1; - delete band2; - delete band3; - delete band4; - delete band5; - - delete bandcurve; - delete plotbandcurve; - //delete eqcurve; - delete plotFFTarray; - - - hopfactor = 1; emit playSpeedChanged(1); + delete m_mutex; /***************************/ } @@ -361,21 +271,21 @@ //Will need a simplemode " m_equalizerFilter->simplemode_bypass() " to switch between draw and slider control if (m_equalizerFilter->bypass() == false) { - - /*if (m_equalizerFilter->simplemode_bypass() == false) + + m_mutex->lock(); + if (m_equalizerFilter->simpleMode()) { - create_filterbands(); //Creates each filter band and creates "bandcurve" - bandeq(L_mags, R_mags, gainband1, gainband2, gainband3, gainband4, gainband5, bandcurve); //Gainband 1 - 5 values from EQ sliders - log10plot2(bandcurve,plotbandcurve, m_framesize, 400); //Converts linear band curve to log band curve only for plot + //m_equalizerFilter->create_filterbands(); + bandeq(L_mags, R_mags, m_equalizerFilter->curve(), m_framesize); //Gainband 1 - 5 values from EQ sliders + //log10plot2(bandcurve,plotbandcurve, m_framesize, 400); //Converts linear band curve to log band curve only for plot } else - {*/ + { applyEQ(L_mags, R_mags, m_framesize, m_equalizerFilter->curve().size(), m_equalizerFilter->curve()); //Takes "eqcurve" which is what user draws in advanced mode - //} + } m_equalizerFilter->emitPlotFFTArray(L_mags, m_framesize); - //log10plot(L_mags,plotFFTarray, m_framesize, 400); //Plots FFT for either eq - + m_mutex->unlock(); } if (m_timeStretchFilter->bypass() == false) @@ -439,16 +349,6 @@ pol2cart(R_FFTframe, R_mags, R_phase, m_framesize); } - // INVERSE FFTS REQUIRED BY ALL PROCESSES - /*pol2cart(L_FFTframe, L_mags, cL_synthphase, m_framesize); - pol2cart(R_FFTframe, R_mags, cR_synthphase, m_framesize); - - fft_object.do_ifft (L_FFTframe,L_processedframe); - fft_object.do_ifft (R_FFTframe,R_processedframe); - fft_object.rescale (L_processedframe); - fft_object.rescale (R_processedframe); - */ - fft_object.do_ifft (L_FFTframe,L_processedframe); fft_object.do_ifft (R_FFTframe,R_processedframe); @@ -504,14 +404,6 @@ output[1][i] = R_outbuffer[i]; } } - - ////DAN - REMOVED REPLACED ABOVE - /*for (int ch = 0; ch < channel; ++ch) - { - for (size_t i = 0; i < samples; ++i) { - output[ch][i] = outbuffer[i]; - } - }*/ } size_t MultiRealTimeFilter::getRequiredInputSamples(size_t outputSamplesNeeded) @@ -540,29 +432,11 @@ void MultiRealTimeFilter::setFilterEnabled(bool b) { filterEnabled = (m_timeStretchFilter->isEnabled() || m_equalizerFilter->isEnabled()); - /*filterEnabled=b; - - if (filterEnabled) - { - if (!m_timeStretchFilter->bypass()) - emit playSpeedChanged(hopfactor); - } - else - emit playSpeedChanged(1);*/ } void MultiRealTimeFilter::setFilterEnabled(int b) { filterEnabled = (m_timeStretchFilter->isEnabled() || m_equalizerFilter->isEnabled()); - /*filterEnabled=b; - - if (filterEnabled) - { - if (!m_timeStretchFilter->bypass()) - emit playSpeedChanged(hopfactor); - } - else - emit playSpeedChanged(1);*/ }
--- a/sv/filter/MultiRealTimeFilter.h Thu Mar 06 14:50:00 2008 +0000 +++ b/sv/filter/MultiRealTimeFilter.h Thu Mar 06 14:56:40 2008 +0000 @@ -109,11 +109,11 @@ */ // DAN Added - Following variables for EQ tool - int gainband1; + /*int gainband1; int gainband2; int gainband3; int gainband4; - int gainband5; + int gainband5;*/ /*float *band1; float *band2; @@ -122,14 +122,16 @@ float *band5;*/ // DAN Added - Following variables for graphical plots in EQ tool - float *bandcurve; - float *plotbandcurve; + //float *bandcurve; + //float *plotbandcurve; //float *eqcurve; - float *plotFFTarray; + //float *plotFFTarray; TimeStretchFilter * m_timeStretchFilter; EqualizerFilter * m_equalizerFilter; + QMutex *m_mutex; + }; #endif \ No newline at end of file
--- a/widgets/Plotter.cpp Thu Mar 06 14:50:00 2008 +0000 +++ b/widgets/Plotter.cpp Thu Mar 06 14:56:40 2008 +0000 @@ -141,7 +141,7 @@ if ((event->button() == Qt::LeftButton) && m_curveMaskActive) { m_curveMaskActive = false; unsetCursor(); - emit curveChanged(m_curveMask); + emit filterChanged(m_curveMask); } } @@ -193,4 +193,14 @@ void Plotter::setMargin(int margin){ m_margin = margin; +} + +void Plotter::setFilter(float* filter) +{ + m_curveMask.clear(); + for (int i=0; i<m_signalWidth; i++) + { + m_curveMask.push_back((int) (m_signalHeight - filter[i]*89.0)); + } + refreshPixmap(); } \ No newline at end of file
--- a/widgets/Plotter.h Thu Mar 06 14:50:00 2008 +0000 +++ b/widgets/Plotter.h Thu Mar 06 14:56:40 2008 +0000 @@ -34,10 +34,12 @@ void setMargin(int margin); signals: - void curveChanged(QVector<int>&); + void filterChanged(QVector<int>&); public slots: void setCurve(float *); + void setFilter(float *); + protected: void paintEvent(QPaintEvent *event);
--- a/widgets/PropertyBox.cpp Thu Mar 06 14:50:00 2008 +0000 +++ b/widgets/PropertyBox.cpp Thu Mar 06 14:56:40 2008 +0000 @@ -434,18 +434,15 @@ connect(slider, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); if (inGroup) { + slider->setOrientation(Qt::Vertical); slider->setFixedWidth(48); - slider->setFixedHeight(24); + slider->setFixedHeight(100); m_groupLayouts[groupName]->addWidget(slider); + } else { slider->setFixedWidth(100); slider->setFixedHeight(32); m_layout->addWidget(slider, row, 1); - QLabel *label = new QLabel(m_mainWidget); - connect(slider, SIGNAL(valueChanged(int)), - label, SLOT(setNum(int))); - label->setNum(value); - m_layout->addWidget(label, row, 2); } m_propertyControllers[name] = slider; @@ -574,8 +571,9 @@ }*/ if (!have) { - connect(cb, SIGNAL(curveChanged(QVector<int>&)), this, SLOT(propertyControllerChanged(QVector<int>&))); + connect(cb, SIGNAL(filterChanged(QVector<int>&)), this, SLOT(propertyControllerChanged(QVector<int>&))); connect(m_container, SIGNAL(signalChanged(float*)), cb, SLOT(setCurve(float*))); + connect(m_container, SIGNAL(filterChanged(float*)), cb, SLOT(setFilter(float*))); connect(cb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(cb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
--- a/widgets/Slider.cpp Thu Mar 06 14:50:00 2008 +0000 +++ b/widgets/Slider.cpp Thu Mar 06 14:56:40 2008 +0000 @@ -11,20 +11,86 @@ COPYING included with this distribution for more information. */ +#include <QVBoxLayout> + #include "Slider.h" -Slider::Slider(QWidget *parent) : QSlider(parent) , +Slider::Slider(QWidget *parent) : QWidget(parent) , m_showTooltip(true) { - connect(this, SIGNAL(valueChanged(int)), + QHBoxLayout *mainlayout = new QHBoxLayout(); + mainlayout->setMargin(0); + + m_slider = new QSlider(Qt::Horizontal); + + m_label = new QLabel; + connect(m_slider, SIGNAL(valueChanged(int)), m_label, SLOT(setNum(int))); + m_label->setNum(value()); + + mainlayout->addWidget(m_slider); + mainlayout->addWidget(m_label); + + setLayout(mainlayout); + + connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(updateToolTip())); + + connect(m_slider, SIGNAL(valueChanged(int)), + this, SIGNAL(valueChanged(int))); + } -Slider::Slider(Qt::Orientation orientation, QWidget * parent) : QSlider(orientation, parent) , +Slider::Slider(Qt::Orientation orientation, QWidget * parent) : QWidget(parent) , m_showTooltip(true) { - connect(this, SIGNAL(valueChanged(int)), + QGridLayout *mainlayout = new QGridLayout(); + mainlayout->setMargin(0); + + m_slider = new QSlider(orientation); + + m_label = new QLabel; + connect(m_slider, SIGNAL(valueChanged(int)), m_label, SLOT(setNum(int))); + m_label->setNum(value()); + + if (orientation == Qt::Horizontal) + { + mainlayout->addWidget(m_slider, 0, 0); + mainlayout->addWidget(m_label, 0, 1); + } else { + mainlayout->addWidget(m_slider, 0, 0); + mainlayout->addWidget(m_label, 1, 0); + } + + setLayout(mainlayout); + + connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(updateToolTip())); + + connect(m_slider, SIGNAL(valueChanged(int)), + this, SIGNAL(valueChanged(int))); +} + +void Slider::setOrientation(Qt::Orientation or) +{ + QLayout * cur_layout = layout(); + delete cur_layout; + + QGridLayout *mainlayout = new QGridLayout(); + mainlayout->setMargin(0); + + m_slider->setOrientation(or); + + if (or == Qt::Horizontal) + { + mainlayout->addWidget(m_slider, 0, 0); + mainlayout->addWidget(m_label, 0, 1); + } else { + mainlayout->addWidget(m_slider, 0, 0); + mainlayout->addWidget(m_label, 1, 0); + } + + this->setLayout(mainlayout); + } Slider::~Slider() @@ -34,7 +100,7 @@ void Slider::enterEvent(QEvent *e) { - QSlider::enterEvent(e); + QWidget::enterEvent(e); QPalette palette; palette.setColor(QPalette::Button,palette.color(QPalette::Highlight)); setPalette(palette); @@ -44,7 +110,7 @@ void Slider::leaveEvent(QEvent *e) { - QSlider::enterEvent(e); + QWidget::enterEvent(e); QPalette palette; setPalette(palette); emit mouseLeft();
--- a/widgets/Slider.h Thu Mar 06 14:50:00 2008 +0000 +++ b/widgets/Slider.h Thu Mar 06 14:56:40 2008 +0000 @@ -15,8 +15,9 @@ #define _SLIDER_H_ #include <QSlider> +#include <QLabel> -class Slider : public QSlider +class Slider : public QWidget { Q_OBJECT public: @@ -28,9 +29,21 @@ void setShowToolTip(bool show); + inline void setMinimum(int min){m_slider->setMinimum(min);} + inline void setMaximum(int max){m_slider->setMaximum(max);} + + inline void setPageStep(int step){m_slider->setPageStep(step);} + + void setOrientation(Qt::Orientation or); + + inline int value () const {return m_slider->value();} + inline void setValue(int value) {m_slider->setValue(value); m_label->setNum(value);} + + signals: void mouseEntered(); void mouseLeft(); + void valueChanged(int); protected slots: void updateToolTip(); @@ -41,6 +54,10 @@ bool m_showTooltip; + QSlider *m_slider; + + QLabel *m_label; + }; #endif \ No newline at end of file