zynaddsubfx

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

commit 2cac86b624dfdfdee283e938bc6c70a514b30060
parent 8e48f3c6e2a7d1ab9155a89ebf130ca70910772e
Author: fundamental <[email protected]>
Date:   Sun, 11 Jul 2010 22:23:15 -0400

Reverb: removed use of temporary

Diffstat:
Msrc/Effects/Reverb.cpp | 12++++++------
Msrc/Effects/Reverb.h | 3+--
2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp @@ -22,14 +22,13 @@ #include <cmath> #include "Reverb.h" +#include "../Misc/Util.h" /**\todo: EarlyReflections,Prdelay,Perbalance */ Reverb::Reverb(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_) :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0) { - inputbuf = new REALTYPE[SOUND_BUFFER_SIZE]; - bandwidth = NULL; //defaults @@ -87,7 +86,6 @@ Reverb::~Reverb() for(i = 0; i < REV_COMBS * 2; i++) delete [] comb[i]; - delete [] inputbuf; if(bandwidth) delete bandwidth; } @@ -121,7 +119,7 @@ void Reverb::cleanup() /* * Process one channel; 0=left,1=right */ -void Reverb::processmono(int ch, REALTYPE *output) +void Reverb::processmono(int ch, REALTYPE *output, REALTYPE *inputbuf) { /**\todo: implement the high part from lohidamp*/ for(int j = REV_COMBS * ch; j < REV_COMBS * (ch + 1); j++) { @@ -163,6 +161,7 @@ void Reverb::out(const Stereo<float *> &smp) if((Pvolume == 0) && (insertion != 0)) return; + REALTYPE *inputbuf = getTmpBuffer(); for(int i = 0; i < SOUND_BUFFER_SIZE; i++) inputbuf[i] = (smp.l[i] + smp.r[i]) / 2.0; @@ -186,8 +185,9 @@ void Reverb::out(const Stereo<float *> &smp) if(hpf != NULL) hpf->filterout(inputbuf); - processmono(0, efxoutl); //left - processmono(1, efxoutr); //right + processmono(0, efxoutl, inputbuf); //left + processmono(1, efxoutr, inputbuf); //right + returnTmpBuffer(inputbuf); REALTYPE lvol = rs / REV_COMBS * pan; REALTYPE rvol = rs / REV_COMBS * (1.0 - pan); diff --git a/src/Effects/Reverb.h b/src/Effects/Reverb.h @@ -126,9 +126,8 @@ class Reverb:public Effect REALTYPE *idelay; AnalogFilter *lpf, *hpf; //filters - REALTYPE *inputbuf; - void processmono(int ch, REALTYPE *output); + void processmono(int ch, REALTYPE *output, REALTYPE *inputbuf); }; #endif