Please note, I did not get the "bits" knob working yet, only the "frequency" knob. Please excuse the randomness of my coding, I was trying to implement different versions of the bit crunchers that were on the music DSP site. Based on my variable names, you can find the version of the code that I plucked bits and pieces from. When I clean it up i will add proper attribution to the comments in the code.
Basically I did this sloppy mess, with the proper adjustments to the other files to add the menu items:
In the file named Timber.cpp
case FILTER_BIT:
{
float *sp = this->sampleBlock;
float localv0L = v0L;
float localv1L = v1L;
float localv0R = v0R;
float phasor=0;
float BitsTwo = params.effect.param1;
int bits=BitsTwo;
float step;
float Frq = params.effect.param2 * PREENFM_FREQUENCY;
float SR = PREENFM_FREQUENCY;
float NormFreq = Frq / SR;
for (int k=0 ; k<BLOCK_SIZE ; k++) {
if (unlikely(fxParam1 = 0)) {
fxParam1 = 0.01;
}
step = 1 / (pow(2.0, bits));
// left side
localv0L = (*sp) + localv0L;
phasor = phasor + NormFreq;
if (phasor >= 1.0){
phasor = phasor - 1.0;
localv0L = step * floor(localv0L / step + 0.5 ); //quantize
localv0L = localv0L * fxParam3;
}
(*sp) = ((*sp) + localv0L) * mixerGain;
if (unlikely(*sp > ratioTimbres)) {
*sp = ratioTimbres;
}
if (unlikely(*sp < -ratioTimbres)) {
*sp = -ratioTimbres;
}
sp++;