aliasant ·
Below is something I found quite interesting and something that should be quite simple for us to convert to SM. Most of it is simple but the stage/ state stuff is new to me.
I found this at this place: http://www.musicdsp.org/showArchiveComm ... hiveID=227
Butterworth
Type : LPF 24dB/Oct References : Posted by [email removed] Code : First calculate the prewarped digital frequency:
K = tan(Pi * Frequency / Samplerate);
Now calc some intermediate variables: (see 'Factors of Polynoms' at http://en.wikipedia.org/wiki/Butterworth_filter, especially if you want a higher order like 48dB/Oct) a = 0.76536686473 * Q * K; b = 1.84775906502 * Q * K;
K = K*K; (to optimize it a little bit)
Calculate the first biquad:
A0 = (K+a+1); A1 = 2*(1-K); A2 =(a-K-1); B0 = K; B1 = 2*B0; B2 = B0;
Calculate the second biquad:
A3 = (K+b+1); A4 = 2*(1-K); A5 = (b-K-1); B3 = K; B4 = 2*B3; B5 = B3;
Then calculate the output as follows:
Stage1 = B0*Input + State0; State0 = B1*Input + A1/A0*Stage1 + State1; State1 = B2*Input + A2/A0*Stage1;
Output = B3*Stage1 + State2; State2 = B4*Stage1 + A4/A3*Output + State2; State3 = B5*Stage1 + A5/A3*Output;