Browse Source

skip out of calculations when input==0

master
aj_genius 21 years ago
parent
commit
b2bb2caaa4
3 changed files with 53 additions and 28 deletions
  1. +38
    -19
      SpiralSound/Plugins/MoogFilterPlugin/MoogFilterPlugin.C
  2. +1
    -0
      SpiralSound/Plugins/MoogFilterPlugin/MoogFilterPlugin.h
  3. +14
    -9
      SpiralSound/Plugins/SVFilterPlugin/SVFilterPlugin.C

+ 38
- 19
SpiralSound/Plugins/MoogFilterPlugin/MoogFilterPlugin.C View File

@@ -60,7 +60,7 @@ f(0.0f),
p(0.0f), p(0.0f),
q(0.0f), q(0.0f),
b0(0.1f), b0(0.1f),
b1(0.1f),
b1(0.0f),
b2(0.0f), b2(0.0f),
b3(0.0f), b3(0.0f),
b4(0.0f), b4(0.0f),
@@ -135,28 +135,47 @@ void MoogFilterPlugin::Execute()
Q = ((Resonance+GetInput(2,n))*6)-3.0f; Q = ((Resonance+GetInput(2,n))*6)-3.0f;
q = Q + (1.0f + 0.5f * q * (1.0f - q + 5.6f * q * q)); q = Q + (1.0f + 0.5f * q * (1.0f - q + 5.6f * q * q));
} }
in = GetInput(0,n); in = GetInput(0,n);
in -= q * b4;
if (in>1) in=1;
if (in<-1) in=-1;
t1 = b1; b1 = (in + b0) * p - b1 * f;
t2 = b2; b2 = (b1 + t1) * p - b2 * f;
t1 = b3; b3 = (b2 + t2) * p - b3 * f;
b4 = (b3 + t1) * p - b4 * f;
b4 = b4 - b4 * b4 * b4 * 0.166667f;
b0 = in;
SetOutput(0,n,b4);
SetOutput(1,n,(in-b4));
SetOutput(2,n,3.0f * (b3 - b4));
if (in == 0)
{
Clear();
SetOutput(0,n,0);
SetOutput(1,n,0);
SetOutput(2,n,0);
} else {
in -= q * b4;
if (in>1) in=1;
if (in<-1) in=-1;
t1 = b1; b1 = (in + b0) * p - b1 * f;
t2 = b2; b2 = (b1 + t1) * p - b2 * f;
t1 = b3; b3 = (b2 + t2) * p - b3 * f;
b4 = (b3 + t1) * p - b4 * f;
b4 = b4 - b4 * b4 * b4 * 0.166667f;
b0 = in;
SetOutput(0,n,b4);
SetOutput(1,n,(in-b4));
SetOutput(2,n,3.0f * (b3 - b4));
}
} }
} }

void MoogFilterPlugin::Clear()
{
b0 = 0.0f;
b1 = 0.0f;
b2 = 0.0f;
b3 = 0.0f;
b4 = 0.0f;
t1 = 0.0f;
t2 = 0.0f;
}

void MoogFilterPlugin::Randomise() void MoogFilterPlugin::Randomise()
{ {
} }


+ 1
- 0
SpiralSound/Plugins/MoogFilterPlugin/MoogFilterPlugin.h View File

@@ -37,6 +37,7 @@ public:
float GetCutoff() { return Cutoff; } float GetCutoff() { return Cutoff; }
float GetResonance() { return Resonance; } float GetResonance() { return Resonance; }
void Clear();
void Randomise(); void Randomise();


private: private:


+ 14
- 9
SpiralSound/Plugins/SVFilterPlugin/SVFilterPlugin.C View File

@@ -115,14 +115,19 @@ void SVFilterPlugin::Execute()


in = GetInput(0,n); in = GetInput(0,n);


float scale=0.5f;

m_l = m_l + m_f*m_b;
m_h = scale*in - m_l - q*m_b;
m_b = m_b + m_f*m_h;
m_n = m_l + m_h;
m_p = m_l - m_h;

if (in == 0)
Clear();
else
{
float scale=0.5f;

m_l = m_l + m_f*m_b;
m_h = scale*in - m_l - q*m_b;
m_b = m_b + m_f*m_h;
m_n = m_l + m_h;
m_p = m_l - m_h;
}
SetOutput(0,n,m_l); SetOutput(0,n,m_l);
SetOutput(1,n,m_b); SetOutput(1,n,m_b);
SetOutput(2,n,m_h); SetOutput(2,n,m_h);
@@ -156,7 +161,7 @@ void SVFilterPlugin::StreamIn (istream &s) {
void SVFilterPlugin::Clear() void SVFilterPlugin::Clear()
{ {
m_h=0.0f; m_h=0.0f;
m_b=0.1f;
m_b=0.0f;
m_l=0.0f; m_l=0.0f;
m_p=0.0f; m_p=0.0f;
m_n=0.0f; m_n=0.0f;


Loading…
Cancel
Save