aboutsummaryrefslogtreecommitdiffstats
path: root/src/mdaRezFilter.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-13 16:04:14 +0000
committerDavid Robillard <d@drobilla.net>2009-05-13 16:04:14 +0000
commite39cbfb9dcf0c00133945eab186072274b45358a (patch)
tree646d496e9bb964ead2ec493e976b01f4de115590 /src/mdaRezFilter.cpp
parentc74440a8ae0169010167befafd80d44e23805f6b (diff)
downloadmda.lv2-e39cbfb9dcf0c00133945eab186072274b45358a.tar.gz
mda.lv2-e39cbfb9dcf0c00133945eab186072274b45358a.tar.bz2
mda.lv2-e39cbfb9dcf0c00133945eab186072274b45358a.zip
Strip trailing whitespace.
git-svn-id: http://svn.drobilla.net/lad/trunk/mda-lv2@1999 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/mdaRezFilter.cpp')
-rw-r--r--src/mdaRezFilter.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/mdaRezFilter.cpp b/src/mdaRezFilter.cpp
index b65240e..7e00db7 100644
--- a/src/mdaRezFilter.cpp
+++ b/src/mdaRezFilter.cpp
@@ -23,13 +23,13 @@ mdaRezFilter::mdaRezFilter(audioMasterCallback audioMaster) : AudioEffectX(audio
fParam8 = 0.00f; //trigger
fParam9 = 0.75f; //max freq
- setNumInputs(2);
- setNumOutputs(2);
- setUniqueID("mdaRezFilter");
- DECLARE_LVZ_DEPRECATED(canMono) ();
- canProcessReplacing();
+ setNumInputs(2);
+ setNumOutputs(2);
+ setUniqueID("mdaRezFilter");
+ DECLARE_LVZ_DEPRECATED(canMono) ();
+ canProcessReplacing();
strcpy(programName, "Resonant Filter");
-
+
suspend(); // flush buffer
setParameter(2, 0.5f); //go and set initial values!
}
@@ -51,21 +51,21 @@ void mdaRezFilter::setParameter(LvzInt32 index, float value)
}
//calcs here
fff = 1.5f * fParam0 * fParam0 - 0.15f;
- fq = 0.99f * (float)pow(fParam1,0.3f); //was 0.99f *
+ fq = 0.99f * (float)pow(fParam1,0.3f); //was 0.99f *
fg = 0.5f * (float)pow(10.0f, 2.f * fParam2 - 1.f);
-
+
fmax = 0.99f + 0.3f * fParam1;
- if(fmax>(1.3f * fParam9)) fmax=1.3f*fParam9;
+ if(fmax>(1.3f * fParam9)) fmax=1.3f*fParam9;
//fmax = 1.0f;
//fq *= 1.0f + 0.2f * fParam9;
-
- fenv = 2.f*(0.5f - fParam3)*(0.5f - fParam3);
+
+ fenv = 2.f*(0.5f - fParam3)*(0.5f - fParam3);
fenv = (fParam3>0.5f)? fenv : -fenv;
att = (float)pow(10.0, -0.01 - 4.0 * fParam4);
rel = 1.f - (float)pow(10.0, -2.00 - 4.0 * fParam5);
lfomode=0;
- flfo = 2.f * (fParam6 - 0.5f)*(fParam6 - 0.5f);
+ flfo = 2.f * (fParam6 - 0.5f)*(fParam6 - 0.5f);
dphi = (float)(6.2832f * (float)pow(10.0f, 3.f * fParam7 - 1.5f) / getSampleRate());
if(fParam6<0.5) { lfomode=1; dphi *= 0.15915f; flfo *= 0.001f; } //S&H
@@ -83,8 +83,8 @@ bool mdaRezFilter::getEffectName(char* name) { strcpy(name, "RezFilter"); re
void mdaRezFilter::suspend()
{
- buf0=0.f;
- buf1=0.f;
+ buf0=0.f;
+ buf1=0.f;
buf2=0.f;
}
@@ -151,7 +151,7 @@ void mdaRezFilter::getParameterDisplay(LvzInt32 index, char *text)
case 5: float2strng((float)(-301.0301 / (getSampleRate() * log10(rel))),text); break;
case 6: long2string((long)(200 * fParam6 - 100), text); break;
case 7: float2strng((float)pow(10.0f, 4.f*fParam7 - 2.f), text); break;
- case 8: if(tthr==0.f) strcpy(text, "FREE RUN");
+ case 8: if(tthr==0.f) strcpy(text, "FREE RUN");
else long2string((long)(20*log10(0.5*tthr)), text); break;
case 9: long2string((long)(100 * fParam9), text); break;
}
@@ -183,17 +183,17 @@ void mdaRezFilter::process(float **inputs, float **outputs, LvzInt32 sampleFrame
float *in2 = inputs[1];
float *out1 = outputs[0];
float *out2 = outputs[1];
- float a, c, d;
+ float a, c, d;
float f, i, o, ff=fff, fe=fenv, q=fq, g=fg, e=env;
float b0=buf0, b1=buf1, b2=buf2, at=att, re=rel, fm=fmax;
float fl=flfo, dph=dphi, ph=phi, bl=bufl, th=tthr, e2=env2;
int lm=lfomode, ta=tatt, tt=ttrig;
- --in1;
- --in2;
+ --in1;
+ --in2;
--out1;
--out2;
-
+
if(th==0.f)
{
while(--sampleFrames >= 0)
@@ -201,21 +201,21 @@ void mdaRezFilter::process(float **inputs, float **outputs, LvzInt32 sampleFrame
a = *++in1 + *++in2;
c = out1[1];
d = out2[1]; //process from here...
-
+
i = (a>0)? a : -a; //envelope
- e = (i>e)? e + at * (i - e) : e * re;
-
+ e = (i>e)? e + at * (i - e) : e * re;
+
if(lm==0) bl = fl * (float)sin(ph); //lfo
else if(ph>1.f) { bl = fl*(rand() % 2000 - 1000); ph=0.f; }
ph += dph;
f = ff + fe * e + bl; //freq
if(f<0.f) i=0.f; else i=(f>fm)? fm : f;
- o = 1.f - i;
+ o = 1.f - i;
- b0 = o * b0 + i * (g*a + q*(1.f + (1.f/o)) * (b0-b1) );
+ b0 = o * b0 + i * (g*a + q*(1.f + (1.f/o)) * (b0-b1) );
b1 = o * b1 + i * b0; //filter
- b2 = o * b2 + i * b1;
+ b2 = o * b2 + i * b1;
*++out1 = c + b2;
*++out2 = d + b2;
@@ -228,10 +228,10 @@ void mdaRezFilter::process(float **inputs, float **outputs, LvzInt32 sampleFrame
a = *++in1 + *++in2;
c = out1[1];
d = out2[1]; //process from here...
-
+
i = (a>0)? a : -a; //envelope
- e = (i>e)? i : e * re;
- if(e>th) { if(tt==0) {ta=1; if(lm==1)ph=2.f; } tt=1; } else tt=0;
+ e = (i>e)? i : e * re;
+ if(e>th) { if(tt==0) {ta=1; if(lm==1)ph=2.f; } tt=1; } else tt=0;
if(ta==1) { e2 += at*(1.f-e2); if(e2>0.999f)ta=0; } else e2*=re;
if(lm==0) bl = fl * (float)sin(ph); //lfo
@@ -240,18 +240,18 @@ void mdaRezFilter::process(float **inputs, float **outputs, LvzInt32 sampleFrame
f = ff + fe * e + bl; //freq
if(f<0.f) i=0.f; else i=(f>fm)? fm : f;
- o = 1.f - i;
+ o = 1.f - i;
- b0 = o * b0 + i * (g*a + q*(1.f + (1.f/o)) * (b0-b1) );
+ b0 = o * b0 + i * (g*a + q*(1.f + (1.f/o)) * (b0-b1) );
b1 = o * b1 + i * b0; //filter
- b2 = o * b2 + i * b1;
+ b2 = o * b2 + i * b1;
*++out1 = c + b2;
*++out2 = d + b2;
}
}
if(fabs(b0)<1.0e-10) { buf0=0.f; buf1=0.f; buf2=0.f; }
- else { buf0=b0; buf1=b1; buf2=b2; }
+ else { buf0=b0; buf1=b1; buf2=b2; }
env=e; env2=e2; bufl=bl; tatt=ta; ttrig=tt;
phi=(float)fmod(ph,6.2831853f);
}
@@ -262,14 +262,14 @@ void mdaRezFilter::processReplacing(float **inputs, float **outputs, LvzInt32 sa
float *in2 = inputs[1];
float *out1 = outputs[0];
float *out2 = outputs[1];
- float a;
+ float a;
float f, i, ff=fff, fe=fenv, q=fq, g=fg, e=env, tmp;
float b0=buf0, b1=buf1, b2=buf2, at=att, re=rel, fm=fmax;
float fl=flfo, dph=dphi, ph=phi, bl=bufl, th=tthr, e2=env2;
int lm=lfomode, ta=tatt, tt=ttrig;
- --in1;
- --in2;
+ --in1;
+ --in2;
--out1;
--out2;
@@ -278,29 +278,29 @@ void mdaRezFilter::processReplacing(float **inputs, float **outputs, LvzInt32 sa
while(--sampleFrames >= 0)
{
a = *++in1 + *++in2;
-
+
i = (a>0)? a : -a; //envelope
- e = (i>e)? e + at * (i - e) : e * re;
-
+ e = (i>e)? e + at * (i - e) : e * re;
+
if(lm==0) bl = fl * (float)sin(ph); //lfo
else if(ph>1.f) { bl = fl*(rand() % 2000 - 1000); ph=0.f; }
ph += dph;
f = ff + fe * e + bl; //freq
if(f<0.f) i=0.f; else i=(f>fm)? fm : f;
- // o = 1.f - i;
+ // o = 1.f - i;
// tmp = g*a + q*(1.f + (1.f/o)) * (b0-b1);
- // b0 = o * (b0 - tmp) + tmp;
+ // b0 = o * (b0 - tmp) + tmp;
// b1 = o * (b1 - b0) + b0;
-
+
tmp = q + q * (1.0f + i * (1.0f + 1.1f * i));
//tmp = q + q/(1.0008 - i);
b0 += i * (g * a - b0 + tmp * (b0 - b1));
b1 += i * (b0 - b1);
-
- // b2 = o * (b2 - b1) + b1;
+
+ // b2 = o * (b2 - b1) + b1;
*++out1 = b1;
*++out2 = b1;
@@ -311,11 +311,11 @@ void mdaRezFilter::processReplacing(float **inputs, float **outputs, LvzInt32 sa
while(--sampleFrames >= 0)
{
a = *++in1 + *++in2;
-
+
i = (a>0)? a : -a; //envelope
- e = (i>e)? i : e * re;
- if(e>th) { if(tt==0) {ta=1; if(lm==1)ph=2.f; } tt=1; } else tt=0;
+ e = (i>e)? i : e * re;
+ if(e>th) { if(tt==0) {ta=1; if(lm==1)ph=2.f; } tt=1; } else tt=0;
if(ta==1) { e2 += at*(1.f-e2); if(e2>0.999f)ta=0; } else e2*=re;
if(lm==0) bl = fl * (float)sin(ph); //lfo
@@ -324,8 +324,8 @@ void mdaRezFilter::processReplacing(float **inputs, float **outputs, LvzInt32 sa
f = ff + fe * e + bl; //freq
if(f<0.f) i=0.f; else i=(f>fm)? fm : f;
-
- // o = 1.f - i;
+
+ // o = 1.f - i;
tmp = q + q * (1.0f + i * (1.0f + 1.1f * i));
//tmp = q + q/(1.0008 - i);
@@ -336,7 +336,7 @@ void mdaRezFilter::processReplacing(float **inputs, float **outputs, LvzInt32 sa
// tmp = g*a + q*(1.f + (1.f/o)) * (b0-b1); //what about (q + q/f)*
// b0 = o * (b0 - tmp) + tmp; // ^ what about div0 ?
// b1 = o * (b1 - b0) + b0;
- // b2 = o * (b2 - b1) + b1;
+ // b2 = o * (b2 - b1) + b1;
*++out1 = b1;
@@ -344,7 +344,7 @@ void mdaRezFilter::processReplacing(float **inputs, float **outputs, LvzInt32 sa
}
}
if(fabs(b0)<1.0e-10) { buf0=0.f; buf1=0.f; buf2=0.f; }
- else { buf0=b0; buf1=b1; buf2=b2; }
+ else { buf0=b0; buf1=b1; buf2=b2; }
env=e; env2=e2; bufl=bl; tatt=ta; ttrig=tt;
phi=(float)fmod(ph,6.2831853f);
}