ZynAddSubFX: follow recent changes in CVS repository

Follow recent changes in ZynAddSubFX CVS repository - ChangeLog says:

29 Mar 2009 (Mark McCurry)
            - Started to use Doxygen within the Effects
            - Started to use const within Effects
            - Changing tabs->four spaces in hopes of generating a bit more
              consitancy
            - Began to use Initialization Lists
            - Almost all changes contained in Effects until further
              discussion on the style, so consistancy can be reached
This commit is contained in:
Tobias Doerffel
2009-03-31 10:17:35 +02:00
parent ca5588f747
commit f7fa720d0b
21 changed files with 508 additions and 456 deletions

View File

@@ -840,7 +840,7 @@
hovers over them
- Created tooltips for the effects knobs
- Standardized the code, so it could compile with pedantic without
errors
errors [it looks like some errors may have ben missed]
22 Feb 2009 (Mark McCurry)
- Fix improper deallocation in PresetsStore
@@ -851,3 +851,13 @@
- Added start of DocBook documentation
- Incorperated JACK output patch by Emmanuel Saracco
- Incorperated QUERTZ layout by Achim Settelmeier
29 Mar 2009 (Mark McCurry)
- Started to use Doxygen within the Effects
- Started to use const within Effects
- Changing tabs->four spaces in hopes of generating a bit more
consitancy
- Began to use Initialization Lists
- Almost all changes contained in Effects until further
discussion on the style, so consistancy can be reached

View File

