From 7539144b2c9235a88953990c1b63cf47d9588f45 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 13 Apr 2009 01:48:47 +0200 Subject: [PATCH] ZynAddSubFX: follow recent changes in CVS repository No ChangeLog entries available, however mainly seem to be cleanups. --- plugins/zynaddsubfx/src/Effects/Alienwah.C | 77 ++-- plugins/zynaddsubfx/src/Effects/Alienwah.h | 13 +- plugins/zynaddsubfx/src/Effects/Chorus.C | 18 +- plugins/zynaddsubfx/src/Effects/Chorus.h | 40 +- plugins/zynaddsubfx/src/Effects/Distorsion.C | 6 +- plugins/zynaddsubfx/src/Effects/Distorsion.h | 2 +- .../zynaddsubfx/src/Effects/DynamicFilter.C | 8 +- .../zynaddsubfx/src/Effects/DynamicFilter.h | 2 +- plugins/zynaddsubfx/src/Effects/EQ.C | 4 +- plugins/zynaddsubfx/src/Effects/Echo.C | 7 +- plugins/zynaddsubfx/src/Effects/Echo.h | 17 +- plugins/zynaddsubfx/src/Effects/Effect.h | 27 +- plugins/zynaddsubfx/src/Effects/EffectLFO.C | 7 +- plugins/zynaddsubfx/src/Effects/EffectLFO.h | 7 +- plugins/zynaddsubfx/src/Effects/EffectMgr.C | 38 +- plugins/zynaddsubfx/src/Effects/EffectMgr.h | 33 +- plugins/zynaddsubfx/src/Effects/Phaser.C | 204 +++++----- plugins/zynaddsubfx/src/Effects/Phaser.h | 67 ++-- plugins/zynaddsubfx/src/Effects/Reverb.C | 363 +++++++++--------- plugins/zynaddsubfx/src/Effects/Reverb.h | 136 +++---- plugins/zynaddsubfx/src/UI/EffUI.cc | 2 +- plugins/zynaddsubfx/src/UI/EffUI.fl | 8 +- 22 files changed, 576 insertions(+), 510 deletions(-) diff --git a/plugins/zynaddsubfx/src/Effects/Alienwah.C b/plugins/zynaddsubfx/src/Effects/Alienwah.C index 29a7afbc6..0f5e40b4c 100644 --- a/plugins/zynaddsubfx/src/Effects/Alienwah.C +++ b/plugins/zynaddsubfx/src/Effects/Alienwah.C @@ -20,17 +20,16 @@ */ -#include +#include #include "Alienwah.h" -#include -Alienwah::Alienwah(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_) +Alienwah::Alienwah(const int &insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_) :Effect(insertion_,efxoutl_,efxoutr_,NULL,0),oldl(NULL),oldr(NULL) { setpreset(Ppreset); cleanup(); - oldclfol.a=fb;oldclfol.b=0.0; - oldclfor.a=fb;oldclfor.b=0.0; + oldclfol=complex(fb,0.0); + oldclfor=complex(fb,0.0); }; Alienwah::~Alienwah(){ @@ -43,39 +42,38 @@ Alienwah::~Alienwah(){ * Apply the effect */ void Alienwah::out(REALTYPE *smpsl,REALTYPE *smpsr){ - int i; - REALTYPE lfol,lfor; - COMPLEXTYPE clfol,clfor,out,tmp; - + REALTYPE lfol,lfor; //Left/Right LFOs + complex clfol,clfor,out,tmp; + /**\todo Rework, as optimization can be used when the new complex type is + * utilized. + * Before all calculations needed to be done with individual REALTYPE, + * but now they can be done together*/ lfo.effectlfoout(&lfol,&lfor); lfol*=depth*PI*2.0;lfor*=depth*PI*2.0; - clfol.a=cos(lfol+phase)*fb;clfol.b=sin(lfol+phase)*fb; - clfor.a=cos(lfor+phase)*fb;clfor.b=sin(lfor+phase)*fb; + clfol=complex(cos(lfol+phase)*fb,sin(lfol+phase)*fb); //rework + clfor=complex(cos(lfor+phase)*fb,sin(lfor+phase)*fb); //rework - for (i=0;i=Pdelay) oldk=0; @@ -84,8 +82,8 @@ void Alienwah::out(REALTYPE *smpsl,REALTYPE *smpsr){ efxoutr[i]=r*(1.0-lrcross)+l*lrcross; }; - oldclfol.a=clfol.a;oldclfol.b=clfol.b; - oldclfor.a=clfor.a;oldclfor.b=clfor.b; + oldclfol=clfol; + oldclfor=clfor; }; @@ -93,11 +91,9 @@ void Alienwah::out(REALTYPE *smpsl,REALTYPE *smpsr){ * Cleanup the effect */ void Alienwah::cleanup(){ - for (int i=0;i(0.0,0.0); + oldr[i]=complex(0.0,0.0); }; oldk=0; }; @@ -147,8 +143,8 @@ void Alienwah::setdelay(const unsigned char &Pdelay){ if (oldr!=NULL) delete [] oldr; if (Pdelay>=MAX_ALIENWAH_DELAY) this->Pdelay=MAX_ALIENWAH_DELAY; else this->Pdelay=Pdelay; - oldl=new COMPLEXTYPE[Pdelay]; - oldr=new COMPLEXTYPE[Pdelay]; + oldl=new complex[Pdelay]; + oldr=new complex[Pdelay]; cleanup(); }; @@ -232,6 +228,3 @@ unsigned char Alienwah::getpar(const int &npar)const{ }; - - - diff --git a/plugins/zynaddsubfx/src/Effects/Alienwah.h b/plugins/zynaddsubfx/src/Effects/Alienwah.h index 4c4f23bbe..a27b45e7a 100644 --- a/plugins/zynaddsubfx/src/Effects/Alienwah.h +++ b/plugins/zynaddsubfx/src/Effects/Alienwah.h @@ -22,17 +22,15 @@ #ifndef ALIENWAH_H #define ALIENWAH_H +#include #include "../globals.h" #include "Effect.h" #include "EffectLFO.h" +using namespace std; #define MAX_ALIENWAH_DELAY 100 -struct COMPLEXTYPE { - REALTYPE a,b; -}; - /**"AlienWah" Effect*/ class Alienwah:public Effect { public: @@ -43,7 +41,7 @@ class Alienwah:public Effect { * @param efxoutr_ Pointer to Alienwah's left channel output buffer * @return Initialized Alienwah */ - Alienwah(int insetion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_); + Alienwah(const int &insetion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_); ~Alienwah(); void out(REALTYPE *const smpsl,REALTYPE *const smpsr); @@ -74,10 +72,9 @@ class Alienwah:public Effect { void setphase(const unsigned char &Pphase); //Internal Values - //const int insertion; //value inherited REALTYPE panning,fb,depth,lrcross,phase; - COMPLEXTYPE *oldl,*oldr; - COMPLEXTYPE oldclfol,oldclfor; + complex *oldl,*oldr; + complex oldclfol,oldclfor; int oldk; }; diff --git a/plugins/zynaddsubfx/src/Effects/Chorus.C b/plugins/zynaddsubfx/src/Effects/Chorus.C index 46c3658c7..d7462cc03 100644 --- a/plugins/zynaddsubfx/src/Effects/Chorus.C +++ b/plugins/zynaddsubfx/src/Effects/Chorus.C @@ -20,9 +20,11 @@ */ -#include +#include #include "Chorus.h" -#include +#include + +using namespace std; Chorus::Chorus(const int &insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_) :Effect(insertion_,efxoutl_,efxoutr_,NULL,0) @@ -54,9 +56,10 @@ REALTYPE Chorus::getdelay(REALTYPE xlfo){ result=(delay+xlfo*depth)*SAMPLE_RATE; } else result=0; - //check if it is too big delay(caused bu errornous setdelay() and setdepth() + //check if it is too big delay(caused bu errornous setdelay() and setdepth() + /**\todo fix setdelay() and setdepth(), so this error cannot occur*/ if ((result+0.5)>=maxdelay) { - fprintf(stderr,"%s","WARNING: Chorus.C::getdelay(..) too big delay (see setdelay and setdepth funcs.)\n"); + cerr << "WARNING: Chorus.C::getdelay(..) too big delay (see setdelay and setdepth funcs.)\n"; result=maxdelay-1.0; }; return(result); @@ -67,6 +70,7 @@ REALTYPE Chorus::getdelay(REALTYPE xlfo){ */ void Chorus::out(REALTYPE *smpsl,REALTYPE *smpsr){ int i; + const REALTYPE one=1.0; dl1=dl2;dr1=dr2; lfo.effectlfoout(&lfol,&lfor); @@ -93,7 +97,7 @@ void Chorus::out(REALTYPE *smpsl,REALTYPE *smpsr){ dlhi%=maxdelay; dlhi2=(dlhi-1+maxdelay)%maxdelay; - dllo=1.0-fmod(tmp,1.0); + dllo=1.0-fmod(tmp,one); efxoutl[i]=delayl[dlhi2]*dllo+delayl[dlhi]*(1.0-dllo); delayl[dlk]=inl+efxoutl[i]*fb; @@ -102,13 +106,13 @@ void Chorus::out(REALTYPE *smpsl,REALTYPE *smpsr){ //compute the delay in samples using linear interpolation between the lfo delays mdel=(dr1*(SOUND_BUFFER_SIZE-i)+dr2*i)/SOUND_BUFFER_SIZE; if (++drk>=maxdelay) drk=0; - tmp=drk-mdel+maxdelay*2.0;//where should I get the sample from + tmp=drk*1.0-mdel+maxdelay*2.0;//where should I get the sample from F2I(tmp,dlhi); dlhi%=maxdelay; dlhi2=(dlhi-1+maxdelay)%maxdelay; - dllo=1.0-fmod(tmp,1.0); + dllo=1.0-fmod(tmp,one); efxoutr[i]=delayr[dlhi2]*dllo+delayr[dlhi]*(1.0-dllo); delayr[dlk]=inr+efxoutr[i]*fb; diff --git a/plugins/zynaddsubfx/src/Effects/Chorus.h b/plugins/zynaddsubfx/src/Effects/Chorus.h index 85366e60b..b53db141e 100644 --- a/plugins/zynaddsubfx/src/Effects/Chorus.h +++ b/plugins/zynaddsubfx/src/Effects/Chorus.h @@ -28,13 +28,51 @@ #define MAX_CHORUS_DELAY 250.0 //ms +/**Chorus and Flange effects*/ class Chorus:public Effect { public: Chorus(const int &insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_); + /**Destructor*/ ~Chorus(); void out(REALTYPE *smpsl,REALTYPE *smpsr); void setpreset(unsigned char npreset); + /** + * Sets the value of the chosen variable + * + * The possible parameters are: + * -# Volume + * -# Panning + * -# LFO Frequency + * -# LFO Randomness + * -# LFO Type + * -# LFO stereo + * -# Depth + * -# Delay + * -# Feedback + * -# Flange Mode + * -# Subtractive + * @param npar number of chosen parameter + * @param value the new value + */ void changepar(const int &npar,const unsigned char &value); + /** + * Gets the value of the chosen variable + * + * The possible parameters are: + * -# Volume + * -# Panning + * -# LFO Frequency + * -# LFO Randomness + * -# LFO Type + * -# LFO stereo + * -# Depth + * -# Delay + * -# Feedback + * -# Flange Mode + * -# Subtractive + * @param npar number of chosen parameter + * @return the value of the parameter + */ unsigned char getpar(const int &npar)const; void cleanup(); @@ -51,7 +89,7 @@ class Chorus:public Effect { unsigned char Poutsub;//if I wish to substract the output instead of the adding it - //Control Parametrii + //Parameter Controls void setvolume(const unsigned char &Pvolume); void setpanning(const unsigned char &Ppanning); void setdepth(const unsigned char &Pdepth); diff --git a/plugins/zynaddsubfx/src/Effects/Distorsion.C b/plugins/zynaddsubfx/src/Effects/Distorsion.C index c00f3e607..33dabe2a7 100644 --- a/plugins/zynaddsubfx/src/Effects/Distorsion.C +++ b/plugins/zynaddsubfx/src/Effects/Distorsion.C @@ -20,9 +20,7 @@ */ -#include -#include -#include +#include #include "Distorsion.h" @@ -137,7 +135,7 @@ void waveshapesmps(int n,REALTYPE *smps,unsigned char type,unsigned char drive){ smps[i]=tmp/tmpv; }; break; - //update to Distorsion::changepar (Ptype max) if there is added more waveshapings functions + /**\todo update to Distorsion::changepar (Ptype max) if there is added more waveshapings functions*/ }; }; diff --git a/plugins/zynaddsubfx/src/Effects/Distorsion.h b/plugins/zynaddsubfx/src/Effects/Distorsion.h index d351a4b7e..c211168e0 100644 --- a/plugins/zynaddsubfx/src/Effects/Distorsion.h +++ b/plugins/zynaddsubfx/src/Effects/Distorsion.h @@ -29,7 +29,7 @@ //Waveshaping(called by Distorsion effect and waveshape from OscilGen) void waveshapesmps(int n,REALTYPE *smps,unsigned char type,unsigned char drive); - +/**Distortion Effect*/ class Distorsion:public Effect{ public: Distorsion(const int &insertion,REALTYPE *efxoutl_,REALTYPE *efxoutr_); diff --git a/plugins/zynaddsubfx/src/Effects/DynamicFilter.C b/plugins/zynaddsubfx/src/Effects/DynamicFilter.C index 5595f793d..150c4c590 100644 --- a/plugins/zynaddsubfx/src/Effects/DynamicFilter.C +++ b/plugins/zynaddsubfx/src/Effects/DynamicFilter.C @@ -20,9 +20,8 @@ */ -#include +#include #include "DynamicFilter.h" -#include DynamicFilter::DynamicFilter(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_) :Effect(insertion_,efxoutl_,efxoutr_,new FilterParams(0,64,64),0), @@ -127,7 +126,10 @@ void DynamicFilter::setpanning(const unsigned char &Ppanning){ void DynamicFilter::setampsns(const unsigned char &Pampsns){ ampsns=pow(Pampsns/127.0,2.5)*10.0; if (Pampsnsinv!=0) ampsns=-ampsns; - ampsmooth=exp(-Pampsmooth/127.0*10.0)*0.99; + ampsmooth=exp(-Pampsmooth/127.0*10.0)*0.99;/**\todo currently Pampsmooth is + * uninitialized when this is + * called. Please fix. + */ this->Pampsns=Pampsns; }; diff --git a/plugins/zynaddsubfx/src/Effects/DynamicFilter.h b/plugins/zynaddsubfx/src/Effects/DynamicFilter.h index 5aeacfc54..ba8c04407 100644 --- a/plugins/zynaddsubfx/src/Effects/DynamicFilter.h +++ b/plugins/zynaddsubfx/src/Effects/DynamicFilter.h @@ -27,7 +27,7 @@ #include "EffectLFO.h" #include "../DSP/Filter.h" - +/**DynamicFilter Effect*/ class DynamicFilter:public Effect { public: DynamicFilter(int insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_); diff --git a/plugins/zynaddsubfx/src/Effects/EQ.C b/plugins/zynaddsubfx/src/Effects/EQ.C index b4d34dbeb..b05120dc8 100644 --- a/plugins/zynaddsubfx/src/Effects/EQ.C +++ b/plugins/zynaddsubfx/src/Effects/EQ.C @@ -20,9 +20,7 @@ */ -#include -#include -#include +#include #include "EQ.h" EQ::EQ(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_) diff --git a/plugins/zynaddsubfx/src/Effects/Echo.C b/plugins/zynaddsubfx/src/Effects/Echo.C index dce740ab2..1be98fe33 100644 --- a/plugins/zynaddsubfx/src/Effects/Echo.C +++ b/plugins/zynaddsubfx/src/Effects/Echo.C @@ -150,6 +150,7 @@ void Echo::sethidamp(const unsigned char & Phidamp){ } void Echo::setpreset(unsigned char npreset){ + /**\todo see if the preset array can be replaced with a struct or a class*/ const int PRESET_SIZE=7; const int NUM_PRESETS=9; unsigned char presets[NUM_PRESETS][PRESET_SIZE]={ @@ -175,12 +176,13 @@ void Echo::setpreset(unsigned char npreset){ if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1; for (int n=0;n +#include #include "../Misc/Util.h" #include "../globals.h" #include "../Params/FilterParams.h" @@ -44,30 +44,43 @@ class Effect{ Effect(const int & insertion_,REALTYPE *const efxoutl_, REALTYPE *const efxoutr_,FilterParams *filterpars_, const unsigned char & Ppreset_); - /**Deconstructor*/ + /**Deconstructor + * + * Deconstructs the Effect and releases any resouces that it has + * allocated for itself*/ virtual ~Effect(){}; /** * Choose a preset * @param npreset number of chosen preset*/ - virtual void setpreset(unsigned char npreset){}; + virtual void setpreset(unsigned char npreset)=0; /**Change parameter npar to value * @param npar chosen parameter * @param value chosen new value*/ - virtual void changepar(const int &npar,const unsigned char &value){}; + virtual void changepar(const int &npar,const unsigned char &value)=0; /**Get the value of parameter npar * @param npar chosen parameter * @return the value of the parameter in an unsigned char or 0 if it * does not exist*/ - virtual unsigned char getpar(const int &npar)const {return(0);}; - virtual void out(REALTYPE *const smpsl,REALTYPE *const smpsr){}; + virtual unsigned char getpar(const int &npar)const=0; + /**Output result of effect based on the given buffers + * + * This method should result in the effect generating its results + * and placing them into the efxoutl and efxoutr buffers. + * Every Effect should overide this method. + * + * @param smpsl Input buffer for the Left channel + * @param smpsr Input buffer for the Right channel + */ + virtual void out(REALTYPE *const smpsl,REALTYPE *const smpsr)=0; /**Reset the state of the effect*/ virtual void cleanup(){}; /**This is only used for EQ (for user interface)*/ virtual REALTYPE getfreqresponse(REALTYPE freq){return (0);}; - unsigned char Ppreset; + unsigned char Ppreset;/** -#include -#include +#include +#include #include "EffectLFO.h" @@ -75,7 +74,7 @@ REALTYPE EffectLFO::getlfoshape(REALTYPE x){ else if ((x>0.25)&&(x<0.75)) out=2-4*x; else out=4.0*x-4.0; break; - //more to be added here; also ::updateparams() need to be updated (to allow more lfotypes) + /**\todo more to be added here; also ::updateparams() need to be updated (to allow more lfotypes)*/ default:out=cos(x*2*PI);//EffectLFO_SINE }; return(out); diff --git a/plugins/zynaddsubfx/src/Effects/EffectLFO.h b/plugins/zynaddsubfx/src/Effects/EffectLFO.h index a5c2b4f70..ca78b8414 100644 --- a/plugins/zynaddsubfx/src/Effects/EffectLFO.h +++ b/plugins/zynaddsubfx/src/Effects/EffectLFO.h @@ -24,7 +24,7 @@ #define EFFECT_LFO_H #include "../globals.h" - +/**LFO for some of the Effect objects*/ class EffectLFO{ public: EffectLFO(); @@ -40,11 +40,12 @@ class EffectLFO{ REALTYPE xl,xr; REALTYPE incx; - REALTYPE ampl1,ampl2,ampr1,ampr2;//necesar pentru "randomness" + REALTYPE ampl1,ampl2,ampr1,ampr2;//necessary for "randomness" REALTYPE lfointensity; REALTYPE lfornd; - char lfotype; + char lfotype; /**\todo GET RID OF CHAR (use a subclass if types are needed)*/ }; #endif + diff --git a/plugins/zynaddsubfx/src/Effects/EffectMgr.C b/plugins/zynaddsubfx/src/Effects/EffectMgr.C index b3ee816ca..f61896f6c 100644 --- a/plugins/zynaddsubfx/src/Effects/EffectMgr.C +++ b/plugins/zynaddsubfx/src/Effects/EffectMgr.C @@ -20,30 +20,34 @@ */ -#include -#include #include "EffectMgr.h" -EffectMgr::EffectMgr(int insertion_,pthread_mutex_t *mutex_){ - setpresettype("Peffect"); - efx=NULL; - nefx=0; - insertion=insertion_; - mutex=mutex_; - efxoutl=new REALTYPE[SOUND_BUFFER_SIZE]; - efxoutr=new REALTYPE[SOUND_BUFFER_SIZE];; +EffectMgr::EffectMgr(int insertion_,pthread_mutex_t *mutex_) + :insertion(insertion_), + efxoutl(new REALTYPE[SOUND_BUFFER_SIZE]), + efxoutr(new REALTYPE[SOUND_BUFFER_SIZE]), + filterpars(NULL),nefx(0),efx(NULL),mutex(mutex_),dryonly(false) +{ + setpresettype("Peffect"); /**\todo Figure out what this is doing + * , as it might be another leaky abstraction.*/ +// efx=NULL; +// nefx=0; +// insertion=insertion_; +// mutex=mutex_; +// efxoutl=new REALTYPE[SOUND_BUFFER_SIZE]; +// efxoutr=new REALTYPE[SOUND_BUFFER_SIZE]; for (int i=0;ivolume; if (nefx==7){//this is need only for the EQ effect + /**\todo figure out why*/ for (i=0;iaddpar("preset",efx->Ppreset); xml->beginbranch("EFFECT_PARAMETERS"); - for (int n=0;n<128;n++){ + for (int n=0;n<128;n++){ /**\todo evaluate who should oversee saving + * and loading of parameters*/ int par=geteffectpar(n); if (par==0) continue; xml->beginbranch("par_no",n); @@ -287,5 +293,3 @@ void EffectMgr::getfromXML(XMLwrapper *xml){ cleanup(); } - - diff --git a/plugins/zynaddsubfx/src/Effects/EffectMgr.h b/plugins/zynaddsubfx/src/Effects/EffectMgr.h index 5be4e4601..c680b335f 100644 --- a/plugins/zynaddsubfx/src/Effects/EffectMgr.h +++ b/plugins/zynaddsubfx/src/Effects/EffectMgr.h @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License (version 2) along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ #ifndef EFFECTMGR_H @@ -57,19 +56,41 @@ class EffectMgr:public Presets{ REALTYPE sysefxgetvolume(); void cleanup();/** +#include #include "Phaser.h" -#include +/**\todo figure out why this define was made*/ #define PHASER_LFO_SHAPE 2 Phaser::Phaser(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_) @@ -58,46 +58,46 @@ void Phaser::out(REALTYPE *smpsl,REALTYPE *smpsr){ if (lgain>1.0) lgain=1.0;else if (lgain<0.0) lgain=0.0; if (rgain>1.0) rgain=1.0;else if (rgain<0.0) rgain=0.0; - for (i=0;iPvolume=Pvolume; outvolume=Pvolume/127.0; if (insertion==0) volume=1.0; - else volume=outvolume; + else volume=outvolume; }; void Phaser::setpanning(const unsigned char &Ppanning){ @@ -165,18 +165,18 @@ void Phaser::setpreset(unsigned char npreset){ const int PRESET_SIZE=12; const int NUM_PRESETS=6; unsigned char presets[NUM_PRESETS][PRESET_SIZE]={ - //Phaser1 - {64,64,36,0,0,64,110,64,1,0,0,20}, - //Phaser2 - {64,64,35,0,0,88,40,64,3,0,0,20}, - //Phaser3 - {64,64,31,0,0,66,68,107,2,0,0,20}, - //Phaser4 - {39,64,22,0,0,66,67,10,5,0,1,20}, - //Phaser5 - {64,64,20,0,1,110,67,78,10,0,0,20}, - //Phaser6 - {64,64,53,100,0,58,37,78,3,0,0,20}}; + //Phaser1 + {64,64,36,0,0,64,110,64,1,0,0,20}, + //Phaser2 + {64,64,35,0,0,88,40,64,3,0,0,20}, + //Phaser3 + {64,64,31,0,0,66,68,107,2,0,0,20}, + //Phaser4 + {39,64,22,0,0,66,67,10,5,0,1,20}, + //Phaser5 + {64,64,20,0,1,110,67,78,10,0,0,20}, + //Phaser6 + {64,64,53,100,0,58,37,78,3,0,0,20}}; if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1; for (int n=0;n1) Poutsub=1; + case 0: setvolume(value); + break; + case 1: setpanning(value); + break; + case 2: lfo.Pfreq=value; + lfo.updateparams(); + break; + case 3: lfo.Prandomness=value; + lfo.updateparams(); + break; + case 4: lfo.PLFOtype=value; + lfo.updateparams(); + break; + case 5: lfo.Pstereo=value; + lfo.updateparams(); + break; + case 6: setdepth(value); + break; + case 7: setfb(value); + break; + case 8: setstages(value); + break; + case 9: setlrcross(value); + break; + case 10:if (value>1) Poutsub=1; else Poutsub=value; - break; - case 11:setphase(value); - break; + break; + case 11:setphase(value); + break; }; }; unsigned char Phaser::getpar(const int &npar)const{ switch (npar){ - case 0: return(Pvolume); - break; - case 1: return(Ppanning); - break; - case 2: return(lfo.Pfreq); - break; - case 3: return(lfo.Prandomness); - break; - case 4: return(lfo.PLFOtype); - break; - case 5: return(lfo.Pstereo); - break; - case 6: return(Pdepth); - break; - case 7: return(Pfb); - break; - case 8: return(Pstages); - break; - case 9: return(Plrcross); - break; - case 10:return(Poutsub); - break; - case 11:return(Pphase); - break; - default:return (0); + case 0: return(Pvolume); + break; + case 1: return(Ppanning); + break; + case 2: return(lfo.Pfreq); + break; + case 3: return(lfo.Prandomness); + break; + case 4: return(lfo.PLFOtype); + break; + case 5: return(lfo.Pstereo); + break; + case 6: return(Pdepth); + break; + case 7: return(Pfb); + break; + case 8: return(Pstages); + break; + case 9: return(Plrcross); + break; + case 10:return(Poutsub); + break; + case 11:return(Pphase); + break; + default:return (0); }; }; diff --git a/plugins/zynaddsubfx/src/Effects/Phaser.h b/plugins/zynaddsubfx/src/Effects/Phaser.h index 190f1491c..d74390f89 100644 --- a/plugins/zynaddsubfx/src/Effects/Phaser.h +++ b/plugins/zynaddsubfx/src/Effects/Phaser.h @@ -27,43 +27,44 @@ #include "EffectLFO.h" #define MAX_PHASER_STAGES 12 +/**Phaser Effect*/ class Phaser:public Effect { public: - Phaser(const int &insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_); - ~Phaser(); - void out(REALTYPE *smpsl,REALTYPE *smpsr); + Phaser(const int &insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_); + ~Phaser(); + void out(REALTYPE *smpsl,REALTYPE *smpsr); void setpreset(unsigned char npreset); - void changepar(const int &npar,const unsigned char &value); - unsigned char getpar(const int &npar)const; - void cleanup(); - void setdryonly(); - + void changepar(const int &npar,const unsigned char &value); + unsigned char getpar(const int &npar)const; + void cleanup(); + void setdryonly(); + private: - //Parametrii Phaser - EffectLFO lfo;/** - -#include -#include +#include #include "Reverb.h" /**\todo: EarlyReflections,Prdelay,Perbalance */ @@ -48,17 +45,17 @@ Reverb::Reverb(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_) Proomsize=64;roomsize=1.0;rs=1.0; for (int i=0;i=comblength) ck=0; - }; + if ((++ck)>=comblength) ck=0; + }; - combk[j]=ck; - lpcomb[j]=lpcombj; + combk[j]=ck; + lpcomb[j]=lpcombj; }; for (j=REV_APS*ch;j=aplength) ak=0; - }; - apk[j]=ak; + int ak=apk[j]; + int aplength=aplen[j]; + for (i=0;i=aplength) ak=0; + }; + apk[j]=ak; }; }; @@ -151,14 +148,14 @@ void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r){ if ((Pvolume==0)&&(insertion!=0)) return; for (i=0;i=idelaylen) idelayk=0; - }; + inputbuf[i]=(smps_l[i]+smps_r[i])/2.0; + //Initial delay r + if (idelay!=NULL){ + REALTYPE tmp=inputbuf[i]+idelay[idelayk]*idelayfb; + inputbuf[i]=idelay[idelayk]; + idelay[idelayk]=tmp; + idelayk++;if (idelayk>=idelaylen) idelayk=0; + }; }; if (lpf!=NULL) lpf->filterout(inputbuf); @@ -170,11 +167,11 @@ void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r){ REALTYPE lvol=rs/REV_COMBS*pan; REALTYPE rvol=rs/REV_COMBS*(1.0-pan); if (insertion!=0){ - lvol*=2;rvol*=2; + lvol*=2;rvol*=2; }; for (int i=0;iPvolume=Pvolume; if (insertion==0) { - outvolume=pow(0.01,(1.0-Pvolume/127.0))*4.0; - volume=1.0; + outvolume=pow(0.01,(1.0-Pvolume/127.0))*4.0; + volume=1.0; } else { - volume=outvolume=Pvolume/127.0; - if (Pvolume==0) cleanup(); + volume=outvolume=Pvolume/127.0; + if (Pvolume==0) cleanup(); }; }; @@ -205,8 +202,8 @@ void Reverb::settime(const unsigned char &Ptime){ t=pow(60.0,(REALTYPE)Ptime/127.0)-0.97; for (i=0;iPlohidamp=Plohidamp; if (Plohidamp==64) { - lohidamptype=0; - lohifb=0.0; - } else { - if (Plohidamp<64) lohidamptype=1; - if (Plohidamp>64) lohidamptype=2; - x=fabs((REALTYPE)(Plohidamp-64)/64.1); - lohifb=x*x; - }; + lohidamptype=0; + lohifb=0.0; + } else { + if (Plohidamp<64) lohidamptype=1; + if (Plohidamp>64) lohidamptype=2; + x=fabs((REALTYPE)(Plohidamp-64)/64.1); + lohifb=x*x; + }; }; void Reverb::setidelay(const unsigned char &Pidelay){ @@ -237,8 +234,8 @@ void Reverb::setidelay(const unsigned char &Pidelay){ idelaylen=(int) (SAMPLE_RATE*delay/1000); if (idelaylen>1) { - idelayk=0; - idelay=new REALTYPE[idelaylen]; + idelayk=0; + idelay=new REALTYPE[idelaylen]; for (int i=0;iPhpf=Phpf; if (Phpf==0) {//No HighPass - if (hpf!=NULL) delete(hpf); - hpf=NULL; - } + if (hpf!=NULL) delete hpf; + hpf=NULL; + } else{ REALTYPE fr=exp(pow(Phpf/127.0,0.5)*log(10000.0))+20.0; - if (hpf==NULL) hpf=new AnalogFilter(3,fr,1,0); - else hpf->setfreq(fr); - }; + if (hpf==NULL) hpf=new AnalogFilter(3,fr,1,0); + else hpf->setfreq(fr); + }; }; void Reverb::setlpf(const unsigned char &Plpf){ this->Plpf=Plpf; if (Plpf==127) {//No LowPass - if (lpf!=NULL) delete(lpf); - lpf=NULL; - } + if (lpf!=NULL) delete lpf; + lpf=NULL; + } else{ REALTYPE fr=exp(pow(Plpf/127.0,0.5)*log(25000.0))+40; - if (lpf==NULL) lpf=new AnalogFilter(2,fr,1,0); - else lpf->setfreq(fr); - }; + if (lpf==NULL) lpf=new AnalogFilter(2,fr,1,0); + else lpf->setfreq(fr); + }; }; void Reverb::settype(unsigned char Ptype){ const int NUM_TYPES=2; int combtunings[NUM_TYPES][REV_COMBS]={ - //this is unused (for random) - {0,0,0,0,0,0,0,0}, - //Freeverb by Jezar at Dreampoint - {1116,1188,1277,1356,1422,1491,1557,1617} + //this is unused (for random) + {0,0,0,0,0,0,0,0}, + //Freeverb by Jezar at Dreampoint + {1116,1188,1277,1356,1422,1491,1557,1617} }; int aptunings[NUM_TYPES][REV_APS]={ - //this is unused (for random) - {0,0,0,0}, - //Freeverb by Jezar at Dreampoint - {225,341,441,556} + //this is unused (for random) + {0,0,0,0}, + //Freeverb by Jezar at Dreampoint + {225,341,441,556} }; if (Ptype>=NUM_TYPES) Ptype=NUM_TYPES-1; @@ -294,31 +291,31 @@ void Reverb::settype(unsigned char Ptype){ REALTYPE tmp; for (int i=0;iREV_COMBS) tmp+=23.0; - tmp*=SAMPLE_RATE/44100.0;//adjust the combs according to the samplerate - if (tmp<10) tmp=10; - - comblen[i]=(int) tmp; - combk[i]=0; - lpcomb[i]=0; - if (comb[i]!=NULL) delete []comb[i]; - comb[i]=new REALTYPE[comblen[i]]; - }; + if (Ptype==0) tmp=800.0+(int)(RND*1400.0); + else tmp=combtunings[Ptype][i%REV_COMBS]; + tmp*=roomsize; + if (i>REV_COMBS) tmp+=23.0; + tmp*=SAMPLE_RATE/44100.0;//adjust the combs according to the samplerate + if (tmp<10) tmp=10; + + comblen[i]=(int) tmp; + combk[i]=0; + lpcomb[i]=0; + if (comb[i]!=NULL) delete []comb[i]; + comb[i]=new REALTYPE[comblen[i]]; + }; for (int i=0;iREV_APS) tmp+=23.0; - tmp*=SAMPLE_RATE/44100.0;//adjust the combs according to the samplerate - if (tmp<10) tmp=10; - aplen[i]=(int) tmp; - apk[i]=0; - if (ap[i]!=NULL) delete []ap[i]; - ap[i]=new REALTYPE[aplen[i]]; + if (Ptype==0) tmp=500+(int)(RND*500); + else tmp=aptunings[Ptype][i%REV_APS]; + tmp*=roomsize; + if (i>REV_APS) tmp+=23.0; + tmp*=SAMPLE_RATE/44100.0;//adjust the combs according to the samplerate + if (tmp<10) tmp=10; + aplen[i]=(int) tmp; + apk[i]=0; + if (ap[i]!=NULL) delete []ap[i]; + ap[i]=new REALTYPE[aplen[i]]; }; settime(Ptime); cleanup(); @@ -338,32 +335,32 @@ void Reverb::setpreset(unsigned char npreset){ const int PRESET_SIZE=12; const int NUM_PRESETS=13; unsigned char presets[NUM_PRESETS][PRESET_SIZE]={ - //Cathedral1 - {80,64,63,24,0,0,0,85,5,83,1,64}, - //Cathedral2 - {80,64,69,35,0,0,0,127,0,71,0,64}, - //Cathedral3 - {80,64,69,24,0,0,0,127,75,78,1,85}, - //Hall1 - {90,64,51,10,0,0,0,127,21,78,1,64}, - //Hall2 - {90,64,53,20,0,0,0,127,75,71,1,64}, - //Room1 - {100,64,33,0,0,0,0,127,0,106,0,30}, - //Room2 - {100,64,21,26,0,0,0,62,0,77,1,45}, - //Basement - {110,64,14,0,0,0,0,127,5,71,0,25}, - //Tunnel - {85,80,84,20,42,0,0,51,0,78,1,105}, - //Echoed1 - {95,64,26,60,71,0,0,114,0,64,1,64}, - //Echoed2 - {90,64,40,88,71,0,0,114,0,88,1,64}, - //VeryLong1 - {90,64,93,15,0,0,0,114,0,77,0,95}, - //VeryLong2 - {90,64,111,30,0,0,0,114,90,74,1,80}}; + //Cathedral1 + {80,64,63,24,0,0,0,85,5,83,1,64}, + //Cathedral2 + {80,64,69,35,0,0,0,127,0,71,0,64}, + //Cathedral3 + {80,64,69,24,0,0,0,127,75,78,1,85}, + //Hall1 + {90,64,51,10,0,0,0,127,21,78,1,64}, + //Hall2 + {90,64,53,20,0,0,0,127,75,71,1,64}, + //Room1 + {100,64,33,0,0,0,0,127,0,106,0,30}, + //Room2 + {100,64,21,26,0,0,0,62,0,77,1,45}, + //Basement + {110,64,14,0,0,0,0,127,5,71,0,25}, + //Tunnel + {85,80,84,20,42,0,0,51,0,78,1,105}, + //Echoed1 + {95,64,26,60,71,0,0,114,0,64,1,64}, + //Echoed2 + {90,64,40,88,71,0,0,114,0,88,1,64}, + //VeryLong1 + {90,64,93,15,0,0,0,114,0,77,0,95}, + //VeryLong2 + {90,64,111,30,0,0,0,114,90,74,1,80}}; if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1; for (int n=0;n1.0) x=1.0; -return(20.0*pow(1000.0,x)); +return(20.0*pow((REALTYPE)1000.0,x)); } REALTYPE EQGraph::getfreqpos(REALTYPE freq) { diff --git a/plugins/zynaddsubfx/src/UI/EffUI.fl b/plugins/zynaddsubfx/src/UI/EffUI.fl index 2a708b72d..e2712f107 100644 --- a/plugins/zynaddsubfx/src/UI/EffUI.fl +++ b/plugins/zynaddsubfx/src/UI/EffUI.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0109 +version 1.0107 header_name {.h} code_name {.cc} decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {} @@ -36,7 +36,7 @@ decl {\#include "../Effects/EffectMgr.h"} {public decl {\#include "PresetsUI.h"} {public } -class EQGraph {: {public Fl_Box} +class EQGraph {selected : {public Fl_Box} } { Function {EQGraph(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} { code {eff=NULL; @@ -141,7 +141,7 @@ return(idbresp);} {} Function {getfreqx(REALTYPE x)} {return_type REALTYPE } { code {if (x>1.0) x=1.0; -return(20.0*pow(1000.0,x));} {} +return(20.0*pow((REALTYPE)1000.0,x));} {} } Function {getfreqpos(REALTYPE freq)} {return_type REALTYPE } { @@ -336,7 +336,7 @@ refresh(eff);} callback {int x=64; if (Fl::event_button1()) x=(int)o->value(); else o->value(x); -eff->seteffectpar(11,x);} selected +eff->seteffectpar(11,x);} tooltip RoomSize xywh {190 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 8 align 8 minimum 1 maximum 127 step 1 class WidgetPDial }