Wavetable synthesis bandlimiting buffer

louis hardoon's icon

Hi,
I'm actually working on a wavetable oscillator. The tables are created inside the max patch, there will be 1table/octave . For basic wave like saw rect ect I've planned to "peek" the band limited waveforms (addition of sin with the highest one below the nyquist frequency) in the buffers. But what if I want the user to be able to import his own non band limited waveforms (or to draw them). How could I then band limit the buffers ?
Is this option valid : FFT each buffer => Filter in frequency domain => IFFT => Override the buffer.
What else can I do ?
Thanks for your help,
Louis

Roman Thilenius's icon

for unknown content there is only one thing you can do, lowpassfilter the audio so hard that you cut off a bit more than neccessary.

35 times [slide 2.99 2.99] should work fine, you just will loose half an octave under nyquist, too.

louis hardoon's icon

Hi thanks for the answer,
My buffer are read from a gen patch with the sample object. What you suggest is to filter the output of the gen patch ? I could maybe oversample too ? Could you explain why this is the only solution ?

Roman Thilenius's icon

nope, i was only answering the "user samples" part. if you generate waveforms programatically you can generate them bandlimited from the beginning on. but if you use random audio files you need a brickwallfilter close to nyquist.

it is the only solution because you dont know unknown things in advance. :)

upsampling? yes of course. in theory you would set the 44 khz basic waveform to the lowest note number, which is 0, so that you reach a freaking crazy 512 times oversampling at note number 120. in practice you will use far less. try 8x and see if you like the result.

(may i remind you that most DA converters will also use a simple lowpass filter to reduce aliasing?)

louis hardoon's icon

Hi,
Ok very nice !
Just curious: If I brickwall all the wavetable corresponding to let say a saw (which is not generated with sin and so not band limited). Will the result be the same that if I had generated each wavetable with addition of sin up to nyquist (I mean if we don't concider cpu charge) ? I guess it depends of the filter and their linearity in phase ? I read somewhere it has to be done with a FIR(but I don't see any in max)? Could you tell me more about the choice of the filter and the consequences ?
Some of the things I read about this: http://www.dafx.ca/proceedings/papers/p_169.pdf
Thanks again for your help !

Roman Thilenius's icon

no it will not be the same. procedural will be exact and predictable. if you use post filtering to create wavetables you must cut stuff a bit more to get rid of most content over nyquist.

right, it should be phase linear filters by any means. thats why i suggested slide~s.

slide~ 4 4 will leave 11khz untouched and will lower the gain of 22 khz content for -3db per each additional instance of slide~ you add. it is a compromise.

FIR in MSP is buffir~ with buffer~. but forget it for now.

...

btw, if you want to do it really good, you can use the following setup:

- use 2 times oversampling for all wavetables

- use a different wavetable for every octave

this way you can have 100% bandlimited output across the whole spectrum.