zynaddsubfx

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

commit a3d3cf448cc2d782f9ab0015c24378fd7f69aa24
parent 134f9ac742ee5da00e839b9e23a6a42c5b450f85
Author: fundamental <[email protected]>
Date:   Sun, 27 Jun 2010 15:59:40 -0400

Merge commit 'b683bf98e711db21de2fe5901567a48a66650939'

Conflicts:
	src/Effects/Alienwah.cpp
	src/Effects/DynamicFilter.cpp
	src/Effects/Reverb.cpp

Diffstat:
Msrc/Effects/APhaser.cpp | 4++--
Msrc/Effects/Alienwah.cpp | 6+++---
Msrc/Effects/Chorus.cpp | 20++++++++++----------
Msrc/Effects/Distorsion.cpp | 6+++---
Msrc/Effects/DynamicFilter.cpp | 8++++----
Msrc/Effects/EQ.cpp | 4++--
Msrc/Effects/Echo.cpp | 36++++++++++++++++++------------------
Msrc/Effects/Phaser.cpp | 24++++++++++++------------
Msrc/Effects/Reverb.cpp | 4++--
Msrc/Misc/Stereo.cpp | 8++++----
Msrc/Misc/Stereo.h | 32++++----------------------------
Msrc/Tests/EchoTest.h | 12++++++------
12 files changed, 70 insertions(+), 94 deletions(-)

