I am teaching myself C++, and I'm trying to make a simple distortion plugin (using JUCE).
However, I am kind of blocked at the antialiasing part - I am having some trouble understanding perfectly what I should do, even with some very interesting topics I found here on KVR (hereand here).
What I understand (correct me if I'm wrong) is that I should do the following steps :
- Oversample my buffer (let's say 2X to make it simple)
- Process the oversampled array with my distortion algorithm
- Low-pass (for instance using a Butterworth filter)
- Downsample
Question 1 :
Regarding the oversampling : for now I'm just adding 0 values between the actual samples values. I noticed links to this article : http://yehar.com/blog/wp-content/upload ... iginal.pdf
I assume it's just a matter of choice, but which of the interpolation algorithms are the most commonly used ?
Since we are using buffers, aren't the oversampling cause a problem at the limits (i.e. first sample and last sample in the buffer) ? I think not but I want to make sure
Question 2 :
So far I have a written a very simple code without filtering. Right now I am getting some sound but there is a kind of static noise, so I guess I am doing something wrong. Anyone has an idea ?
(I know its speed can be enhanced, by the way, I just did a very raw thing to understand the concept. Speed will come after )
Code: Select all
float* channelData = buffer.getWritePointer (channel);
// OVERSAMPLING 2X
for (int i = 0; i < buffer.getNumSamples()*2; i++) {
if (i % 2 == 0) { oversampleArray.push_back(channelData[i]); }
else { oversampleArray.push_back(0); }
}
// DISTORTION
for (int sample = 0; sample < buffer.getNumSamples()*2; sample++) {
oversampleArray[sample] = 1 / (atan(5))*atan(5*oversampleArray[sample]);
}
// DOWNSAMPLING
for (int i = 0; i < buffer.getNumSamples(); i++) {
channelData[i] = oversampleArray[2 * i];
}
oversampleArray.clear();
Would it be absolutely wrong to simply do a LPF at Nyquist frequency, without oversampling ?
--
Sorry, that's a lot of questions and I know those are complex topics. I hope you guys will be able to help me out, because I am reading a lot of things about FIRs and stuffs but in the end I am not sure which direction to go, especially since DSP is not exactly for the faint-hearted in terms of mathematics, and although I understand the formulas I am reading they don't always make crystal-clear sense to me.
Thank you by advance for your help,
V.