[sdiy] Digital filtering (Oversampling and downsampling)
cheater cheater
cheater00 at gmail.com
Mon Aug 3 18:29:06 CEST 2009
Oversampling in itself doesn't help with aliasing at all. It's band
limiting that does.
It's a convenient coincidence that oversampling one part of an
algorithm will mean that the input signal's upper limit, which doesn't
change, starts falling inside the bandwidth which is supported by the
algorithm that you started oversampling, at the certain sample rate
which you oversampled to.
But any algorithm that has a defined supported input bandwidth will
start having problems if you feed it a signal that's too wide-band.
To give you an example, let's say you have a ring modulator R. It has
two inputs, A and B, and the output, Y.
Y = R(A, B)
The highest frequency that can happen in Y is the sum of the highest
frequencies that will happen in A and B respectively. So if both A and
B are at fs=48k, then naturally they're band-limited to 24k, and Y can
have its highest component at 48k. Oversampling R at 2x will mean that
your algorithm will not alias. But it's because A and B are
bandlimited below 1/2 the nyquist frequency of R. For other
algorithms, you could get other band limiting requirements.
If you oversample R to 2x your system's sampling frequency, but end up
oversampling A and B as well, without band-limiting them at the input
to R, then you can easily get aliasing.
HTH
D.
On Mon, Aug 3, 2009 at 4:59 PM, Tom Wiltshire<tom at electricdruid.net> wrote:
> Hi All,
>
> I'm currently doing quite a lot of experiments with digital filtering, which
> I only recently worked out how to do.
>
> The biggest problem with cheap digital systems (like dsPIC) for synths is
> aliasing. Fans of PPG aside, most people think aliasing is objectionable,
> and I agree with them. No birdies in my synth, please. I'll be pretty lucky
> to get rid of them completely, but hey, y'gotta try.
>
> One technique for reducing aliasing is to use oversampling. The general
> scheme is to run the system with an internal sample rate that is some
> multiple of the final output rate. For example, with a 48KHz output rate,
> you could run your sound generation algorithm at 384KHz for x8 oversampling.
> Whilst even a rate this fast won't remove all your problems (the 100th
> harmonic of a ramp wave at the highest MIDI note is over 1MHz) it will
> certainly help. As long as what you're doing is simple enough that you can
> do it eight times, rather than just once, in the time you have between your
> output samples, then you're fine. This might be true for fairly
> straightforward algorithms like sine FM or perhaps wavetable oscillators.
>
> The final part of an oversampling system is to reduce the internal sample
> rate for output. This is done by applying a digital filter to remove any
> unwanted high frequency content (remember that a signal with a sample rate
> of 384KHz could have frequencies up to 192KHz) and then chucking away most
> of the samples (7 out of 8 to get from 384 to 48KHz). This combination of
> filtering and decimation is called "downsampling".
>
> This downsampling filter seems to be where most of the problems are. It
> makes sense to have a fairly low final output sample rate, since that give
> me longest between output samples to generate my signal. Let's stick with
> 48KHz for the sake of argument. I need the downsampling filter to provide
> significant attenuation by 24KHz to avoid aliasing in the decimation step;
> say -80dB, but you choose a level. If I roll the downsampling filter off at
> about 20KHz, I'm left needing a very steep slope, since I want to pass
> 20KHz, but completely block 24KHz and above. This requires a complex digital
> filter with a lot of coefficients and a lot of calculating.
>
> If instead I choose a higher output sample rate, I can relax the
> downsampling filter specification. Let's try 96KHz. Now I want to pass
> 20KHz, and I need significant attenuation by Fs/2=48KHz. This gives me 28KHz
> for the transition band of the filter, rather than 4KHz. This is much less
> demanding and can be done with fewer coefficients and calculated quicker.
> Now we only have to generate half as many samples to get up to our
> oversampled rate of 384KHz (now we're oversampling at x4 not x8). We've got
> half as much time to do it, but we can finish up with less-than-half as much
> to do, since the downsampling filter can be much simpler.
>
> This means that sometimes it seems to actually be *easier* to run with a
> faster sample rate.
>
> Is this really true? How far does this go? Would I do better still trying to
> run at 192KHz?
>
> Balancing these competing demands without a lot of previous experience seems
> to be very difficult and very much an art not a science. If anyone has any
> useful experience or pointers to offer, I'd be grateful for any help I can
> get.
>
> Thanks,
> Tom
>
>
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
>
More information about the Synth-diy
mailing list