Noise n => BiQuad gq => dac; 0.1 => gq.gain; //need these: 0 => int PEAKNOTCH; 1 => int LOWSHELF; 2 => int HIGHSHELF; 2. * pi => float twopi; 1::second/1::samp => float thisSR; //set everything setFreqBoostBandwidth(440., 10., 0.1, LOWSHELF); //yay, hang out 1::day => now; //main function for setting biquad params fun void setFreqBoostBandwidth(float freq, float boost, float thisBandwidth, int type) { float d, a_boost, a_cut, Vzero, true_bw; freq * thisBandwidth => true_bw; boost - 1. => Vzero; //a's are pole coeffs, b's are zero coeffs //PEAK/NOTCH CASE if (type == PEAKNOTCH) { (Math.tan(true_bw*twopi/(2.*thisSR)) - 1.) / (Math.tan(true_bw*twopi/(2.*thisSR)) + 1.) => a_boost; (Math.tan(true_bw*twopi/(2.*thisSR)) - boost) / (Math.tan(true_bw*twopi/(2.*thisSR)) + boost) => a_cut; -Math.cos(freq*twopi/thisSR) => d; /* cut */ if(boost <= 1.0) { 1.0 + (1.0 + a_cut)*Vzero/2.0 => gq.b0; d*(1 - a_cut) => gq.b1; (-a_cut - (1 + a_cut)*Vzero/2.0) => gq.b2; d*(1.0 - a_cut) => gq.a1; -a_cut => gq.a2; } /* boost */ if(boost > 1.0) { 1.0 + (1.0 + a_boost)*Vzero/2.0 => gq.b0; d*(1 - a_boost) => gq.b1; (-a_boost - (1 + a_boost)*Vzero/2.0) => gq.b2; d*(1.0 - a_boost) => gq.a1; -a_boost => gq.a2; } } //LOW SHELF CASE else if (type == LOWSHELF) { (Math.tan(freq*twopi/(2.*thisSR)) - 1.) / (Math.tan(freq*twopi/(2.*thisSR)) + 1.) => a_boost; (Math.tan(freq*twopi/(2.*thisSR)) - boost) / (Math.tan(freq*twopi/(2.*thisSR)) + boost) => a_cut; /* cut */ if(boost <= 1.0) { 1.0 + (1.0 + a_cut)*Vzero/2.0 => gq.b0; a_cut + (1 + a_cut)*Vzero/2.0 => gq.b1; 0. => gq.b2; a_cut => gq.a1; 0. => gq.a2; } /* boost */ if(boost > 1.0) { 1.0 + (1.0 + a_boost)*Vzero/2.0 => gq.b0; a_boost + (1 + a_boost)*Vzero/2.0 => gq.b1; 0. => gq.b2; a_boost => gq.a1; 0. => gq.a2; } } //HIGH SHELF CASE else if (type == HIGHSHELF) { (Math.tan(freq*twopi/(2.*thisSR)) - 1.) / (Math.tan(freq*twopi/(2.*thisSR)) + 1.) => a_boost; (boost*Math.tan(freq*twopi/(2.*thisSR)) - 1.) / (boost*Math.tan(freq*twopi/(2.*thisSR)) + 1.) => a_cut; /* cut */ if(boost <= 1.0) { 1.0 + (1.0 - a_cut)*Vzero/2.0 => gq.b0; a_cut + (a_cut - 1.)*Vzero/2.0 => gq.b1; 0. => gq.b2; a_cut => gq.a1; 0. => gq.a2; } /* boost */ if(boost > 1.0) { 1.0 + (1.0 - a_boost)*Vzero/2.0 => gq.b0; a_boost + (a_boost - 1.)*Vzero/2.0 => gq.b1; 0. => gq.b2; a_boost => gq.a1; 0. => gq.a2; } } }