@@ -24,16 +24,9 @@
#include "Alienwah.h"
#include <stdio.h>
Alienwah::Alienwah(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
oldl=NULL;
oldr=NULL;
filterpars=NULL;
insertion=insertion_;
Ppreset=0;
Alienwah::Alienwah(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
:Effect(insertion_,efxoutl_,efxoutr_,NULL,0),oldl(NULL),oldr(NULL)
{
setpreset(Ppreset);
cleanup();
oldclfol.a=fb;oldclfol.b=0.0;
@@ -114,12 +107,12 @@ void Alienwah::cleanup(){
* Parameter control
*/
void Alienwah::setdepth(unsigned char Pdepth){
void Alienwah::setdepth(const unsigned char &Pdepth){
this->Pdepth=Pdepth;
depth=(Pdepth/127.0);
};
void Alienwah::setfb(unsigned char Pfb){
void Alienwah::setfb(const unsigned char &Pfb){
this->Pfb=Pfb;
fb=fabs((Pfb-64.0)/64.1);
fb=sqrt(fb);
@@ -127,33 +120,33 @@ void Alienwah::setfb(unsigned char Pfb){
if (Pfb<64) fb=-fb;
};
void Alienwah::setvolume(unsigned char Pvolume){
void Alienwah::setvolume(const unsigned char &Pvolume){
this->Pvolume=Pvolume;
outvolume=Pvolume/127.0;
if (insertion==0) volume=1.0;
else volume=outvolume;
};
void Alienwah::setpanning(unsigned char Ppanning){
void Alienwah::setpanning(const unsigned char &Ppanning){
this->Ppanning=Ppanning;
panning=Ppanning/127.0;
};
void Alienwah::setlrcross(unsigned char Plrcross){
void Alienwah::setlrcross(const unsigned char &Plrcross){
this->Plrcross=Plrcross;
lrcross=Plrcross/127.0;
};
void Alienwah::setphase(unsigned char Pphase){
void Alienwah::setphase(const unsigned char &Pphase){
this->Pphase=Pphase;
phase=(Pphase-64.0)/64.0*PI;
};
void Alienwah::setdelay(unsigned char Pdelay){
void Alienwah::setdelay(const unsigned char &Pdelay){
if (oldl!=NULL) delete [] oldl;
if (oldr!=NULL) delete [] oldr;
if (Pdelay>=MAX_ALIENWAH_DELAY) Pdelay=MAX_ALIENWAH_DELAY;
this->Pdelay=Pdelay;
if (Pdelay>=MAX_ALIENWAH_DELAY) this->Pdelay=MAX_ALIENWAH_DELAY;
else this->Pdelay=Pdelay;
oldl=new COMPLEXTYPE[Pdelay];
oldr=new COMPLEXTYPE[Pdelay];
cleanup();
@@ -179,7 +172,7 @@ void Alienwah::setpreset(unsigned char npreset){
};
void Alienwah::changepar(int npar,unsigned char value){
void Alienwah::changepar(const int &npar,const unsigned char &value){
switch(npar){
case 0: setvolume(value);
break;
@@ -210,7 +203,7 @@ void Alienwah::changepar(int npar,unsigned char value){
};
};
unsigned char Alienwah::getpar(int npar){
unsigned char Alienwah::getpar(const int &npar)const{
switch (npar){
case 0: return(Pvolume);
break;

View File

@@ -33,44 +33,52 @@ struct COMPLEXTYPE {
REALTYPE a,b;
};
/**"AlienWah" Effect*/
class Alienwah:public Effect {
public:
Alienwah(int insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
~Alienwah();
void out(REALTYPE *smpsl,REALTYPE *smpsr);
/**
* Constructor
* @param insetion_ 1 for insertion Effect, 0 for others
* @param efxoutl_ Pointer to Alienwah's left channel output buffer
* @param efxoutr_ Pointer to Alienwah's left channel output buffer
* @return Initialized Alienwah
*/
Alienwah(int insetion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_);
~Alienwah();
void out(REALTYPE *const smpsl,REALTYPE *const smpsr);
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
void cleanup();
void changepar(const int &npar,const unsigned char &value);
unsigned char getpar(const int &npar)const;
void cleanup();
private:
//Parametrii Alienwah
EffectLFO lfo;//lfo-ul Alienwah
unsigned char Pvolume;
unsigned char Ppanning;
unsigned char Pdepth;//the depth of the Alienwah
unsigned char Pfb;//feedback
unsigned char Plrcross;//feedback
unsigned char Pdelay;
unsigned char Pphase;
//Alienwah Parameters
EffectLFO lfo;//lfo-ul Alienwah
unsigned char Pvolume;
unsigned char Ppanning;
unsigned char Pdepth;//the depth of the Alienwah
unsigned char Pfb;//feedback
unsigned char Plrcross;//feedback
unsigned char Pdelay;
unsigned char Pphase;
//Control Parametrii
void setvolume(unsigned char Pvolume);
void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setfb(unsigned char Pfb);
void setlrcross(unsigned char Plrcross);
void setdelay(unsigned char Pdelay);
void setphase(unsigned char Pphase);
//Valorile interne
int insertion;
REALTYPE panning,fb,depth,lrcross,phase;
COMPLEXTYPE *oldl,*oldr;
COMPLEXTYPE oldclfol,oldclfor;
int oldk;
//Control Parameters
void setvolume(const unsigned char &Pvolume);
void setpanning(const unsigned char &Ppanning);
void setdepth(const unsigned char &Pdepth);
void setfb(const unsigned char &Pfb);
void setlrcross(const unsigned char &Plrcross);
void setdelay(const unsigned char &Pdelay);
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;
int oldk;
};
#endif

View File

@@ -24,17 +24,14 @@
#include "Chorus.h"
#include <stdio.h>
Chorus::Chorus(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
Chorus::Chorus(const int &insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_)
:Effect(insertion_,efxoutl_,efxoutr_,NULL,0)
{
dlk=0;drk=0;
maxdelay=(int)(MAX_CHORUS_DELAY/1000.0*SAMPLE_RATE);
delayl=new REALTYPE[maxdelay];
delayr=new REALTYPE[maxdelay];
insertion=insertion_;
filterpars=NULL;
Ppreset=0;
setpreset(Ppreset);
lfo.effectlfoout(&lfol,&lfor);
@@ -144,33 +141,33 @@ void Chorus::cleanup(){
/*
* Parameter control
*/
void Chorus::setdepth(unsigned char Pdepth){
void Chorus::setdepth(const unsigned char &Pdepth){
this->Pdepth=Pdepth;
depth=(pow(8.0,(Pdepth/127.0)*2.0)-1.0)/1000.0;//seconds
};
void Chorus::setdelay(unsigned char Pdelay){
void Chorus::setdelay(const unsigned char &Pdelay){
this->Pdelay=Pdelay;
delay=(pow(10.0,(Pdelay/127.0)*2.0)-1.0)/1000.0;//seconds
};
void Chorus::setfb(unsigned char Pfb){
void Chorus::setfb(const unsigned char &Pfb){
this->Pfb=Pfb;
fb=(Pfb-64.0)/64.1;
};
void Chorus::setvolume(unsigned char Pvolume){
void Chorus::setvolume(const unsigned char &Pvolume){
this->Pvolume=Pvolume;
outvolume=Pvolume/127.0;
if (insertion==0) volume=1.0;
else volume=outvolume;
};
void Chorus::setpanning(unsigned char Ppanning){
void Chorus::setpanning(const unsigned char &Ppanning){
this->Ppanning=Ppanning;
panning=Ppanning/127.0;
};
void Chorus::setlrcross(unsigned char Plrcross){
void Chorus::setlrcross(const unsigned char &Plrcross){
this->Plrcross=Plrcross;
lrcross=Plrcross/127.0;
};
@@ -206,7 +203,7 @@ void Chorus::setpreset(unsigned char npreset){
};
void Chorus::changepar(int npar,unsigned char value){
void Chorus::changepar(const int &npar,const unsigned char &value){
switch(npar){
case 0: setvolume(value);
break;
@@ -232,16 +229,16 @@ void Chorus::changepar(int npar,unsigned char value){
break;
case 9: setlrcross(value);
break;
case 10:if (value>1) value=1;
Pflangemode=value;
case 10:if (value>1) Pflangemode=1;
else Pflangemode=value;
break;
case 11:if (value>1) value=1;
Poutsub=value;
case 11:if (value>1) Poutsub=1;
else Poutsub=value;
break;
};
};
unsigned char Chorus::getpar(int npar){
unsigned char Chorus::getpar(const int &npar)const{
switch (npar){
case 0: return(Pvolume);
break;
@@ -272,6 +269,3 @@ unsigned char Chorus::getpar(int npar){
};

View File

@@ -30,16 +30,16 @@
class Chorus:public Effect {
public:
Chorus(int insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
Chorus(const int &insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
~Chorus();
void out(REALTYPE *smpsl,REALTYPE *smpsr);
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
void changepar(const int &npar,const unsigned char &value);
unsigned char getpar(const int &npar)const;
void cleanup();
private:
//Parametrii Chorus
//Chorus Parameters
EffectLFO lfo;//lfo-ul chorus
unsigned char Pvolume;
unsigned char Ppanning;
@@ -52,17 +52,17 @@ class Chorus:public Effect {
//Control Parametrii
void setvolume(unsigned char Pvolume);
void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setdelay(unsigned char Pdelay);
void setfb(unsigned char Pfb);
void setlrcross(unsigned char Plrcross);
void setvolume(const unsigned char &Pvolume);
void setpanning(const unsigned char &Ppanning);
void setdepth(const unsigned char &Pdepth);
void setdelay(const unsigned char &Pdelay);
void setfb(const unsigned char &Pfb);
void setlrcross(const unsigned char &Plrcross);
//Valorile interne
//Internal Values
REALTYPE depth,delay,fb,lrcross,panning;
REALTYPE dl1,dl2,dr1,dr2,lfol,lfor;
int insertion,maxdelay;
int maxdelay;
REALTYPE *delayl,*delayr;
int dlk,drk,dlhi,dlhi2;
REALTYPE getdelay(REALTYPE xlfo);

View File

@@ -143,20 +143,17 @@ void waveshapesmps(int n,REALTYPE *smps,unsigned char type,unsigned char drive){
};
Distorsion::Distorsion(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
Distorsion::Distorsion(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
:Effect(insertion_,efxoutl_,efxoutr_,NULL,0)
{
lpfl=new AnalogFilter(2,22000,1,0);
lpfr=new AnalogFilter(2,22000,1,0);
hpfl=new AnalogFilter(3,20,1,0);
hpfr=new AnalogFilter(3,20,1,0);
filterpars=NULL;
insertion=insertion_;
//default values
Ppreset=0;
Pvolume=50;
Plrcross=40;
Pdrive=90;
@@ -173,10 +170,10 @@ Distorsion::Distorsion(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
};
Distorsion::~Distorsion(){
delete (lpfl);
delete (lpfr);
delete (hpfl);
delete (hpfr);
delete lpfl;
delete lpfr;
delete hpfl;
delete hpfr;
};
@@ -256,7 +253,7 @@ void Distorsion::out(REALTYPE *smpsl,REALTYPE *smpsr){
/*
* Parameter control
*/
void Distorsion::setvolume(unsigned char Pvolume){
void Distorsion::setvolume(const unsigned char &Pvolume){
this->Pvolume=Pvolume;
if (insertion==0) {
@@ -269,25 +266,25 @@ void Distorsion::setvolume(unsigned char Pvolume){
};
void Distorsion::setpanning(unsigned char Ppanning){
void Distorsion::setpanning(const unsigned char &Ppanning){
this->Ppanning=Ppanning;
panning=(Ppanning+0.5)/127.0;
};
void Distorsion::setlrcross(unsigned char Plrcross){
void Distorsion::setlrcross(const unsigned char &Plrcross){
this->Plrcross=Plrcross;
lrcross=Plrcross/127.0*1.0;
};
void Distorsion::setlpf(unsigned char Plpf){
void Distorsion::setlpf(const unsigned char &Plpf){
this->Plpf=Plpf;
REALTYPE fr=exp(pow(Plpf/127.0,0.5)*log(25000.0))+40;
lpfl->setfreq(fr);
lpfr->setfreq(fr);
};
void Distorsion::sethpf(unsigned char Phpf){
void Distorsion::sethpf(const unsigned char &Phpf){
this->Phpf=Phpf;
REALTYPE fr=exp(pow(Phpf/127.0,0.5)*log(25000.0))+20.0;
hpfl->setfreq(fr);
@@ -321,7 +318,7 @@ void Distorsion::setpreset(unsigned char npreset){
};
void Distorsion::changepar(int npar,unsigned char value){
void Distorsion::changepar(const int &npar,const unsigned char &value){
switch (npar){
case 0: setvolume(value);
break;
@@ -333,25 +330,25 @@ void Distorsion::changepar(int npar,unsigned char value){
break;
case 4: Plevel=value;
break;
case 5: if (value>13) value=13;//this must be increased if more distorsion types are added
Ptype=value;
case 5: if (value>13) Ptype=13;//this must be increased if more distorsion types are added
else Ptype=value;
break;
case 6: if (value>1) value=1;
Pnegate=value;
case 6: if (value>1) Pnegate=1;
else Pnegate=value;
break;
case 7: setlpf(value);
break;
case 8: sethpf(value);
break;
case 9: if (value>1) value=1;
Pstereo=value;
case 9: if (value>1) Pstereo=1;
else Pstereo=value;
break;
case 10:Pprefiltering=value;
break;
};
};
unsigned char Distorsion::getpar(int npar){
unsigned char Distorsion::getpar(const int &npar)const{
switch (npar){
case 0: return(Pvolume);
break;
@@ -379,6 +376,3 @@ unsigned char Distorsion::getpar(int npar){
return(0);//in case of bogus parameter number
};

View File

@@ -32,12 +32,12 @@ void waveshapesmps(int n,REALTYPE *smps,unsigned char type,unsigned char drive);
class Distorsion:public Effect{
public:
Distorsion(int insertion,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
Distorsion(const int &insertion,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
~Distorsion();
void out(REALTYPE *smpsl,REALTYPE *smpr);
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
void changepar(const int &npar,const unsigned char &value);
unsigned char getpar(const int &npar)const;
void cleanup();
void applyfilters(REALTYPE *efxoutl,REALTYPE *efxoutr);
@@ -55,13 +55,13 @@ class Distorsion:public Effect{
unsigned char Pstereo; //0=mono,1=stereo
unsigned char Pprefiltering;//if you want to do the filtering before the distorsion
void setvolume(unsigned char Pvolume);
void setpanning(unsigned char Ppanning);
void setlrcross(unsigned char Plrcross);
void setlpf(unsigned char Plpf);
void sethpf(unsigned char Phpf);
void setvolume(const unsigned char &Pvolume);
void setpanning(const unsigned char &Ppanning);
void setlrcross(const unsigned char &Plrcross);
void setlpf(const unsigned char &Plpf);
void sethpf(const unsigned char &Phpf);
//Parametrii reali
//Real Parameters
REALTYPE panning,lrcross;
AnalogFilter *lpfl,*lpfr,*hpfl,*hpfr;
@@ -70,4 +70,3 @@ class Distorsion:public Effect{
#endif

View File

@@ -24,24 +24,19 @@
#include "DynamicFilter.h"
#include <stdio.h>
DynamicFilter::DynamicFilter(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
insertion=insertion_;
Ppreset=0;
filterl=NULL;
filterr=NULL;
filterpars=new FilterParams(0,64,64);
DynamicFilter::DynamicFilter(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
:Effect(insertion_,efxoutl_,efxoutr_,new FilterParams(0,64,64),0),
filterl(NULL),filterr(NULL)
{
setpreset(Ppreset);
cleanup();
/**\todo fix intialization issues here*/
};
DynamicFilter::~DynamicFilter(){
delete(filterpars);
delete(filterl);
delete(filterr);
delete filterpars;
delete filterl;
delete filterr;
};
@@ -110,26 +105,26 @@ void DynamicFilter::cleanup(){
* Parameter control
*/
void DynamicFilter::setdepth(unsigned char Pdepth){
void DynamicFilter::setdepth(const unsigned char &Pdepth){
this->Pdepth=Pdepth;
depth=pow((Pdepth/127.0),2.0);
};
void DynamicFilter::setvolume(unsigned char Pvolume){
void DynamicFilter::setvolume(const unsigned char &Pvolume){
this->Pvolume=Pvolume;
outvolume=Pvolume/127.0;
if (insertion==0) volume=1.0;
else volume=outvolume;
};
void DynamicFilter::setpanning(unsigned char Ppanning){
void DynamicFilter::setpanning(const unsigned char &Ppanning){
this->Ppanning=Ppanning;
panning=Ppanning/127.0;
};
void DynamicFilter::setampsns(unsigned char Pampsns){
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;
@@ -255,7 +250,7 @@ void DynamicFilter::setpreset(unsigned char npreset){
};
void DynamicFilter::changepar(int npar,unsigned char value){
void DynamicFilter::changepar(const int &npar,const unsigned char &value){
switch(npar){
case 0: setvolume(value);
break;
@@ -286,7 +281,7 @@ void DynamicFilter::changepar(int npar,unsigned char value){
};
};
unsigned char DynamicFilter::getpar(int npar){
unsigned char DynamicFilter::getpar(const int &npar)const{
switch (npar){
case 0: return(Pvolume);
break;
@@ -313,6 +308,3 @@ unsigned char DynamicFilter::getpar(int npar){
};

View File

@@ -35,8 +35,8 @@ class DynamicFilter:public Effect {
void out(REALTYPE *smpsl,REALTYPE *smpsr);
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
void changepar(const int &npar,const unsigned char &value);
unsigned char getpar(const int &npar)const;
void cleanup();
// void setdryonly();
@@ -46,21 +46,20 @@ class DynamicFilter:public Effect {
EffectLFO lfo;//lfo-ul DynamicFilter
unsigned char Pvolume;
unsigned char Ppanning;
unsigned char Pdepth;//the depth of the lfo of the DynamicFilter
unsigned char Pampsns;//how the filter varies according to the input amplitude
unsigned char Pdepth;/**<the depth of the lfo of the DynamicFilter*/
unsigned char Pampsns;/**<how the filter varies according to the input amplitude*/
unsigned char Pampsnsinv;//if the filter freq is lowered if the input amplitude rises
unsigned char Pampsmooth;//how smooth the input amplitude changes the filter
//Control Parametrii
void setvolume(unsigned char Pvolume);
void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setampsns(unsigned char Pampsns);
//Parameter Control
void setvolume(const unsigned char &Pvolume);
void setpanning(const unsigned char &Ppanning);
void setdepth(const unsigned char &Pdepth);
void setampsns(const unsigned char &Pampsns);
void reinitfilter();
//Valorile interne
int insertion;
//Internal Values
REALTYPE panning,depth,ampsns,ampsmooth;
Filter *filterl,*filterr;

View File

@@ -25,11 +25,9 @@
#include <math.h>
#include "EQ.h"
EQ::EQ(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
insertion=insertion_;
filterpars=NULL;
EQ::EQ(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
:Effect(insertion_,efxoutl_,efxoutr_,NULL,0)
{
for (int i=0;i<MAX_EQ_BANDS;i++){
filter[i].Ptype=0;
@@ -41,7 +39,6 @@ EQ::EQ(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
filter[i].r=new AnalogFilter(6,1000.0,1.0,0);
};
//default values
Ppreset=0;
Pvolume=50;
setpreset(Ppreset);
@@ -84,7 +81,7 @@ void EQ::out(REALTYPE *smpsl,REALTYPE *smpsr){
/*
* Parameter control
*/
void EQ::setvolume(unsigned char Pvolume){
void EQ::setvolume(const unsigned char &Pvolume){
this->Pvolume=Pvolume;
outvolume=pow(0.005,(1.0-Pvolume/127.0))*10.0;
@@ -112,7 +109,7 @@ void EQ::setpreset(unsigned char npreset){
};
void EQ::changepar(int npar,unsigned char value){
void EQ::changepar(const int &npar,const unsigned char &value){
switch (npar){
case 0: setvolume(value);
break;
@@ -125,9 +122,9 @@ void EQ::changepar(int npar,unsigned char value){
REALTYPE tmp;
switch(bp){
case 0: if (value>9) value=0;//has to be changed if more filters will be added
filter[nb].Ptype=value;
if (value!=0){
case 0: filter[nb].Ptype=value;
if (value>9) filter[nb].Ptype=0;//has to be changed if more filters will be added
if (filter[nb].Ptype!=0){
filter[nb].l->settype(value-1);
filter[nb].r->settype(value-1);
};
@@ -147,15 +144,15 @@ void EQ::changepar(int npar,unsigned char value){
filter[nb].l->setq(tmp);
filter[nb].r->setq(tmp);
break;
case 4: if (value>=MAX_FILTER_STAGES) value=MAX_FILTER_STAGES-1;
filter[nb].Pstages=value;
case 4: filter[nb].Pstages=value;
if (value>=MAX_FILTER_STAGES) filter[nb].Pstages=MAX_FILTER_STAGES-1;
filter[nb].l->setstages(value);
filter[nb].r->setstages(value);
break;
};
};
unsigned char EQ::getpar(int npar){
unsigned char EQ::getpar(const int &npar)const{
switch (npar){
case 0: return(Pvolume);
break;

View File

@@ -27,21 +27,22 @@
#include "../DSP/AnalogFilter.h"
#include "Effect.h"
/**EQ Effect*/
class EQ:public Effect{
public:
EQ(int insertion,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
EQ(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
~EQ();
void out(REALTYPE *smpsl,REALTYPE *smpr);
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
void changepar(const int &npar,const unsigned char &value);
unsigned char getpar(const int &npar)const;
void cleanup();
REALTYPE getfreqresponse(REALTYPE freq);
private:
//Parametrii
unsigned char Pvolume;//Volumul
//Parameters
unsigned char Pvolume;/**<Volume*/
void setvolume(unsigned char Pvolume);
void setvolume(const unsigned char &Pvolume);
struct {
//parameters

View File

@@ -20,39 +20,23 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include "Echo.h"
Echo::Echo(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
filterpars=NULL;
insertion=insertion_;
//default values
Ppreset=0;
Pvolume=50;
Ppanning=64;
Pdelay=60;
Plrdelay=100;
Plrcross=100;
Pfb=40;
Phidamp=60;
ldelay=NULL;
rdelay=NULL;
lrdelay=0;
Echo::Echo(const int & insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_)
: Effect(insertion_,efxoutl_,efxoutr_,NULL,0),
Pvolume(50),Ppanning(64),Pdelay(60),
Plrdelay(100),Plrcross(100),Pfb(40),Phidamp(60),
lrdelay(0),ldelay(NULL),rdelay(NULL)
{
setpreset(Ppreset);
cleanup();
};
}
Echo::~Echo(){
delete[] ldelay;
delete[] rdelay;
};
}
/*
* Cleanup the effect
@@ -63,7 +47,7 @@ void Echo::cleanup(){
for (i=0;i<dr;i++) rdelay[i]=0.0;
oldl=0.0;
oldr=0.0;
};
}
/*
@@ -80,161 +64,160 @@ void Echo::initdelays(){
rdelay=new REALTYPE[dr];
cleanup();
};
}
/*
* Effect output
*/
void Echo::out(REALTYPE *smpsl,REALTYPE *smpsr){
void Echo::out(REALTYPE *const smpsl,REALTYPE *const smpsr){
int i;
REALTYPE l,r,ldl,rdl;
for (i=0;i<SOUND_BUFFER_SIZE;i++){
ldl=ldelay[kl];
rdl=rdelay[kr];
l=ldl*(1.0-lrcross)+rdl*lrcross;
r=rdl*(1.0-lrcross)+ldl*lrcross;
ldl=l;rdl=r;
efxoutl[i]=ldl*2.0;
efxoutr[i]=rdl*2.0;
ldl=smpsl[i]*panning-ldl*fb;
rdl=smpsr[i]*(1.0-panning)-rdl*fb;
ldl=ldelay[kl];
rdl=rdelay[kr];
l=ldl*(1.0-lrcross)+rdl*lrcross;
r=rdl*(1.0-lrcross)+ldl*lrcross;
ldl=l;rdl=r;
efxoutl[i]=ldl*2.0;
efxoutr[i]=rdl*2.0;
ldl=smpsl[i]*panning-ldl*fb;
rdl=smpsr[i]*(1.0-panning)-rdl*fb;
//LowPass Filter
ldelay[kl]=ldl=ldl*hidamp+oldl*(1.0-hidamp);
rdelay[kr]=rdl=rdl*hidamp+oldr*(1.0-hidamp);
oldl=ldl;
oldr=rdl;
//LowPass Filter
ldelay[kl]=ldl=ldl*hidamp+oldl*(1.0-hidamp);
rdelay[kr]=rdl=rdl*hidamp+oldr*(1.0-hidamp);
oldl=ldl;
oldr=rdl;
if (++kl>=dl) kl=0;
if (++kr>=dr) kr=0;
if (++kl>=dl) kl=0;
if (++kr>=dr) kr=0;
};
};
}
/*
* Parameter control
*/
void Echo::setvolume(unsigned char Pvolume){
void Echo::setvolume(const unsigned char & Pvolume){
this->Pvolume=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;
volume=outvolume=Pvolume/127.0;
};
if (Pvolume==0) cleanup();
};
}
void Echo::setpanning(unsigned char Ppanning){
void Echo::setpanning(const unsigned char & Ppanning){
this->Ppanning=Ppanning;
panning=(Ppanning+0.5)/127.0;
};
}
void Echo::setdelay(unsigned char Pdelay){
void Echo::setdelay(const unsigned char & Pdelay){
this->Pdelay=Pdelay;
delay=1+(int)(Pdelay/127.0*SAMPLE_RATE*1.5);//0 .. 1.5 sec
initdelays();
};
}
void Echo::setlrdelay(unsigned char Plrdelay){
void Echo::setlrdelay(const unsigned char & Plrdelay){
REALTYPE tmp;
this->Plrdelay=Plrdelay;
tmp=(pow(2,fabs(Plrdelay-64.0)/64.0*9)-1.0)/1000.0*SAMPLE_RATE;
if (Plrdelay<64.0) tmp=-tmp;
lrdelay=(int) tmp;
initdelays();
};
}
void Echo::setlrcross(unsigned char Plrcross){
void Echo::setlrcross(const unsigned char & Plrcross){
this->Plrcross=Plrcross;
lrcross=Plrcross/127.0*1.0;
};
}
void Echo::setfb(unsigned char Pfb){
void Echo::setfb(const unsigned char & Pfb){
this->Pfb=Pfb;
fb=Pfb/128.0;
};
}
void Echo::sethidamp(unsigned char Phidamp){
void Echo::sethidamp(const unsigned char & Phidamp){
this->Phidamp=Phidamp;
hidamp=1.0-Phidamp/127.0;
};
}
void Echo::setpreset(unsigned char npreset){
const int PRESET_SIZE=7;
const int NUM_PRESETS=9;
unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
//Echo 1
{67,64,35,64,30,59,0},
//Echo 2
{67,64,21,64,30,59,0},
//Echo 3
{67,75,60,64,30,59,10},
//Simple Echo
{67,60,44,64,30,0,0},
//Canyon
{67,60,102,50,30,82,48},
//Panning Echo 1
{67,64,44,17,0,82,24},
//Panning Echo 2
{81,60,46,118,100,68,18},
//Panning Echo 3
{81,60,26,100,127,67,36},
//Feedback Echo
{62,64,28,64,100,90,55}};
//Echo 1
{67,64,35,64,30,59,0},
//Echo 2
{67,64,21,64,30,59,0},
//Echo 3
{67,75,60,64,30,59,10},
//Simple Echo
{67,60,44,64,30,0,0},
//Canyon
{67,60,102,50,30,82,48},
//Panning Echo 1
{67,64,44,17,0,82,24},
//Panning Echo 2
{81,60,46,118,100,68,18},
//Panning Echo 3
{81,60,26,100,127,67,36},
//Feedback Echo
{62,64,28,64,100,90,55}};
if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
for (int n=0;n<PRESET_SIZE;n++) changepar(n,presets[npreset][n]);
if (insertion!=0) changepar(0,presets[npreset][0]/2);//lower the volume if this is insertion effect
Ppreset=npreset;
};
}
void Echo::changepar(int npar,unsigned char value){
void Echo::changepar(const int & npar,const unsigned char & value){
switch (npar){
case 0: setvolume(value);
break;
case 1: setpanning(value);
break;
case 2: setdelay(value);
break;
case 3: setlrdelay(value);
break;
case 4: setlrcross(value);
break;
case 5: setfb(value);
break;
case 6: sethidamp(value);
break;
case 0: setvolume(value);
break;
case 1: setpanning(value);
break;
case 2: setdelay(value);
break;
case 3: setlrdelay(value);
break;
case 4: setlrcross(value);
break;
case 5: setfb(value);
break;
case 6: sethidamp(value);
break;
};
};
/**\todo in case of bogus parameter number print error to find depreciated
*calls*/
}
unsigned char Echo::getpar(int npar){
unsigned char Echo::getpar(const int & npar)const{
switch (npar){
case 0: return(Pvolume);
break;
case 1: return(Ppanning);
break;
case 2: return(Pdelay);
break;
case 3: return(Plrdelay);
break;
case 4: return(Plrcross);
break;
case 5: return(Pfb);
break;
case 6: return(Phidamp);
break;
case 0: return(Pvolume);
break;
case 1: return(Ppanning);
break;
case 2: return(Pdelay);
break;
case 3: return(Plrdelay);
break;
case 4: return(Plrcross);
break;
case 5: return(Pfb);
break;
case 6: return(Phidamp);
break;
};
return(0);//in case of bogus parameter number
};
return(0);// in case of bogus parameter number
}

View File

@@ -26,46 +26,105 @@
#include "../globals.h"
#include "Effect.h"
/**Echo Effect*/
class Echo:public Effect{
public:
Echo(int insertion,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
~Echo();
void out(REALTYPE *smpsl,REALTYPE *smpr);
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
void cleanup();
void setdryonly();
/**
* The Constructor For Echo
* @param insertion_ integer to determine if Echo is an insertion effect
* or not
* @param efxoutl_ Effect out Left Channel
* @param efxoutr_ Effect out Right Channel
* @return An initialized Echo Object
*/
Echo(const int & insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_);
/**
* The destructor
*/
~Echo();
/**
* Outputs the echo to efxoutl and efxoutr
* @param smpsl Sample from Left channel
* @param smpsr Sample from Right channel
*/
void out(REALTYPE *const smpsl,REALTYPE *const smpr);
/**
* Sets the state of Echo to the specified preset
* @param npreset number of chosen preset
*/
void setpreset(unsigned char npreset);
/**
* Sets the value of the chosen variable
*
* The possible parameters are:
* -# Volume
* -# Panning
* -# Delay
* -# L/R Delay
* -# L/R Crossover
* -# Feedback
* -# Dampening
* @param npar number of chosen parameter
* @param value the new value
*/
void changepar(const int & npar,const unsigned char & value);
/**
* Gets the specified parameter
*
* The possible parameters are
* -# Volume
* -# Panning
* -# Delay
* -# L/R Delay
* -# L/R Crossover
* -# Feedback
* -# Dampening
* @param npar number of chosen parameter
* @return value of parameter
*
* \todo make this method use constant variables by reference
*Currently doing so results in strange behavior
*/
unsigned char getpar(const int & npar)const;
/**Zeros out the state of the Echo*/
void cleanup();
/**\todo This function needs to be implemented or the prototype should be removed*/
void setdryonly();
private:
//Parametrii
unsigned char Pvolume;//Volumul or E/R
unsigned char Ppanning;//Panning
unsigned char Pdelay;
unsigned char Plrdelay;// L/R delay difference
unsigned char Plrcross;// L/R Mixing
unsigned char Pfb;//Feed-back-ul
unsigned char Phidamp;
void setvolume(unsigned char Pvolume);
void setpanning(unsigned char Ppanning);
void setdelay(unsigned char Pdelay);
void setlrdelay(unsigned char Plrdelay);
void setlrcross(unsigned char Plrcross);
void setfb(unsigned char Pfb);
void sethidamp(unsigned char Phidamp);
//Parametrii reali
REALTYPE panning,lrcross,fb,hidamp;
int dl,dr,delay,lrdelay;
void initdelays();
REALTYPE *ldelay,*rdelay;
REALTYPE oldl,oldr;//pt. lpf
int kl,kr;
};
//Parameters
unsigned char Pvolume;/**< Volume or Dry/Wetness*/
unsigned char Ppanning;/**< Panning*/
unsigned char Pdelay;/**< Delay of the Echo*/
unsigned char Plrdelay;/**< L/R delay difference*/
unsigned char Plrcross;/**< L/R Mixing*/
unsigned char Pfb;/**<Feedback*/
unsigned char Phidamp;/**<Dampening of the Echo*/
void setvolume(const unsigned char & Pvolume);
void setpanning(const unsigned char & Ppanning);
void setdelay(const unsigned char & Pdelay);
void setlrdelay(const unsigned char & Plrdelay);
void setlrcross(const unsigned char & Plrcross);
void setfb(const unsigned char & Pfb);
void sethidamp(const unsigned char & Phidamp);
//Real Parameters
REALTYPE panning,lrcross,fb,hidamp;
int dl,dr,delay,lrdelay;
void initdelays();
REALTYPE *ldelay,*rdelay;
REALTYPE oldl,oldr;//pt. lpf
int kl,kr;
};
#endif

View File

@@ -22,3 +22,9 @@
#include "Effect.h"
Effect::Effect(const int & insertion_,REALTYPE *const efxoutl_,
REALTYPE *const efxoutr_,FilterParams *filterpars_,
const unsigned char & Ppreset_)
:Ppreset(Ppreset_),efxoutl(efxoutl_),efxoutr(efxoutr_),
filterpars(filterpars_),insertion(insertion_){}

View File

@@ -29,29 +29,59 @@
#include "../Params/FilterParams.h"
/**this class is inherited by the all effects(Reverb, Echo, ..)*/
class Effect{
public:
/**
* Effect Constructor
* @param insertion_ 1 when it is an insertion Effect and 0 when it
* is not an insertion Effect
* @param efxoutl_ Effect output buffer Left channel
* @param efxoutr_ Effect output buffer Right channel
* @param filterpars_ pointer to FilterParams array
* @param Ppreset_ chosen preset
* @return Initialized Effect object*/
Effect(const int & insertion_,REALTYPE *const efxoutl_,
REALTYPE *const efxoutr_,FilterParams *filterpars_,
const unsigned char & Ppreset_);
/**Deconstructor*/
virtual ~Effect(){};
/**
* Choose a preset
* @param npreset number of chosen preset*/
virtual void setpreset(unsigned char npreset){};
virtual void changepar(int npar,unsigned char value){};
virtual unsigned char getpar(int npar){return(0);};
virtual void out(REALTYPE *smpsl,REALTYPE *smpsr){};
/**Change parameter npar to value
* @param npar chosen parameter
* @param value chosen new value*/
virtual void changepar(const int &npar,const unsigned char &value){};
/**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){};
/**Reset the state of the effect*/
virtual void cleanup(){};
virtual REALTYPE getfreqresponse(REALTYPE freq){return (0);};//this is only used for EQ (for user interface)
/**This is only used for EQ (for user interface)*/
virtual REALTYPE getfreqresponse(REALTYPE freq){return (0);};
unsigned char Ppreset;
REALTYPE *efxoutl;
REALTYPE *efxoutr;
REALTYPE *const efxoutl;/**<Effect out Left Channel*/
REALTYPE *const efxoutr;/**<Effect out Right Channel*/
REALTYPE outvolume;//this is the volume of effect and is public because need it in system effect. The out volume of such effects are always 1.0, so this setting tells me how is the volume to the Master Output only.
REALTYPE outvolume;/**<This is the volume of effect and is public because
* it is needed in system effects.
* The out volume of such effects are always 1.0, so
* this setting tells me how is the volume to the
* Master Output only.*/
REALTYPE volume;
FilterParams *filterpars;
FilterParams *filterpars;/**<Parameters for filters used by Effect*/
protected:
int insertion;//1 for insertion effect
const int insertion;/**<If Effect is an insertion effect, insertion=1
*otherwise, it should be insertion=0*/
};
#endif

View File

@@ -39,19 +39,19 @@ EffectMgr::EffectMgr(int insertion_,pthread_mutex_t *mutex_){
filterpars=NULL;
dryonly=false;
defaults();
};
}
EffectMgr::~EffectMgr(){
if (efx!=NULL) delete (efx);
delete []efxoutl;
delete []efxoutr;
};
}
void EffectMgr::defaults(){
changeeffect(0);
setdryonly(false);
};
}
/*
* Change the effect
@@ -80,21 +80,21 @@ void EffectMgr::changeeffect(int nefx_){
};
if (efx!=NULL) filterpars=efx->filterpars;
};
}
/*
* Obtain the effect number
*/
int EffectMgr::geteffect(){
return (nefx);
};
}
/*
* Cleanup the current effect
*/
void EffectMgr::cleanup(){
if (efx!=NULL) efx->cleanup();
};
}
/*
@@ -104,14 +104,14 @@ void EffectMgr::cleanup(){
unsigned char EffectMgr::getpreset(){
if (efx!=NULL) return(efx->Ppreset);
else return(0);
};
}
/*
* Change the preset of the current effect
*/
void EffectMgr::changepreset_nolock(unsigned char npreset){
if (efx!=NULL) efx->setpreset(npreset);
};
}
/*
* Change the preset of the current effect(with thread locking)
@@ -120,7 +120,7 @@ void EffectMgr::changepreset(unsigned char npreset){
pthread_mutex_lock(mutex);
changepreset_nolock(npreset);
pthread_mutex_unlock(mutex);
};
}
/*
@@ -129,7 +129,7 @@ void EffectMgr::changepreset(unsigned char npreset){
void EffectMgr::seteffectpar_nolock(int npar,unsigned char value){
if (efx==NULL) return;
efx->changepar(npar,value);
};
}
/*
* Change a parameter of the current effect (with thread locking)
@@ -138,7 +138,7 @@ void EffectMgr::seteffectpar(int npar,unsigned char value){
pthread_mutex_lock(mutex);
seteffectpar_nolock(npar,value);
pthread_mutex_unlock(mutex);
};
}
/*
* Get a parameter of the current effect
@@ -146,7 +146,7 @@ void EffectMgr::seteffectpar(int npar,unsigned char value){
unsigned char EffectMgr::geteffectpar(int npar){
if (efx==NULL) return(0);
return(efx->getpar(npar));
};
}
/*
@@ -214,7 +214,7 @@ void EffectMgr::out(REALTYPE *smpsl,REALTYPE *smpsr){
};
};
};
}
/*
* Get the effect volume for the system effect
@@ -222,7 +222,7 @@ void EffectMgr::out(REALTYPE *smpsl,REALTYPE *smpsr){
REALTYPE EffectMgr::sysefxgetvolume(){
if (efx==NULL) return (1.0);
else return(efx->outvolume);
};
}
/*
@@ -231,12 +231,12 @@ REALTYPE EffectMgr::sysefxgetvolume(){
REALTYPE EffectMgr::getEQfreqresponse(REALTYPE freq){
if (nefx==7) return(efx->getfreqresponse(freq));
else return(0.0);
};
}
void EffectMgr::setdryonly(bool value){
dryonly=value;
};
}
void EffectMgr::add2XML(XMLwrapper *xml){
xml->addpar("type",geteffect());
@@ -258,7 +258,7 @@ void EffectMgr::add2XML(XMLwrapper *xml){
xml->endbranch();
};
xml->endbranch();
};
}
void EffectMgr::getfromXML(XMLwrapper *xml){
changeeffect(xml->getpar127("type",geteffect()));
@@ -285,7 +285,7 @@ void EffectMgr::getfromXML(XMLwrapper *xml){
xml->exitbranch();
};
cleanup();
};
}

View File

@@ -39,6 +39,7 @@
#include "../Params/Presets.h"
/**Effect manager, an interface betwen the program and effects*/
class EffectMgr:public Presets{
public:
EffectMgr(int insertion_,pthread_mutex_t *mutex_);
@@ -52,10 +53,10 @@ class EffectMgr:public Presets{
void setdryonly(bool value);
//get the output(to speakers) volume of the systemeffect
/**get the output(to speakers) volume of the systemeffect*/
REALTYPE sysefxgetvolume();
void cleanup();//cleanup the effect
void cleanup();/**<cleanup the effect*/
void changeeffect(int nefx_);
int geteffect();
@@ -63,9 +64,9 @@ class EffectMgr:public Presets{
void changepreset_nolock(unsigned char npreset);
unsigned char getpreset();
void seteffectpar(int npar,unsigned char value);
void seteffectpar_nolock(int npar,unsigned char value);//sets the effect par without thread lock
void seteffectpar_nolock(int npar,unsigned char value);/**<sets the effect par without thread lock*/
unsigned char geteffectpar(int npar);
int insertion;//1 if the effect is connected as insertion effect
int insertion;/**<1 if the effect is connected as insertion effect*/
REALTYPE *efxoutl,*efxoutr;
//used by UI

View File

@@ -25,16 +25,9 @@
#include <stdio.h>
#define PHASER_LFO_SHAPE 2
Phaser::Phaser(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
filterpars=NULL;
oldl=NULL;
oldr=NULL;
insertion=insertion_;
Ppreset=0;
Phaser::Phaser(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
:Effect(insertion_,efxoutl_,efxoutr_,NULL,0),oldl(NULL),oldr(NULL)
{
setpreset(Ppreset);
cleanup();
};
@@ -124,45 +117,45 @@ void Phaser::cleanup(){
/*
* Parameter control
*/
void Phaser::setdepth(unsigned char Pdepth){
void Phaser::setdepth(const unsigned char &Pdepth){
this->Pdepth=Pdepth;
depth=(Pdepth/127.0);
};
void Phaser::setfb(unsigned char Pfb){
void Phaser::setfb(const unsigned char &Pfb){
this->Pfb=Pfb;
fb=(Pfb-64.0)/64.1;
};
void Phaser::setvolume(unsigned char Pvolume){
void Phaser::setvolume(const unsigned char &Pvolume){
this->Pvolume=Pvolume;
outvolume=Pvolume/127.0;
if (insertion==0) volume=1.0;
else volume=outvolume;
};
void Phaser::setpanning(unsigned char Ppanning){
void Phaser::setpanning(const unsigned char &Ppanning){
this->Ppanning=Ppanning;
panning=Ppanning/127.0;
};
void Phaser::setlrcross(unsigned char Plrcross){
void Phaser::setlrcross(const unsigned char &Plrcross){
this->Plrcross=Plrcross;
lrcross=Plrcross/127.0;
};
void Phaser::setstages(unsigned char Pstages){
void Phaser::setstages(const unsigned char &Pstages){
if (oldl!=NULL) delete [] oldl;
if (oldr!=NULL) delete [] oldr;
if (Pstages>=MAX_PHASER_STAGES) Pstages=MAX_PHASER_STAGES-1;
this->Pstages=Pstages;
if (Pstages>=MAX_PHASER_STAGES) this->Pstages=MAX_PHASER_STAGES-1;
else this->Pstages=Pstages;
oldl=new REALTYPE[Pstages*2];
oldr=new REALTYPE[Pstages*2];
cleanup();
};
void Phaser::setphase(unsigned char Pphase){
void Phaser::setphase(const unsigned char &Pphase){
this->Pphase=Pphase;
phase=(Pphase/127.0);
};
@@ -190,7 +183,7 @@ void Phaser::setpreset(unsigned char npreset){
};
void Phaser::changepar(int npar,unsigned char value){
void Phaser::changepar(const int &npar,const unsigned char &value){
switch(npar){
case 0: setvolume(value);
break;
@@ -216,15 +209,15 @@ void Phaser::changepar(int npar,unsigned char value){
break;
case 9: setlrcross(value);
break;
case 10:if (value>1) value=1;
Poutsub=value;
case 10:if (value>1) Poutsub=1;
else Poutsub=value;
break;
case 11:setphase(value);
break;
};
};
unsigned char Phaser::getpar(int npar){
unsigned char Phaser::getpar(const int &npar)const{
switch (npar){
case 0: return(Pvolume);
break;
@@ -255,6 +248,3 @@ unsigned char Phaser::getpar(int npar){
};

View File

@@ -29,38 +29,38 @@
#define MAX_PHASER_STAGES 12
class Phaser:public Effect {
public:
Phaser(int insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
Phaser(const int &insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
~Phaser();
void out(REALTYPE *smpsl,REALTYPE *smpsr);
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
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;//lfo-ul Phaser
EffectLFO lfo;/**<lfo-ul Phaser*/
unsigned char Pvolume;
unsigned char Ppanning;
unsigned char Pdepth;//the depth of the Phaser
unsigned char Pfb;//feedback
unsigned char Plrcross;//feedback
unsigned char Pdepth;/**<the depth of the Phaser*/
unsigned char Pfb;/**<feedback*/
unsigned char Plrcross;/**<feedback*/
unsigned char Pstages;
unsigned char Poutsub;//if I wish to substract the output instead of the adding it
unsigned char Poutsub;/**<if I wish to substract the output instead of the adding it*/
unsigned char Pphase;
//Control Parametrii
void setvolume(unsigned char Pvolume);
void setpanning(unsigned char Ppanning);
void setdepth(unsigned char Pdepth);
void setfb(unsigned char Pfb);
void setlrcross(unsigned char Plrcross);
void setstages(unsigned char Pstages);
void setphase(unsigned char Pphase);
void setvolume(const unsigned char &Pvolume);
void setpanning(const unsigned char &Ppanning);
void setdepth(const unsigned char &Pdepth);
void setfb(const unsigned char &Pfb);
void setlrcross(const unsigned char &Plrcross);
void setstages(const unsigned char &Pstages);
void setphase(const unsigned char &Pphase);
//Valorile interne
int insertion;
//Internal Values
//int insertion; //inherited from Effect
REALTYPE panning,fb,depth,lrcross,fbl,fbr,phase;
REALTYPE *oldl,*oldr;
REALTYPE oldlgain,oldrgain;

View File

@@ -26,17 +26,14 @@
#include <stdlib.h>
#include "Reverb.h"
/*TODO: EarlyReflections,Prdelay,Perbalance */
/**\todo: EarlyReflections,Prdelay,Perbalance */
Reverb::Reverb(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
efxoutl=efxoutl_;
efxoutr=efxoutr_;
Reverb::Reverb(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
:Effect(insertion_,efxoutl_,efxoutr_,NULL,0)
{
inputbuf=new REALTYPE[SOUND_BUFFER_SIZE];
filterpars=NULL;
insertion=insertion_;
//defaults
Ppreset=0;
Pvolume=48;
Ppan=64;
Ptime=64;
@@ -110,7 +107,7 @@ void Reverb::cleanup(){
void Reverb::processmono(int ch,REALTYPE *output){
int i,j;
REALTYPE fbout,tmp;
//TODO: implement the high part from lohidamp
/**\todo: implement the high part from lohidamp*/
for (j=REV_COMBS*ch;j<REV_COMBS*(ch+1);j++){
@@ -185,7 +182,7 @@ void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r){
/*
* Parameter control
*/
void Reverb::setvolume(unsigned char Pvolume){
void Reverb::setvolume(const unsigned char &Pvolume){
this->Pvolume=Pvolume;
if (insertion==0) {
outvolume=pow(0.01,(1.0-Pvolume/127.0))*4.0;
@@ -196,12 +193,12 @@ void Reverb::setvolume(unsigned char Pvolume){
};
};
void Reverb::setpan(unsigned char Ppan){
void Reverb::setpan(const unsigned char &Ppan){
this->Ppan=Ppan;
pan=(REALTYPE)Ppan/127.0;
};
void Reverb::settime(unsigned char Ptime){
void Reverb::settime(const unsigned char &Ptime){
int i;
REALTYPE t;
this->Ptime=Ptime;
@@ -230,7 +227,7 @@ void Reverb::setlohidamp(unsigned char Plohidamp){
};
};
void Reverb::setidelay(unsigned char Pidelay){
void Reverb::setidelay(const unsigned char &Pidelay){
REALTYPE delay;
this->Pidelay=Pidelay;
delay=pow(50*Pidelay/127.0,2)-1.0;
@@ -246,12 +243,12 @@ void Reverb::setidelay(unsigned char Pidelay){
};
};
void Reverb::setidelayfb(unsigned char Pidelayfb){
void Reverb::setidelayfb(const unsigned char &Pidelayfb){
this->Pidelayfb=Pidelayfb;
idelayfb=Pidelayfb/128.0;
};
void Reverb::sethpf(unsigned char Phpf){
void Reverb::sethpf(const unsigned char &Phpf){
this->Phpf=Phpf;
if (Phpf==0) {//No HighPass
if (hpf!=NULL) delete(hpf);
@@ -264,7 +261,7 @@ void Reverb::sethpf(unsigned char Phpf){
};
};
void Reverb::setlpf(unsigned char Plpf){
void Reverb::setlpf(const unsigned char &Plpf){
this->Plpf=Plpf;
if (Plpf==127) {//No LowPass
if (lpf!=NULL) delete(lpf);
@@ -327,10 +324,10 @@ void Reverb::settype(unsigned char Ptype){
cleanup();
};
void Reverb::setroomsize(unsigned char Proomsize){
if (Proomsize==0) Proomsize=64;//this is because the older versions consider roomsize=0
void Reverb::setroomsize(const unsigned char &Proomsize){
this->Proomsize=Proomsize;
roomsize=(Proomsize-64.0)/64.0;
if (Proomsize==0) this->Proomsize=64;//this is because the older versions consider roomsize=0
roomsize=(this->Proomsize-64.0)/64.0;
if (roomsize>0.0) roomsize*=2.0;
roomsize=pow(10.0,roomsize);
rs=sqrt(roomsize);
@@ -375,7 +372,7 @@ void Reverb::setpreset(unsigned char npreset){
};
void Reverb::changepar(int npar,unsigned char value){
void Reverb::changepar(const int &npar,const unsigned char &value){
switch (npar){
case 0: setvolume(value);
break;
@@ -404,7 +401,7 @@ void Reverb::changepar(int npar,unsigned char value){
};
};
unsigned char Reverb::getpar(int npar){
unsigned char Reverb::getpar(const int &npar)const{
switch (npar){
case 0: return(Pvolume);
break;

View File

@@ -31,83 +31,85 @@
#define REV_COMBS 8
#define REV_APS 4
/**Creates Reverberation Effects*/
class Reverb:public Effect {
public:
Reverb(int insertion,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
Reverb(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
~Reverb();
void out(REALTYPE *smps_l,REALTYPE *smps_r);
void cleanup();
void setpreset(unsigned char npreset);
void changepar(int npar,unsigned char value);
unsigned char getpar(int npar);
void changepar(const int &npar,const unsigned char &value);
unsigned char getpar(const int &npar)const;
private:
//Parametrii
//Amount of the reverb,
/**Amount of the reverb*/
unsigned char Pvolume;
//LefT/Right Panning
/**Left/Right Panning*/
unsigned char Ppan;
//duration of reverb
/**duration of reverb*/
unsigned char Ptime;
//Initial delay
/**Initial delay*/
unsigned char Pidelay;
//Initial delay feedback
/**Initial delay feedback*/
unsigned char Pidelayfb;
//delay between ER/Reverbs
/**delay between ER/Reverbs*/
unsigned char Prdelay;
//EarlyReflections/Reverb Balance
/**EarlyReflections/Reverb Balance*/
unsigned char Perbalance;
//HighPassFilter
/**HighPassFilter*/
unsigned char Plpf;
//LowPassFilter
/**LowPassFilter*/
unsigned char Phpf;
//Low/HighFrequency Damping
unsigned char Plohidamp;// 0..63 lpf,64=off,65..127=hpf(TODO)
/**Low/HighFrequency Damping
* \todo 0..63 lpf,64=off,65..127=hpf(TODO)*/
unsigned char Plohidamp;
//Reverb type
/**Reverb type*/
unsigned char Ptype;
//Room Size
/**Room Size*/
unsigned char Proomsize;
//parameter control
void setvolume(unsigned char Pvolume);
void setpan(unsigned char Ppan);
void settime(unsigned char Ptime);
void setvolume(const unsigned char &Pvolume);
void setpan(const unsigned char &Ppan);
void settime(const unsigned char &Ptime);
void setlohidamp(unsigned char Plohidamp);
void setidelay(unsigned char Pidelay);
void setidelayfb(unsigned char Pidelayfb);
void sethpf(unsigned char Phpf);
void setlpf(unsigned char Plpf);
void settype(unsigned char Ptype);
void setroomsize(unsigned char Proomsize);
void setidelay(const unsigned char &Pidelay);
void setidelayfb(const unsigned char &Pidelayfb);
void sethpf(const unsigned char &Phpf);
void setlpf(const unsigned char &Plpf);
void settype( unsigned char Ptype);
void setroomsize(const unsigned char &Proomsize);
REALTYPE pan,erbalance;
//Parametrii 2
int lohidamptype;//0=disable,1=highdamp(lowpass),2=lowdamp(highpass)
int lohidamptype;/**<0=disable,1=highdamp(lowpass),2=lowdamp(highpass)*/
int idelaylen,rdelaylen;
int idelayk;
REALTYPE lohifb,idelayfb,roomsize,rs;//rs is used to "normalise" the volume according to the roomsize
int comblen[REV_COMBS*2];
int aplen[REV_APS*2];
//Valorile interne
//Internal Variables
REALTYPE *comb[REV_COMBS*2];
int combk[REV_COMBS*2];
REALTYPE combfb[REV_COMBS*2];//feedback-ul fiecarui filtru "comb"
REALTYPE lpcomb[REV_COMBS*2];//pentru Filtrul LowPass
REALTYPE combfb[REV_COMBS*2];/**<feedback-ul fiecarui filtru "comb"*/
REALTYPE lpcomb[REV_COMBS*2];/**<pentru Filtrul LowPass*/
REALTYPE *ap[REV_APS*2];
@@ -120,8 +122,5 @@ class Reverb:public Effect {
void processmono(int ch,REALTYPE *output);
};
#endif