Forums

Anti Aliasing of Arbitrary Waveforms

Started by Scott Gravenhorst September 23, 2008
What are the common method(s) for preventing aliasing of arbitrary
waveforms generated within a DSP application?  I understand that
waveforms supplied as analog signals and presented to an ADC must
first be lowpass filtered to remove harmonics above the Nyquist
frequency, but what about generated waveforms?  I know about BLIT and
it won't be appropriate for completely arbitrary waveforms.  I'm
currently experimenting with a Chebyshev filter by upsampling (2:1),
filtering at Fc of 0.25, then decimating (1:2), but I'm still hearing
aliasing.  The filter I'm using is 8 poles, 0.5% ripple, but I don't
hear a difference between the unfiltered and the filtered signals.  My
sample rate is 200KHz, expected range of frequency for the arbitrary
waveforms is 0Hz to 10KHz.

Do I need more poles?  
A different Fc?  
More oversampling?  

Or do I need a completely different method?  

I looked a windowed sinc filters, but I also read that Chebyshev is
supposed to be quite good, but with much lower computational needs.

Many thanks.

Scott Gravenhorst <no.spam@gte.net> wrote:

>What are the common method(s) for preventing aliasing of arbitrary >waveforms generated within a DSP application? I understand that >waveforms supplied as analog signals and presented to an ADC must >first be lowpass filtered to remove harmonics above the Nyquist >frequency, but what about generated waveforms? I know about BLIT and >it won't be appropriate for completely arbitrary waveforms. I'm >currently experimenting with a Chebyshev filter by upsampling (2:1), >filtering at Fc of 0.25, then decimating (1:2), but I'm still hearing >aliasing. The filter I'm using is 8 poles, 0.5% ripple, but I don't >hear a difference between the unfiltered and the filtered signals. My >sample rate is 200KHz, expected range of frequency for the arbitrary >waveforms is 0Hz to 10KHz. > >Do I need more poles? >A different Fc? >More oversampling?
>Or do I need a completely different method?
What exactly do mean by "hearing aliasing"? If you are neither sampling an analog waveform, nor downsampling a digital signal, you will never get aliasing. If your sample rate is always 200 KHz, and never higher or lower, there is no aliasing in your system. Possibly you are hearing some other artifact instead. Steve
On Tue, 23 Sep 2008 18:00:16 +0000 (UTC), spope33@speedymail.org
(Steve Pope) wrote:

>Scott Gravenhorst <no.spam@gte.net> wrote: > >>What are the common method(s) for preventing aliasing of arbitrary >>waveforms generated within a DSP application? I understand that >>waveforms supplied as analog signals and presented to an ADC must >>first be lowpass filtered to remove harmonics above the Nyquist >>frequency, but what about generated waveforms? I know about BLIT and >>it won't be appropriate for completely arbitrary waveforms. I'm >>currently experimenting with a Chebyshev filter by upsampling (2:1), >>filtering at Fc of 0.25, then decimating (1:2), but I'm still hearing >>aliasing. The filter I'm using is 8 poles, 0.5% ripple, but I don't >>hear a difference between the unfiltered and the filtered signals. My >>sample rate is 200KHz, expected range of frequency for the arbitrary >>waveforms is 0Hz to 10KHz. >> >>Do I need more poles? >>A different Fc? >>More oversampling? > >>Or do I need a completely different method? > >What exactly do mean by "hearing aliasing"?
The test application is generating a "naive" sawtooth waveform using a phase accumulator which simply wraps on overflow. There is a fast transient when it resets. The frequency of the sawtooth is swept at a rather slow rate by increasing or decreasing the phase increment amount. When the frequency of the sawtooth is swept, especially at higher frequencies (eg above 1 or 2 KHz) I hear a sort of siren that goes down and then up and down and up as I sweep the sawtooth in _one_ direction. The siren effect is very apparent and I was told that this is aliasing. I also read on www.dspguide.com that any internally generated "naive" waveform such as sawtooth or pulse that contains transients will, in fact, exhibit aliasing. This effect is most profound above 5 KHz. The sample rate is fixed at 200 KHz.
> >If you are neither sampling an analog waveform, nor downsampling >a digital signal, you will never get aliasing. If your sample >rate is always 200 KHz, and never higher or lower, there is >no aliasing in your system. Possibly you are hearing some other >artifact instead. > >Steve

