zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 94d4ae6a0586970ea4d2a3a8c8f002686241ed9c
parent 8f8e8b701c2a452fa08fceb8a5bc8f2577be9e57
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sun, 30 May 2010 12:11:25 -0400

Effects: small cleanup

Diffstat:
Msrc/Effects/Alienwah.cpp | 6+++---
Msrc/Effects/Chorus.cpp | 2--
Msrc/Effects/DynamicFilter.cpp | 20+++++++++-----------
Msrc/Effects/DynamicFilter.h | 16+++++++---------
Msrc/Effects/Reverb.cpp | 37+++++++++++++------------------------
5 files changed, 32 insertions(+), 49 deletions(-)

diff --git a/src/Effects/Alienwah.cpp b/src/Effects/Alienwah.cpp @@ -49,7 +49,7 @@ Alienwah::~Alienwah() void Alienwah::out(const Stereo<float *> &smp) { REALTYPE lfol, lfor; //Left/Right LFOs - complex<REALTYPE> clfol, clfor, out, tmp; + complex<REALTYPE> clfol, clfor; /**\todo Rework, as optimization can be used when the new complex type is * utilized. * Before all calculations needed to be done with individual REALTYPE, @@ -64,9 +64,9 @@ void Alienwah::out(const Stereo<float *> &smp) REALTYPE x = ((REALTYPE) i) / SOUND_BUFFER_SIZE; REALTYPE x1 = 1.0 - x; //left - tmp = clfol * x + oldclfol * x1; + complex<REALTYPE> tmp = clfol * x + oldclfol * x1; - out = tmp * oldl[oldk]; + complex<REALTYPE> out = tmp * oldl[oldk]; out.real() += (1 - fabs(fb)) * smp.l()[i] * (1.0 - panning); oldl[oldk] = out; diff --git a/src/Effects/Chorus.cpp b/src/Effects/Chorus.cpp @@ -127,8 +127,6 @@ void Chorus::out(const Stereo<float *> &input) efxoutl[i] *= -1.0; efxoutr[i] *= -1.0; } - ; - for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { efxoutl[i] *= panning; diff --git a/src/Effects/DynamicFilter.cpp b/src/Effects/DynamicFilter.cpp @@ -48,7 +48,6 @@ DynamicFilter::~DynamicFilter() */ void DynamicFilter::out(const Stereo<float *> &smp) { - int i; if(filterpars->changed) { filterpars->changed = false; cleanup(); @@ -58,26 +57,25 @@ void DynamicFilter::out(const Stereo<float *> &smp) lfo.effectlfoout(&lfol, &lfor); lfol *= depth * 5.0; lfor *= depth * 5.0; - REALTYPE freq = filterpars->getfreq(); - REALTYPE q = filterpars->getq(); + const REALTYPE freq = filterpars->getfreq(); + const REALTYPE q = filterpars->getq(); - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { efxoutl[i] = smp.l()[i]; efxoutr[i] = smp.r()[i]; - REALTYPE x = (fabs(smp.l()[i]) + fabs(smp.l()[i])) * 0.5; + const REALTYPE x = (fabs(smp.l()[i]) + fabs(smp.l()[i])) * 0.5; ms1 = ms1 * (1.0 - ampsmooth) + x * ampsmooth + 1e-10; } - - REALTYPE ampsmooth2 = pow(ampsmooth, 0.2) * 0.3; + const REALTYPE ampsmooth2 = pow(ampsmooth, 0.2) * 0.3; ms2 = ms2 * (1.0 - ampsmooth2) + ms1 * ampsmooth2; ms3 = ms3 * (1.0 - ampsmooth2) + ms2 * ampsmooth2; ms4 = ms4 * (1.0 - ampsmooth2) + ms3 * ampsmooth2; - REALTYPE rms = (sqrt(ms4)) * ampsns; + const REALTYPE rms = (sqrt(ms4)) * ampsns; - REALTYPE frl = filterl->getrealfreq(freq + lfol + rms); - REALTYPE frr = filterr->getrealfreq(freq + lfor + rms); + const REALTYPE frl = filterl->getrealfreq(freq + lfol + rms); + const REALTYPE frr = filterr->getrealfreq(freq + lfor + rms); filterl->setfreq_and_q(frl, q); filterr->setfreq_and_q(frr, q); @@ -87,7 +85,7 @@ void DynamicFilter::out(const Stereo<float *> &smp) filterr->filterout(efxoutr); //panning - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { efxoutl[i] *= panning; efxoutr[i] *= (1.0 - panning); } diff --git a/src/Effects/DynamicFilter.h b/src/Effects/DynamicFilter.h @@ -40,17 +40,15 @@ class DynamicFilter:public Effect unsigned char getpar(int npar) const; void cleanup(); -// void setdryonly(); - private: //Parametrii DynamicFilter - 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 Pampsnsinv; //if the filter freq is lowered if the input amplitude rises - unsigned char Pampsmooth; //how smooth the input amplitude changes the filter + EffectLFO lfo; //lfo-ul DynamicFilter + unsigned char Pvolume; //Volume + unsigned char Ppanning; //Pan + 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 //Parameter Control void setvolume(unsigned char Pvolume); diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp @@ -123,17 +123,14 @@ void Reverb::cleanup() */ void Reverb::processmono(int ch, REALTYPE *output) { - int i, j; - REALTYPE fbout, tmp; /**\todo: implement the high part from lohidamp*/ + for(int j = REV_COMBS * ch; j < REV_COMBS * (ch + 1); j++) { + int &ck = combk[j]; + const int comblength = comblen[j]; + REALTYPE &lpcombj = lpcomb[j]; - for(j = REV_COMBS * ch; j < REV_COMBS * (ch + 1); j++) { - int ck = combk[j]; - int comblength = comblen[j]; - REALTYPE lpcombj = lpcomb[j]; - - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - fbout = comb[j][ck] * combfb[j]; + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { + REALTYPE fbout = comb[j][ck] * combfb[j]; fbout = fbout * (1.0 - lohifb) + lpcombj * lohifb; lpcombj = fbout; @@ -143,22 +140,18 @@ void Reverb::processmono(int ch, REALTYPE *output) if((++ck) >= comblength) ck = 0; } - - combk[j] = ck; - lpcomb[j] = lpcombj; } - for(j = REV_APS * ch; j < REV_APS * (1 + ch); j++) { - int ak = apk[j]; - int aplength = aplen[j]; - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - tmp = ap[j][ak]; + for(int j = REV_APS * ch; j < REV_APS * (1 + ch); j++) { + int &ak = apk[j]; + const int aplength = aplen[j]; + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { + REALTYPE tmp = ap[j][ak]; ap[j][ak] = 0.7 * tmp + output[i]; output[i] = tmp - 0.7 * ap[j][ak]; if((++ak) >= aplength) ak = 0; } - apk[j] = ak; } } @@ -167,16 +160,14 @@ void Reverb::processmono(int ch, REALTYPE *output) */ void Reverb::out(const Stereo<float *> &smp) { - int i; if((Pvolume == 0) && (insertion != 0)) return; - for(i = 0; i < SOUND_BUFFER_SIZE; i++) + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) inputbuf[i] = (smp.l()[i] + smp.r()[i]) / 2.0; - ; if(idelay != NULL) { - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { //Initial delay r REALTYPE tmp = inputbuf[i] + idelay[idelayk] * idelayfb; inputbuf[i] = idelay[idelayk]; @@ -184,7 +175,6 @@ void Reverb::out(const Stereo<float *> &smp) idelayk++; if(idelayk >= idelaylen) idelayk = 0; - ; } } @@ -246,7 +236,6 @@ void Reverb::settime(unsigned char Ptime) combfb[i] = -exp((REALTYPE)comblen[i] / (REALTYPE)SAMPLE_RATE * log(0.001) / t); //the feedback is negative because it removes the DC - ; } void Reverb::setlohidamp(unsigned char Plohidamp)