Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Best type of filter to use for Anti-Aliasing?
Avatar
Alia5
New Member
Members
May 20, 2018 - 12:34 pm
Member Since: May 20, 2018
Forum Posts: 2
sp_UserOfflineSmall Offline

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?  

Avatar
W Pirkle
Admin
May 20, 2018 - 5:47 pm
Member Since: January 29, 2017
Forum Posts: 344
sp_UserOfflineSmall Offline

There is an App Note on oversampling (Multirate) and the filtering requirements here:

http://www.willpirkle.com/app-.....polyphase/

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. 

https://vcvrack.com/

Hope that helps,

- Will 

Avatar
Alia5
New Member
Members
May 21, 2018 - 10:27 am
Member Since: May 20, 2018
Forum Posts: 2
sp_UserOfflineSmall Offline

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?  

Avatar
W Pirkle
Admin
May 25, 2018 - 11:42 am
Member Since: January 29, 2017
Forum Posts: 344
sp_UserOfflineSmall Offline

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:

https://github.com/AE9RB/firpm/blob/master/remez.c

Hope that helps,

Will

Forum Timezone: America/New_York

Most Users Ever Online: 55

Currently Online:
11 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 48

Derek: 46

Frodson: 45

Peter: 41

clau_ste: 39

TheSmile: 37

JimmyM: 33

Gwen: 32

EZB: 24

lppier: 23

Member Stats:

Guest Posters: 1

Members: 565

Moderators: 1

Admins: 4

Forum Stats:

Groups: 12

Forums: 36

Topics: 581

Posts: 2326

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