Main Archive Specials Wiki | FAQ Links Submit Forum

 Cool Sounding Lowpass With Decibel Measured ResonanceType : LP 2-pole resonant tweaked butterworthReferences : Posted by daniel_jacob_werner [AT] yaho [DOT] com [DOT] auNotes : This algorithm is a modified version of the tweaked butterworth lowpass filter by Patrice Tarrabia posted on musicdsp.org's archives. It calculates the coefficients for a second order IIR filter. The resonance is specified in decibels above the DC gain. It can be made suitable to use as a SoundFont 2.0 filter by scaling the output so the overall gain matches the specification (i.e. if resonance is 6dB then you should scale the output by -3dB). Note that you can replace the sqrt(2) values in the standard butterworth highpass algorithm with my "q =" line of code to get a highpass also. How it works: normally q is the constant sqrt(2), and this value controls resonance. At sqrt(2) resonance is 0dB, smaller values increase resonance. By multiplying sqrt(2) by a power ratio we can specify the resonant gain at the cutoff frequency. The resonance power ratio is calculated with a standard formula to convert between decibels and power ratios (the powf statement...). Good Luck, Daniel Werner http://experimentalscene.com/Code : float c, csq, resonance, q, a0, a1, a2, b1, b2; c = 1.0f / (tanf(pi * (cutoff / samplerate))); csq = c * c; resonance = powf(10.0f, -(resonancedB * 0.1f)); q = sqrt(2.0f) * resonance; a0 = 1.0f / (1.0f + (q * c) + (csq)); a1 = 2.0f * a0; a2 = a0; b1 = (2.0f * a0) * (1.0f - csq); b2 = a0 * (1.0f - (q * c) + csq);