diff --git a/src/Effects/APhaser.cpp b/src/Effects/APhaser.cpp @@ -152,8 +152,8 @@ void Analog_Phaser::out(const Stereo<REALTYPE *> &input) gl += ldiff; // Linear interpolation between LFO samples gr += rdiff; - float lxn = input.l()[i]; - float rxn = input.r()[i]; + float lxn = input.l[i]; + float rxn = input.r[i]; if (barber) { diff --git a/src/Effects/Alienwah.cpp b/src/Effects/Alienwah.cpp @@ -66,8 +66,8 @@ void Alienwah::out(const Stereo<float *> &smp) //left complex<REALTYPE> tmp = clfol * x + oldclfol * x1; - complex<REALTYPE> out = tmp * oldl[oldk]; - out.real() += (1 - fabs(fb)) * smp.l()[i] * (1.0 - panning); + complex<REALTYPE>out = tmp * oldl[oldk]; + out.real() += (1 - fabs(fb)) * smp.l[i] * (1.0 - panning); oldl[oldk] = out; REALTYPE l = out.real() * 10.0 * (fb + 0.1); @@ -76,7 +76,7 @@ void Alienwah::out(const Stereo<float *> &smp) tmp = clfor * x + oldclfor * x1; out = tmp * oldr[oldk]; - out.real() += (1 - fabs(fb)) * smp.r()[i] * (1.0 - panning); + out.real() += (1 - fabs(fb)) * smp.r[i] * (1.0 - panning); oldr[oldk] = out; REALTYPE r = out.real() * 10.0 * (fb + 0.1); diff --git a/src/Effects/Chorus.cpp b/src/Effects/Chorus.cpp @@ -79,13 +79,13 @@ void Chorus::out(const Stereo<float *> &input) dr2 = getdelay(lfor); for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { - REALTYPE inl = input.l()[i]; - REALTYPE inr = input.r()[i]; + REALTYPE inl = input.l[i]; + REALTYPE inr = input.r[i]; //LRcross Stereo<REALTYPE> tmpc(inl, inr); //REALTYPE r=inr; - inl = tmpc.l() * (1.0 - lrcross) + tmpc.r() * lrcross; - inr = tmpc.r() * (1.0 - lrcross) + tmpc.l() * lrcross; + inl = tmpc.l * (1.0 - lrcross) + tmpc.r * lrcross; + inr = tmpc.r * (1.0 - lrcross) + tmpc.l * lrcross; //Left channel @@ -100,9 +100,9 @@ void Chorus::out(const Stereo<float *> &input) dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; dllo = 1.0 - fmod(tmp, one); - efxoutl[i] = delaySample.l()[dlhi2] * dllo + delaySample.l()[dlhi] + efxoutl[i] = delaySample.l[dlhi2] * dllo + delaySample.l[dlhi] * (1.0 - dllo); - delaySample.l()[dlk] = inl + efxoutl[i] * fb; + delaySample.l[dlk] = inl + efxoutl[i] * fb; //Right channel @@ -117,9 +117,9 @@ void Chorus::out(const Stereo<float *> &input) dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; dllo = 1.0 - fmod(tmp, one); - efxoutr[i] = delaySample.r()[dlhi2] * dllo + delaySample.r()[dlhi] + efxoutr[i] = delaySample.r[dlhi2] * dllo + delaySample.r[dlhi] * (1.0 - dllo); - delaySample.r()[dlk] = inr + efxoutr[i] * fb; + delaySample.r[dlk] = inr + efxoutr[i] * fb; } if(Poutsub != 0) @@ -139,8 +139,8 @@ void Chorus::out(const Stereo<float *> &input) */ void Chorus::cleanup() { - delaySample.l().clear(); - delaySample.r().clear(); + delaySample.l.clear(); + delaySample.r.clear(); } /* diff --git a/src/Effects/Distorsion.cpp b/src/Effects/Distorsion.cpp @@ -271,14 +271,14 @@ void Distorsion::out(const Stereo<float *> &smp) if(Pstereo != 0) { //Stereo for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - efxoutl[i] = smp.l()[i] * inputvol * panning; - efxoutr[i] = smp.r()[i] * inputvol * (1.0 - panning); + efxoutl[i] = smp.l[i] * inputvol * panning; + efxoutr[i] = smp.r[i] * inputvol * (1.0 - panning); } } else { for(i = 0; i < SOUND_BUFFER_SIZE; i++) efxoutl[i] = - (smp.l()[i] * panning + smp.r()[i] * (1.0 - panning)) * inputvol; + (smp.l[i] * panning + smp.r[i] * (1.0 - panning)) * inputvol; ; } diff --git a/src/Effects/DynamicFilter.cpp b/src/Effects/DynamicFilter.cpp @@ -60,11 +60,11 @@ void DynamicFilter::out(const Stereo<float *> &smp) const REALTYPE freq = filterpars->getfreq(); const REALTYPE q = filterpars->getq(); - for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { - efxoutl[i] = smp.l()[i]; - efxoutr[i] = smp.r()[i]; + for(i = 0; i < SOUND_BUFFER_SIZE; i++) { + efxoutl[i] = smp.l[i]; + efxoutr[i] = smp.r[i]; - const 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; } diff --git a/src/Effects/EQ.cpp b/src/Effects/EQ.cpp @@ -57,8 +57,8 @@ void EQ::out(const Stereo<float *> &smp) { int i; for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - efxoutl[i] = smp.l()[i] * volume; - efxoutr[i] = smp.r()[i] * volume; + efxoutl[i] = smp.l[i] * volume; + efxoutr[i] = smp.r[i] * volume; } for(i = 0; i < MAX_EQ_BANDS; i++) { diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp @@ -44,8 +44,8 @@ Echo::Echo(const int &insertion_, Echo::~Echo() { - delete[] delay.l(); - delete[] delay.r(); + delete[] delay.l; + delete[] delay.r; } /* @@ -53,8 +53,8 @@ Echo::~Echo() */ void Echo::cleanup() { - memset(delay.l(),0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); - memset(delay.r(),0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); + memset(delay.l,0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); + memset(delay.r,0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); old = Stereo<REALTYPE>(0.0); } @@ -75,8 +75,8 @@ void Echo::initdelays() //number of seconds to delay right chan float dr = avgDelay + lrdelay; - ndelta.l() = max(1,(int) (dl * SAMPLE_RATE)); - ndelta.r() = max(1,(int) (dr * SAMPLE_RATE)); + ndelta.l = max(1,(int) (dl * SAMPLE_RATE)); + ndelta.r = max(1,(int) (dr * SAMPLE_RATE)); } void Echo::out(const Stereo<float *> &input) @@ -84,32 +84,32 @@ void Echo::out(const Stereo<float *> &input) REALTYPE ldl, rdl; for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - ldl = delay.l()[pos.l()]; - rdl = delay.r()[pos.r()]; + ldl = delay.l[pos.l]; + rdl = delay.r[pos.r]; ldl = ldl * (1.0 - lrcross) + rdl * lrcross; rdl = rdl * (1.0 - lrcross) + ldl * lrcross; efxoutl[i] = ldl * 2.0; efxoutr[i] = rdl * 2.0; - ldl = input.l()[i] * panning - ldl * fb; - rdl = input.r()[i] * (1.0 - panning) - rdl * fb; + ldl = input.l[i] * panning - ldl * fb; + rdl = input.r[i] * (1.0 - panning) - rdl * fb; //LowPass Filter - old.l() = delay.l()[(pos.l()+delta.l())%(MAX_DELAY * SAMPLE_RATE)] = ldl * hidamp + old.l() * (1.0 - hidamp); - old.r() = delay.r()[(pos.r()+delta.r())%(MAX_DELAY * SAMPLE_RATE)] = rdl * hidamp + old.r() * (1.0 - hidamp); + old.l = delay.l[(pos.l+delta.l)%(MAX_DELAY * SAMPLE_RATE)] = ldl * hidamp + old.l * (1.0 - hidamp); + old.r = delay.r[(pos.r+delta.r)%(MAX_DELAY * SAMPLE_RATE)] = rdl * hidamp + old.r * (1.0 - hidamp); //increment - ++pos.l();// += delta.l(); - ++pos.r();// += delta.r(); + ++pos.l;// += delta.l; + ++pos.r;// += delta.r; //ensure that pos is still in bounds - pos.l() %= MAX_DELAY * SAMPLE_RATE; - pos.r() %= MAX_DELAY * SAMPLE_RATE; + pos.l %= MAX_DELAY * SAMPLE_RATE; + pos.r %= MAX_DELAY * SAMPLE_RATE; //adjust delay if needed - delta.l() = (15*delta.l() + ndelta.l())/16; - delta.r() = (15*delta.r() + ndelta.r())/16; + delta.l = (15*delta.l + ndelta.l)/16; + delta.r = (15*delta.r + ndelta.r)/16; } } diff --git a/src/Effects/Phaser.cpp b/src/Effects/Phaser.cpp @@ -67,22 +67,22 @@ void Phaser::out(const Stereo<float *> &smp) for(i = 0; i < SOUND_BUFFER_SIZE; i++) { REALTYPE x = (REALTYPE) i / SOUND_BUFFER_SIZE; REALTYPE x1 = 1.0 - x; - REALTYPE gl = lgain * x + oldgain.left() * x1; - REALTYPE gr = rgain * x + oldgain.right() * x1; - REALTYPE inl = smp.l()[i] * panning + fbl; - REALTYPE inr = smp.r()[i] * (1.0 - panning) + fbr; + REALTYPE gl = lgain * x + oldgain.l * x1; + REALTYPE gr = rgain * x + oldgain.r * x1; + REALTYPE inl = smp.l[i] * panning + fbl; + REALTYPE inr = smp.r[i] * (1.0 - panning) + fbr; //Left channel for(j = 0; j < Pstages * 2; j++) { //Phasing routine - tmp = old.left()[j]; - old.left()[j] = gl * tmp + inl; - inl = tmp - gl *old.left()[j]; + tmp = old.l[j]; + old.l[j] = gl * tmp + inl; + inl = tmp - gl *old.l[j]; } //Right channel for(j = 0; j < Pstages * 2; j++) { //Phasing routine - tmp = old.right()[j]; - old.right()[j] = gr * tmp + inr; - inr = tmp - gr *old.right()[j]; + tmp = old.r[j]; + old.r[j] = gr * tmp + inr; + inr = tmp - gr *old.r[j]; } //Left/Right crossing REALTYPE l = inl; @@ -114,8 +114,8 @@ void Phaser::cleanup() fbl = 0.0; fbr = 0.0; oldgain = Stereo<REALTYPE>(0.0); - old.l().clear(); - old.r().clear(); + old.l.clear(); + old.r.clear(); } /* diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp @@ -163,8 +163,8 @@ void Reverb::out(const Stereo<float *> &smp) if((Pvolume == 0) && (insertion != 0)) return; - for(int i = 0; i < SOUND_BUFFER_SIZE; i++) - inputbuf[i] = (smp.l()[i] + smp.r()[i]) / 2.0; + for(i = 0; i < SOUND_BUFFER_SIZE; i++) + inputbuf[i] = (smp.l[i] + smp.r[i]) / 2.0; if(idelay != NULL) { for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { diff --git a/src/Misc/Stereo.cpp b/src/Misc/Stereo.cpp @@ -21,18 +21,18 @@ template<class T> Stereo<T>::Stereo(const T &left, const T &right) - :leftChannel(left), rightChannel(right) + :l(left), r(right) {} template<class T> Stereo<T>::Stereo(const T &val) - :leftChannel(val), rightChannel(val) + :l(val), r(val) {} template<class T> void Stereo<T>::operator=(const Stereo<T> &nstr) { - leftChannel = nstr.leftChannel; - rightChannel = nstr.rightChannel; + l = nstr.l; + r = nstr.r; } diff --git a/src/Misc/Stereo.h b/src/Misc/Stereo.h @@ -22,7 +22,7 @@ #define STEREO_H template<class T> -class Stereo +struct Stereo { public: Stereo(const T &left, const T &right); @@ -34,33 +34,9 @@ class Stereo ~Stereo() {} void operator=(const Stereo<T> &smp); - T &left() { - return leftChannel; - } - T &right() { - return rightChannel; - } - T &l() { - return leftChannel; - } - T &r() { - return rightChannel; - } - const T &left() const { - return leftChannel; - } - const T &right() const { - return rightChannel; - } - const T &l() const { - return leftChannel; - } - const T &r() const { - return rightChannel; - } - private: - T leftChannel; - T rightChannel; + + T l; + T r; }; #include "Stereo.cpp" #endif diff --git a/src/Tests/EchoTest.h b/src/Tests/EchoTest.h @@ -40,13 +40,13 @@ class EchoTest:public CxxTest::TestSuite outR[i] = 0.0; input = new Stereo<REALTYPE *>(new REALTYPE[SOUND_BUFFER_SIZE],new REALTYPE[SOUND_BUFFER_SIZE]); for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - input->l()[i] = input->r()[i] = 0.0f; + input->l[i] = input->r[i] = 0.0f; testFX = new Echo(true, outL, outR); } void tearDown() { - delete[] input->r(); - delete[] input->l(); + delete[] input->r; + delete[] input->l; delete input; delete[] outL; delete[] outR; @@ -70,7 +70,7 @@ class EchoTest:public CxxTest::TestSuite //flood with high input for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - input->r()[i] = input->l()[i] = 1.0; + input->r[i] = input->l[i] = 1.0; for(int i = 0; i < 500; ++i) testFX->out(*input); @@ -94,7 +94,7 @@ class EchoTest:public CxxTest::TestSuite //flood with high input for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - input->r()[i] = input->l()[i] = 1.0; + input->r[i] = input->l[i] = 1.0; char FEEDBACK = 5; testFX->changepar(FEEDBACK, 127); for(int i = 0; i < 100; ++i) @@ -106,7 +106,7 @@ class EchoTest:public CxxTest::TestSuite float amp = abs(outL[0] + outR[0]) / 2; //reset input to zero for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) - input->r()[i] = input->l()[i] = 0.0; + input->r[i] = input->l[i] = 0.0; //give the echo time to fade based upon zero input and high feedback for(int i = 0; i < 50; ++i)