commit dbd7a19c219ae4f4b3e8d0556f4669880c9013a3
parent 107267b9a4761bc13faa37a8dfb3cc50c2c5d20e
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Wed, 23 Dec 2009 22:49:22 -0500
Echo: removing resizing due to timing constraints
- No simple solution found for the echo resizing timing
Diffstat:
3 files changed, 5 insertions(+), 69 deletions(-)
diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp
@@ -21,22 +21,18 @@
*/
#include <cmath>
-#include <iostream>
#include "Echo.h"
-using namespace std;
-
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),
- delayTime(1), dl(1), dr(1), lrdelay(0), delay(128000), old(0.0),
+ delayTime(1), lrdelay(0), delay(128000), old(0.0),
pos(0)
{
- pthread_mutex_init(&mutex, NULL);
initdelays();
setpreset(Ppreset);
}
@@ -70,35 +66,17 @@ void Echo::initdelays()
if(dl == delay.l().size() && dr == delay.r().size())
return; //no need to do anything here
- //resetting the loop to a known state
- pthread_mutex_lock(&mutex);
- Sample tmpl(delay.l().size());
- for(int i = 0; i < delay.l().size(); ++i)
- tmpl[i] = delay.l()[pos.l()+i];
-
- Sample tmpr(delay.r().size());
- for(int i = 0; i < delay.r().size(); ++i)
- tmpr[i] = delay.r()[pos.r()+i];
-
- tmpl.resize(dl);
- tmpr.resize(dr);
-
- delay.l() = tmpl;
- delay.r() = tmpr;
pos.l() = 0;
pos.r() = 0;
- pthread_mutex_unlock(&mutex);
+ delay.l() = Sample(dl, 0.0);
+ delay.r() = Sample(dr, 0.0);
}
void Echo::out(const Stereo<Sample> &input)
{
REALTYPE ldl, rdl;
- pthread_mutex_lock(&mutex);
for(int i = 0; i < input.l().size(); ++i) {
- //get past samples (delay .size() is used due to implementaiton of Sample)
- //should get fixed so negative indexes are properly referenced
- //or iterators should work
ldl = delay.l()[pos.l()];
rdl = delay.r()[pos.r()];
ldl = ldl * (1.0 - lrcross) + rdl * lrcross;
@@ -106,22 +84,6 @@ void Echo::out(const Stereo<Sample> &input)
efxoutl[i] = ldl * 2.0;
efxoutr[i] = rdl * 2.0;
- if(rdl != rdl) {
- cout << "hi" << hidamp << endl;
- cout << "l" << ldl << endl;
- cout << "r" << rdl << endl;
- cout << "ol " << efxoutl[i] << endl;
- cout << "or " << efxoutr[i] << endl;
- cout << "cross " << lrcross << endl;
- cout << pos.l() << endl;
- cout << pos.r() << endl;
- cout << input.l()[0] << endl;
- cout << input.r()[0] << endl;
- for(int i=pos.l()-SOUND_BUFFER_SIZE; i<pos.l(); ++i)
- cout << i << ": " << delay.l()[i] << endl;
- exit(1);
- }
-
ldl = input.l()[i] * panning - ldl * fb;
rdl = input.r()[i] * (1.0 - panning) - rdl * fb;
@@ -136,7 +98,6 @@ void Echo::out(const Stereo<Sample> &input)
}
pos.l() %= delay.l().size();
pos.r() %= delay.r().size();
- pthread_mutex_unlock(&mutex);
}
diff --git a/src/Effects/Echo.h b/src/Effects/Echo.h
@@ -28,7 +28,6 @@
#include "../Samples/Sample.h"
#include "../Misc/Stereo.h"
#include "../Controls/DelayCtl.h"
-#include <pthread.h>
/**Echo Effect*/
class Echo:public Effect
@@ -121,7 +120,7 @@ class Echo:public Effect
REALTYPE panning, lrcross, fb, hidamp; //needs better names
//Left/Right delay lengths
Stereo<int> delayTime;
- int dl, dr, lrdelay;
+ int lrdelay;
void initdelays();
//2 channel ring buffer
@@ -130,7 +129,6 @@ class Echo:public Effect
//position of reading/writing from delaysample
Stereo<int> pos;
- mutable pthread_mutex_t mutex;
};
#endif
diff --git a/src/Samples/Sample.cpp b/src/Samples/Sample.cpp
@@ -106,20 +106,11 @@ bool Sample::operator==(const Sample &smp) const
* @param xb X of point b
* @return estimated Y of test point
*/
-float linearEstimate(float ya, float yb, float xt, int xa = 0, int xb = 1)
+inline float linearEstimate(float ya, float yb, float xt, int xa = 0, int xb = 1)
{
if(xa == xb)
return ya;
- //Normalize point a
- //xb -= xa;
- //xt -= xa;
-
- //Normalize point b
- //xt /= xb;
-
- //Now xa=0 xb=1 0<=xt<=1
- //simpily use y=mx+b
return (yb-ya) * (xt-xa)/(xb-xa) + ya;
}
@@ -128,7 +119,6 @@ void Sample::resize(unsigned int nsize)
if(bufferSize == nsize)
return;
else {//resampling occurs here
- int itr = 0;
float ratio = (nsize * 1.0) / (bufferSize * 1.0);
int nBufferSize = nsize;
@@ -153,19 +143,6 @@ void Sample::resize(unsigned int nsize)
nBuffer[i] = linearEstimate(buffer[(int)left],
buffer[(int)right],
test, (int)left, (int)right);
- if(nBuffer[i] != nBuffer[i])
- {
- cout << "ERROR: " << nBuffer[i] << endl;
- cout << "ERROR2: " << buffer[(int)left] << endl;
- cout << "ERROR33: " << buffer[(int)right] << endl;
- cout << "ERROR444: " << right << endl;
- cout << "ERROR5555: " << left << endl;
- cout << "ERROR66666: " << i << endl;
- cout << "ERROR7777: " << i/ratio << endl;
- cout << "ERROR888: " << test << endl;
- exit(1);
- }
-
}
//put the new data in