[Stk] Wah-wah filter? UPDATE for STK using BiQuad
Perry Cook
prc at CS.Princeton.EDU
Tue Oct 8 11:05:19 PDT 2013
Howdy!! My recent hacking of the Raspberry Pi have renewed my
enthusiasm for, and appreciation of, STK.
Today's Wah Wah update for the STK people. I dug into ChucK's ResonZ
filter source code, and it turns out that it (of course) inherits from BiQuad.
I did a test comparing ResonZ and BiQuad (in ChucK), and they seem
to generate basically the same thing as long as I set the coefficients correctly.
Duh, huh?
I hacked a new version of the STK effects project, adding WahWah as
a radio button and condition. Fairly minimal changes to effects.cpp,
and adding BiQuad.o to the Makefile. That new project all lives at:
http://www.cs.princeton.edu/~prc/STKHacks/effectsWithWah.zip
Punchline:
You can make a BiQuad (or subclass it) , and set equal gain zeroes,
and set the frequency and radius thusly:
// given a float value named "temp" ranging from 0.0 to 1.0
// and an STK BiQuad filter named wahwah,
// in the main controller service functions, add this:
case 22: // effect parameter change 1
.
. OTHER STUFF for Other EFX
.
{ // new block for wahWah servicing
float freqs[3] = {460.0,840,2250}; // JOS data
float Qs[3] = {9.4,4.0,2.0}; // from his pedal
float myFreq, myQ;
if (temp < 0.5) {
myFreq = freqs[0] +
((freqs[1]-freqs[0])*2.0*temp);
myQ = Qs[0] +
((Qs[1]-Qs[0])*2.0*temp);
}
else {
myFreq = freqs[1] +
((freqs[2]-freqs[1])*2.0*(temp-0.5));
myQ = Qs[1] +
((Qs[2]-Qs[1])*2.0*(temp-0.5));
}
data->wahwah.setEqualGainZeroes();
float pFreq = myFreq * TWO_PI / SRATE;
float bandwidth = pFreq / myQ;
float radius = 1.0 - (bandwidth * 0.5);
data->wahwah.setResonance(myFreq,radius,1);
}
********************************************************
// For the bilingual, here's my ChucK test program to
// compare the ResonZ to BiQuad:
Noise nz => ResonZ wah => WvOut left => dac;
nz => BiQuad wah2 => WvOut right => dac;
"left.wav" => left.wavFilename;
"right.wav" => right.wavFilename;
0.3 => nz.gain;
[460.0,840,2250] @=> float freqs[]; // JOS data
[9.4,4.0,2.0] @=> float Qs[]; // from his pedal
1 => wah2.eqzs;
for (0 => int i; i < 3; i++) {
(freqs[i],Qs[i]) => wah.set;
freqs[i]*6.28/44100.0 => float pFreq;
pFreq / Qs[i] => float bandwidth;
1.0 - (bandwidth * 0.5) => float radius;
freqs[i] => wah2.pfreq;
radius => wah2.prad;
(1.0 - radius*radius) * 0.5 => wah2.gain;
2.0 :: second => now;
}
left.closeFile();
right.closeFile();
/// END
More information about the Stk
mailing list