Audio Waveform antialiasing techniques

Rein

Member
I have for a while searched the forums for ways to bandlimit arbitrary waveforms. As far as I know has this not been done yet in the teensy realm.

I am currently investigating the possibility to adaptively filter/bandlimit the arbitrary wave (arbData in AudioSynthWaveform class) using a IIR Chebychev filter. Depending on the frequency played, adapt the filter cutoff and therefore effectively bandlimiting the generated wave. I see the possibility to generate the bandlimited wave on call to the frequency() function or continuously in update().

Doing filtering for each Waveform object implies a larger overhead. Should therefore consider creating a new audio object for this purpose. Thought about using a windowed sinc-function, but realized IIR filters is better suited for the much lower execution time and being easier adaptable to different cutoff frequencies. The chebychev coefficients are relatively easy to calculate (example: https://www.analog.com/media/en/technical-documentation/dsp-book/dsp_book_Ch20.pdf). May also consider a lookup table containing coefficients for specific cutoff frequencies at an interval.

I am by no means really qualified to talk about this. I have taken some courses related to DSP but with no practical experience and only recently began exploring the Audio library.

Does anyone have any thoughts about this?
 
Playing a sampled waveform back at various different rates is a problem of interpolation or decimation, ie rate-conversion.

Straight IIR and FIR filters only work when the input sample rate is the same as the output sample rate - for instance you could
interpolate up by integer ratio by zero-stuffing followed by an IIR or FIR filter (but a FIR filter can benefit from polyphase
methods if the input is notionally zero-stuffed, so is often faster than IIR which has to work at the higher of the two rates).

For decimation by an integer ratio you have to run an IIR or FIR at the input (higher) sample rate then drop samples, which is
expensive unless you use FIR in polyphase mode (which only generates the samples that aren't dropped).

However if the ratio isn't an integer ratio this zero-stuffing or sample-dropping approach doesn't work - using sinc interpolation
can achieve the arbitrary interpolation/decimation and filtering in one step - its like polyphase FIR combined with sub-sample
interpolation. And being a FIR technique there is no phase distortion. And the best performing FIR response is windowed sinc.

Typically the sinc function is in a lookup table (with optional linear or polynomial interpolation between table entries).

There's an implemetation of this approach in synth_waveform.cpp in the audio library, BandLimitedWaveform, but its tailored
specifically to square/sawtooth/pulse waveform synthesis rather than arbitrary input samples.

Here's one resource I found: https://ccrma.stanford.edu/~jos/pasp/Windowed_Sinc_Interpolation.html

[ BTW its quite common for polyphase and multi-rate techniques to be omitted in basic DSP tutorials, but they are
essential techniques in the real world and very powerful, often making IIR filters slower as well as less well behaved
for phase. Low power sigma-delta ADC or DAC chips would not be feasible without them for instance. ]
 
Wow, thanks for the comprehensive answer!

How hard would it be to implement such a method for arbitrary waveforms? i.e what benefits are there from implementing this for specific waveforms.

Will check out the implementation of BandLlimitedWaveform when i have the time and try to understand it.

Thanks again for taking the time!
 
The band limited waveforms are a succession of step functions, at arbitrary timing, so its a little different from a succession of
samples so I fear the code won't translate well. There are several pertinent threads about rate conversion here, but
not sure I can remember all the relevant subject keywords, but this one might be a good match. ASRC stands for ASynchronous
Rate Conversion:

https://forum.pjrc.com/threads/68881-New-project-to-verify-an-asrc-using-polynomial-approximations-for-its-coefficients
 
Back
Top