I'm working on a synthesizer plugin that does frequency modulation.
I've been trying to tackle the problem of aliasing, and I have a question about low pass filtering as part of my method, which I will try to explain...
1) I have to do oversampling (by a factor of 'm') in my synthesis calculations so that the effective Nyquist limit is much higher than the host sample rate Nyquist limit.
This prevents high frequencies from aliasing.
2) I have to low pass filter the oversampled signal, so that when I downsample back to host sample rate there will be no frequency content above the host Nyquist limit.
3) Lastly I downsample by summing every (mth) sample, and then dividing this sum by 'm'.
For example, if I am using x8 oversampling, I will sum together 8 samples and divide the result by 8 to get my final sample output at the host sample rate.
I'm relatively new to filter theory and coding filters, so I opted to borrow some code from the 'ResonantLPF' RackFX project.
Specifically, I have borrowed the Biquad object from the RackFX example code to do my low pass filtering at stage 2).
This prototype anti-aliasing system works in basic way, although it is computationally expensive and does not prevent aliasing perfectly.
So my question is... what sort of filter (as opposed to the 'ResonantLPF') would be ideal for improving this anti-aliasing process?
Is there anything else in the FX book that I could turn my attention to?
There is an App Note on oversampling (Multirate) and the filtering requirements here:
This uses the "textbook" linear phase FIR filters which are decomposed into smaller polyphase filters. If you want to do it correctly, this is the way to go. The major hurdle is convolution with the long FIR filters, even after making them more efficient (see the App Note).
You may also find papers on using IIR filters instead and there are also some "budget" versions that I've run across, but never got too interested in.
You might also want to check the code for the VCV Rack synth plugins which (if I remember correctly) includes some oversampling code.
Hope that helps,
11/10 answer - thank you! I have one follow up question...
I didn't know about impulse response generator in RackFX - pre-computing my filter coefficients should be a big help.
I'm just wondering how I could do the process of generating the impulse responses from inside my code, rather than using RackFX to do this outside of my code?
I would prefer to be able to generate impulse responses for a low pass filter from inside my code, but with a sample rate argument that would cause the impulse responses to re-generate if the sampling rate changes (or if other parts of my code require the filter to work at an arbitrary oversampling rate).
Would this be reasonably possible?
RackAFX uses the Optimal Method and Frequency Sampling methods to generate impulse responses and FIR filters. I can't give out the code for that but I can tell you where I got it:
Both the Optimal Method and Frequency Sampling method code originally came from a great DSP book called "Digital Signal Processing: A Practical Approach" by Ifeachor and Jervis and it is listed int the Bibliography of the FIR and IIR chapters in the FX book. I just coded in C++ the algorithms they describe so well, and they also provide some raw C code as well. They also describe and show the implementation for the Windowing method (a third and very popular method to generate FIR filters). My version is their first edition, published in 1993 (and I still use it today) - but there are newer versions out there.
The only tricky thing with the Optimal Method is the Remez Exchange Algorithm and I used a very old (but stable) version you can get here:
Hope that helps,
Most Users Ever Online: 55
Currently Browsing this Page:
Guest Posters: 1
Newest Members:frankthetank, dhodgson, Wanderer, mister1234, Evan Galvanek, Rowan Fraser, patrickbarr1984, Ray C., Jon R., Pat
Moderators: W Pirkle: 344
Administrators: Tom: 69, JD Young: 80, Will Pirkle: 0, W Pirkle: 344