1-RC and C filter

Type : Simple 2-pole LP
References : Posted by madbrain[AT]videotron[DOT]ca
Notes :
This filter is called 1-RC and C since it uses these two parameters. C and R correspond to raw cutoff and inverted resonance, and have a range from 0 to 1.

Code :
//Parameter calculation
//cutoff and resonance are from 0 to 127

  c = pow(0.5, (128-cutoff)   / 16.0);
  r = pow(0.5, (resonance+24) / 16.0);


  v0 =  (1-r*c)*v0  -  (c)*v1  + (c)*input;
  v1 =  (1-r*c)*v1  +  (c)*v0;

  output = v1;

from : yes
comment : input is not in 0 - 1 range. for cutoff i guess 128. for reso the same ?

from : scoofy[AT]inf[DOT]elte[DOT]hu
comment : Nice. This is very similar to a state variable filter in many ways. Relationship between c and frequency: c = 2*sin(pi*freq/samplerate) You can approximate this (tuning error towards nyquist): c = 2*pi*freq/samplerate Relationship between r and q factor: r = 1/q This filter has stability issues for high r values. State variable filter stability limits seem to work fine here. It can also be oversampled for better stability and wider frequency range (use 0.5*original frequency): //Loop: v0 = (1-r*c)*v0 - c*v1 + c*input; v1 = (1-r*c)*v1 + c*v0; tmp = v1; v0 = (1-r*c)*v0 - c*v1 + c*input; v1 = (1-r*c)*v1 + c*v0; output = (tmp+v1)*0.5; -- peter schoffhauzer

from : kiranpatel0305[AT]gmail[DOT]com
comment : Can anyone help me with C++ class composition to implement a single pole-filter design program. The program will allow the user to specify resistor and capacitor values and filter type. Once all the user parameters are specified, the program will return the cutoff frequency values for the filter. I need this as soon as possible and I am lost big time :( Create a Multifile Project for the Composition Lab 1. Add three classes to the project: a Filter class, a Capacitor class, and a Resistor class. 2. The Capacitor class should be modeled after the Resistor class for class members and operation.