Scott Gravenhorst wrote:
> > On Tue, 23 Sep 2008 18:00:16 +0000 (UTC), spope33@speedymail.org > (Steve Pope) wrote: > > >Scott Gravenhorst <no.spam@gte.net> wrote: > > > >>What are the common method(s) for preventing aliasing of arbitrary > >>waveforms generated within a DSP application? I understand that > >>waveforms supplied as analog signals and presented to an ADC must > >>first be lowpass filtered to remove harmonics above the Nyquist > >>frequency, but what about generated waveforms? I know about BLIT and > >>it won't be appropriate for completely arbitrary waveforms. I'm > >>currently experimenting with a Chebyshev filter by upsampling (2:1), > >>filtering at Fc of 0.25, then decimating (1:2), but I'm still hearing > >>aliasing. The filter I'm using is 8 poles, 0.5% ripple, but I don't > >>hear a difference between the unfiltered and the filtered signals. My > >>sample rate is 200KHz, expected range of frequency for the arbitrary > >>waveforms is 0Hz to 10KHz. > >> > >>Do I need more poles? > >>A different Fc? > >>More oversampling? > > > >>Or do I need a completely different method? > > > >What exactly do mean by "hearing aliasing"? > > The test application is generating a "naive" sawtooth waveform using a > phase accumulator which simply wraps on overflow. There is a fast > transient when it resets. The frequency of the sawtooth is swept at a > rather slow rate by increasing or decreasing the phase increment > amount. When the frequency of the sawtooth is swept, especially at > higher frequencies (eg above 1 or 2 KHz) I hear a sort of siren that > goes down and then up and down and up as I sweep the sawtooth in _one_ > direction. The siren effect is very apparent and I was told that this > is aliasing. I also read on www.dspguide.com that any internally > generated "naive" waveform such as sawtooth or pulse that contains > transients will, in fact, exhibit aliasing. This effect is most > profound above 5 KHz. The sample rate is fixed at 200 KHz.
Sounds like you need anti-naive filter:^). Your description of how you acquire your signal leaves a lot to be desired. Hard to say if aliasing has anything to do with your perceived problem. But if aliasing is already present in your signal then a filter won't be able to undo it. That would be like unscrambling eggs. -jim
> > > > >If you are neither sampling an analog waveform, nor downsampling > >a digital signal, you will never get aliasing. If your sample > >rate is always 200 KHz, and never higher or lower, there is > >no aliasing in your system. Possibly you are hearing some other > >artifact instead. > > > >Steve
----== Posted via Pronews.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.pronews.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= - Total Privacy via Encryption =---
On Sep 23, 1:35&#2013266080;pm, no.s...@gte.net (Scott Gravenhorst) wrote:
> What are the common method(s) for preventing aliasing of arbitrary > waveforms generated within a DSP application? &#2013266080;I understand that > waveforms supplied as analog signals and presented to an ADC must > first be lowpass filtered to remove harmonics above the Nyquist > frequency, but what about generated waveforms? &#2013266080;I know about BLIT and > it won't be appropriate for completely arbitrary waveforms.
if the interpolation kernel is long enough and sufficiently densely sampled, i think BLIT would be good enough for non-pathological waveforms. (rich in harmonics is not pathological, but sequences like ...-1, 1, -1, 1, 1, -1, 1, -1,... are pathological.)
> &#2013266080;I'm > currently experimenting with a Chebyshev filter by upsampling (2:1), > filtering at Fc of 0.25, then decimating (1:2), but I'm still hearing > aliasing. &#2013266080;The filter I'm using is 8 poles, 0.5% ripple, but I don't > hear a difference between the unfiltered and the filtered signals. &#2013266080;My > sample rate is 200KHz, expected range of frequency for the arbitrary > waveforms is 0Hz to 10KHz. > > Do I need more poles? &#2013266080; > A different Fc? &#2013266080; > More oversampling? &#2013266080; >
you need way more upsampling. (that's equivalent to a densely sampled interpolation kernel.)
> Or do I need a completely different method?
maybe.
> I looked a windowed sinc filters, but I also read that Chebyshev is > supposed to be quite good, but with much lower computational needs.
compared to a virtual brickwall sinc-like filter? r b-j
Scott Gravenhorst <no.spam@gte.net> wrote:

>On Tue, 23 Sep 2008 18:00:16 +0000 (UTC), spope33@speedymail.org
>(Steve Pope) wrote:
>>What exactly do mean by "hearing aliasing"?
>The test application is generating a "naive" sawtooth waveform using a >phase accumulator which simply wraps on overflow. There is a fast >transient when it resets. The frequency of the sawtooth is swept at a >rather slow rate by increasing or decreasing the phase increment >amount. When the frequency of the sawtooth is swept, especially at >higher frequencies (eg above 1 or 2 KHz) I hear a sort of siren that >goes down and then up and down and up as I sweep the sawtooth in _one_ >direction. The siren effect is very apparent and I was told that this >is aliasing. I also read on www.dspguide.com that any internally >generated "naive" waveform such as sawtooth or pulse that contains >transients will, in fact, exhibit aliasing. This effect is most >profound above 5 KHz. The sample rate is fixed at 200 KHz.
You are not hearing aliasing. You are hearing correlated quantization noise. Probably, some point in your processing, you are truncating or rounding this sawtooth waveform to the precision of the data path to your DAC, without dithering. If you dither at this point, and there is no further truncation/rounding anyhere, the "siren effect" should go away. An easy way to confirm this is not aliasing is the following: if it is aliasing, you will hear the same relative "siren effect" at any signal level. If it is a quantization effect, the "siren efffect" will be much more prominent at weaker signal levels. I am almost certain that you are hearing quantization noise that is correlated to your signal and that with proper dithering this artifact goes away (although there will still be noise, it will turn into white noise and be less audible). The thing to remember is that tone-like signals, that are not dithered and which have components which are at submultiples of the sample rate, will produce audible beat frequencies which will sweep along with signal. This is not "aliasing" (mirroring around the sample rate), it is a type of intermodulation (multiplication with the sample rate), and is a quantization effect in undithered systems. Steve
On 23 Sep, 20:34, no.s...@gte.net (Scott Gravenhorst) wrote:
> On Tue, 23 Sep 2008 18:00:16 +0000 (UTC), spop...@speedymail.org > (Steve Pope) wrote: > >Scott Gravenhorst <no.s...@gte.net> wrote: > > >>What are the common method(s) for preventing aliasing of arbitrary > >>waveforms generated within a DSP application? &#2013266080;I understand that > >>waveforms supplied as analog signals and presented to an ADC must > >>first be lowpass filtered to remove harmonics above the Nyquist > >>frequency, but what about generated waveforms? &#2013266080;
What do you mean by 'generated waveforms'? Did you sample them from an (analog) signal generator or are they generated in discrete- time domain?
> The test application is generating a "naive" sawtooth waveform using a > phase accumulator which simply wraps on overflow. &#2013266080;There is a fast > transient when it resets. &#2013266080;The frequency of the sawtooth is swept at a > rather slow rate by increasing or decreasing the phase increment > amount. &#2013266080;When the frequency of the sawtooth is swept, especially at > higher frequencies (eg above 1 or 2 KHz) I hear a sort of siren that > goes down and then up and down and up as I sweep the sawtooth in _one_ > direction.
What does the audio system look like? Did you include anti-alias filters after the DAC? (They might not be called that, but you need to remove analog aliases after the DAC)
>&#2013266080;The siren effect is very apparent and I was told that this > is aliasing.
Who told you?
>&#2013266080;I also read onwww.dspguide.comthat any internally > generated "naive" waveform such as sawtooth or pulse that contains > transients will, in fact, exhibit aliasing. &#2013266080;This effect is most > profound above 5 KHz. &#2013266080;The sample rate is fixed at 200 KHz.
...which means that the component you hear, if it is indeed aliasing, originated around 395 kHz. I don't know much about audio, but it seems unlikely to me that alias from that far out should be audible. I could of course be wrong. I'd rather have a detailed look at the system and look for other causes for the 'siren' you hear, like nonlinarities somewhere. Rune
On Tue, 23 Sep 2008 13:52:33 -0500, jim <"sjedgingN0sp"@m@mwt.net>
wrote:

> > >Scott Gravenhorst wrote: >> >> On Tue, 23 Sep 2008 18:00:16 +0000 (UTC), spope33@speedymail.org >> (Steve Pope) wrote: >> >> >Scott Gravenhorst <no.spam@gte.net> wrote: >> > >> >>What are the common method(s) for preventing aliasing of arbitrary >> >>waveforms generated within a DSP application? I understand that >> >>waveforms supplied as analog signals and presented to an ADC must >> >>first be lowpass filtered to remove harmonics above the Nyquist >> >>frequency, but what about generated waveforms? I know about BLIT and >> >>it won't be appropriate for completely arbitrary waveforms. I'm >> >>currently experimenting with a Chebyshev filter by upsampling (2:1), >> >>filtering at Fc of 0.25, then decimating (1:2), but I'm still hearing >> >>aliasing. The filter I'm using is 8 poles, 0.5% ripple, but I don't >> >>hear a difference between the unfiltered and the filtered signals. My >> >>sample rate is 200KHz, expected range of frequency for the arbitrary >> >>waveforms is 0Hz to 10KHz. >> >> >> >>Do I need more poles? >> >>A different Fc? >> >>More oversampling? >> > >> >>Or do I need a completely different method? >> > >> >What exactly do mean by "hearing aliasing"? >> >> The test application is generating a "naive" sawtooth waveform using a >> phase accumulator which simply wraps on overflow. There is a fast >> transient when it resets. The frequency of the sawtooth is swept at a >> rather slow rate by increasing or decreasing the phase increment >> amount. When the frequency of the sawtooth is swept, especially at >> higher frequencies (eg above 1 or 2 KHz) I hear a sort of siren that >> goes down and then up and down and up as I sweep the sawtooth in _one_ >> direction. The siren effect is very apparent and I was told that this >> is aliasing. I also read on www.dspguide.com that any internally >> generated "naive" waveform such as sawtooth or pulse that contains >> transients will, in fact, exhibit aliasing. This effect is most >> profound above 5 KHz. The sample rate is fixed at 200 KHz. > > >Sounds like you need anti-naive filter:^). > > Your description of how you acquire your signal leaves a lot to be desired.
That part I am stuck with. Sawtooth is just an example that illustrates the problem. The end application will have to deal with completely arbitrary waveforms (think granular synthesis for example, but that is not the only method), hence I can't use techniques like BLIT.
>Hard to say if aliasing has anything to do with your perceived problem. But if >aliasing is already present in your signal then a filter won't be able to undo >it. That would be like unscrambling eggs.
Yes, that is true, I know I cannot completely eliminate the aliasing, but I was thinking that I might be able to reduce it to an acceptable level by upsampling (and interpolating) the naive signal, filtering while upsampled and then decimating the filter's output.
>-jim > > >> >> > >> >If you are neither sampling an analog waveform, nor downsampling >> >a digital signal, you will never get aliasing. If your sample >> >rate is always 200 KHz, and never higher or lower, there is >> >no aliasing in your system. Possibly you are hearing some other >> >artifact instead. >> > >> >Steve > > >----== Posted via Pronews.Com - Unlimited-Unrestricted-Secure Usenet News==---- >http://www.pronews.com The #1 Newsgroup Service in the World! >100,000 Newsgroups >---= - Total Privacy via Encryption =---
Steve Pope wrote:
> Scott Gravenhorst <no.spam@gte.net> wrote: > >> On Tue, 23 Sep 2008 18:00:16 +0000 (UTC), spope33@speedymail.org > >> (Steve Pope) wrote: > >>> What exactly do mean by "hearing aliasing"? > >> The test application is generating a "naive" sawtooth waveform using a >> phase accumulator which simply wraps on overflow. There is a fast >> transient when it resets. The frequency of the sawtooth is swept at a >> rather slow rate by increasing or decreasing the phase increment >> amount. When the frequency of the sawtooth is swept, especially at >> higher frequencies (eg above 1 or 2 KHz) I hear a sort of siren that >> goes down and then up and down and up as I sweep the sawtooth in _one_ >> direction. The siren effect is very apparent and I was told that this >> is aliasing. I also read on www.dspguide.com that any internally >> generated "naive" waveform such as sawtooth or pulse that contains >> transients will, in fact, exhibit aliasing. This effect is most >> profound above 5 KHz. The sample rate is fixed at 200 KHz. > > You are not hearing aliasing. You are hearing correlated > quantization noise. Probably, some point in your processing, you > are truncating or rounding this sawtooth waveform to the precision of > the data path to your DAC, without dithering. If you dither at > this point, and there is no further truncation/rounding anyhere, the > "siren effect" should go away. > > An easy way to confirm this is not aliasing is the following: > if it is aliasing, you will hear the same relative "siren effect" > at any signal level. If it is a quantization effect, the "siren > efffect" will be much more prominent at weaker signal levels. > > I am almost certain that you are hearing quantization noise that > is correlated to your signal and that with proper dithering > this artifact goes away (although there will still be noise, it will > turn into white noise and be less audible). > > The thing to remember is that tone-like signals, that are not > dithered and which have components which are at submultiples of the > sample rate, will produce audible beat frequencies which will sweep > along with signal. This is not "aliasing" (mirroring around > the sample rate), it is a type of intermodulation (multiplication with > the sample rate), and is a quantization effect in undithered systems. > > Steve
I disagree with your conclusion -- I think it's aliasing. But the diagnostic is the same either way -- if the effect grows or shrinks disproportionately to amplitude, then it's quantization; if it pretty much stays the same relative amplitude, then it's aliasing. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Scott Gravenhorst wrote:
> What are the common method(s) for preventing aliasing of arbitrary > waveforms generated within a DSP application? I understand that > waveforms supplied as analog signals and presented to an ADC must > first be lowpass filtered to remove harmonics above the Nyquist > frequency, but what about generated waveforms? I know about BLIT and > it won't be appropriate for completely arbitrary waveforms. I'm > currently experimenting with a Chebyshev filter by upsampling (2:1), > filtering at Fc of 0.25, then decimating (1:2), but I'm still hearing > aliasing. The filter I'm using is 8 poles, 0.5% ripple, but I don't > hear a difference between the unfiltered and the filtered signals. My > sample rate is 200KHz, expected range of frequency for the arbitrary > waveforms is 0Hz to 10KHz. > > Do I need more poles? > A different Fc? > More oversampling? > > Or do I need a completely different method? > > I looked a windowed sinc filters, but I also read that Chebyshev is > supposed to be quite good, but with much lower computational needs. > > Many thanks. >
Read this and think about what you're trying to achieve: http://www.wescottdesign.com/articles/Sampling/sampling.html. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html