[music-dsp] modified Moog VCF

Paul Kellett paul.kellett at maxim.abel.co.uk
Sun Jul 23 06:47:28 EDT 2000

Below is my version of the "Moog VCF" code posted here a 
few days ago, with some of the calculations simplified.

It sounds pretty good, except my preference is for filters
that keep the passband at unity gain, else bass sounds get
too quiet.

The second "q =" line previously used exp() - I'm not sure if
what I've done is any faster, but this line needs playing with
anyway as it controls which frequencies will self-oscillate. I
think it could be tweaked to sound better than it currently does.

Comments and suggestions welcome!


paul.kellett at maxim.abel.co.uk

//Moog 24 dB/oct resonant lowpass VCF
//References: CSound source code, Stilson/Smith CCRMA paper.
//Modified by paul.kellett at maxim.abel.co.uk July 2000

  float f, p, q;             //filter coefficients
  float b0, b1, b2, b3, b4;  //filter buffers (beware denormals!)
  float t1, t2;              //temporary buffers

//set coefficients given frequency & resonance [0.0...1.0]

  q = 1.0f - frequency;
  p = frequency + 0.8f * frequency * q;
  f = p + p - 1.0f;
  q = resonance * (1.0f + 0.5f * q * (1.0f - q + 5.6f * q * q));

//filter (in [-1.0...+1.0] --> output in b4)

  in -= q * b4;                          //feedback
  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;    //clipping
  b0 = in;

dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links

More information about the music-dsp mailing list