Filtering buffer contents with peek+slide?

Roald Baudoux's icon

Hello,

I want to build a wavetable synth using a series of tables. Every table would have the same series of waves but would be low-pass filtered to a specific cutoff to match a specific pitch range so to have a good compromise between spectral richness and protection against aliasing. I plan to use 10 tables matching 10 octaves downwards from 22.05 kHz.

Of course I could prepare the wavetables outside Max but I was wondering whether it would be possible to filter the sounds upon loading within Max (and possibly in non real-time).

The idea would be to load the sound to be filtered into a buffer, read each sample with peek~, filter with slide and record in another buffer with another instance of peek~.

My questions:
1.If I want to apply a sharp lowpass filtering to my sound in nonrealtime, is slide the best option?
2. How should I calculate the smoothing argument to get a filtering at SR/2, SR/4, etc?

Thank you in advance.

Roald Baudoux

Roman Thilenius's icon

1. biquad (or 2-3 maybe)

2. SR/3

why peek~? why not play~ and record~?

-110

Tj Shredder's icon

Nonrealtime could be much faster than real time...

Hans Höglund's icon

The best way would probably be to implement a standard filter algorithm using Max objects only.

For instance, the the biquad~ use the following function:

For each sample n,
y[n] = a0 * x[n] + a1 * x[n-1] + a2 * x[n-2] - b1 * y[n-1] - b2 * y[n-2]

I may have I go at this later if I have time.

Roald Baudoux's icon

Sorry for the delay to answer, I got caught by one thousand other things.

Thank you Hans, this is a good peek into that stuff but I suppose I'd need a similar equation for a high slope low-pass filter. Any idea where I could get that?

Roald Baudoux

Hans Höglund's icon

The function above can be used for almost any filter. Play around with filtergraph~ to find good values for the coefficients.

This generalization of the above formula should work for simple low-pass filters (taken from http://en.wikipedia.org/wiki/Low-pass_filter#Algorithmic_implementation), but the general formula may be required for high sloped ones.

y[n] = y[n-1] + a * (x[n] - y[n-1])