Hello I am a vst / juce newbie.
I am trying to figure out sample rate reduction and bit crushing. I got the code of a nice vst decimator example , and I am trying to understand what it does. I already understand bit curshing well. However, I am having problems with downsampling. The main problem I have is that I think the plugin doesn’t process audio properly.
Can you guys check this video and tell me what you think?
If you see the video, you will quickly realize what the problem is: when I change sample rates, I get annoying pops and crackles.
Does anybody know what is wrong with the audio processing of this code?
Here is the code that does all the decimation (I posted an image because syntax highlighting helps, if it is annoying I won’t do that anymore):
Here is processBlock again
void myPlugin::processBlock (AudioSampleBuffer& buffer,
MidiBuffer& midiMessages)
{
// initialize y1 and cnt to 0
y1=cnt=0;
// go through each active input channel
for (int channel = 0; channel < getNumInputChannels(); ++channel){
float *p = buffer.getSampleData (channel);
int size = buffer.getNumSamples();
//pass each sample from sample data and decimate
for (int x=0; x<size; x++){
cnt += sampleRate;
if (cnt >= 1){
cnt -= 1;
y1 = (*(p+x));
}
*(p+x) = y1;
}
}
for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
buffer.clear (i, 0, buffer.getNumSamples());
}