DSPRelated.com
Forums

Anti Aliasing of Arbitrary Waveforms

Started by Scott Gravenhorst September 23, 2008
Tim Wescott  <tim@seemywebsite.com> wrote:

>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.
>I disagree with your conclusion -- I think it's aliasing.
It could be, if there's a change in sample rate. i.e. if he synthesizes his sawtooth at 800 Ksamples/sec, then downsamples to 200 Ksamples/sec. But if he's synthesizing his sawtooth at 200 KHz/sec and there are otherwise no changes in sample rate between waveform sysnthesis and DAC, it cannot be 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.
Yep. Steve
On Tue, 23 Sep 2008 12:10:13 -0700, Tim Wescott <tim@seemywebsite.com>
wrote:

>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.
The siren effect is always the same proportion of total output signal regardless of the amplitude of the naive sawtooth.
>-- > >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 <no.spam@gte.net> wrote:

>On Tue, 23 Sep 2008 12:10:13 -0700, Tim Wescott <tim@seemywebsite.com> >wrote:
>>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.
>The siren effect is always the same proportion of total output signal >regardless of the amplitude of the naive sawtooth.
Okay, then describe for us the sample rates used in the entire chain of signals, from waveform generator to DAC. Steve
On Sep 23, 3:01&#4294967295;pm, spop...@speedymail.org (Steve Pope) wrote:
> Scott Gravenhorst <no.s...@gte.net> wrote: > >On Tue, 23 Sep 2008 18:00:16 +0000 (UTC), spop...@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. &#4294967295;There is a fast > >transient when it resets. &#4294967295;The frequency of the sawtooth is swept at a > >rather slow rate by increasing or decreasing the phase increment > >amount. &#4294967295;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. &#4294967295;The siren effect is very apparent and I was told that this > >is aliasing. &#4294967295;I also read onwww.dspguide.comthat any internally > >generated "naive" waveform such as sawtooth or pulse that contains > >transients will, in fact, exhibit aliasing. &#4294967295;This effect is most > >profound above 5 KHz. &#4294967295;The sample rate is fixed at 200 KHz. > > You are not hearing aliasing. &#4294967295;You are hearing correlated > quantization noise.
With all due respect, sir, bullswool. A continuous sawtooth contains harmonics of strength inversely proportional to the square of the harmonic number (the fundamental being the "first harmonic") that extend out to infinity. Discrete time slightly modifies the harmonic stricture in detail in, but is remains substantially the same generally.
> &#4294967295;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. &#4294967295; 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. &#4294967295;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. &#4294967295;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.
That too, but I think the effect is small. To check, assemble the waveform from the computed harmonics up to Fs/2 (100 MHz) but no higher. A plot will show serious Gibbs ringing but no aliasing. Applying a window to the harmonic coefficients will reduce the ringing and increase the flyback tine. Jerry
On Tue, 23 Sep 2008 19:20:05 +0000 (UTC), spope33@speedymail.org
(Steve Pope) wrote:

>Scott Gravenhorst <no.spam@gte.net> wrote: > >>On Tue, 23 Sep 2008 12:10:13 -0700, Tim Wescott <tim@seemywebsite.com> >>wrote: > >>>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. > >>The siren effect is always the same proportion of total output signal >>regardless of the amplitude of the naive sawtooth. > >Okay, then describe for us the sample rates used in the entire >chain of signals, from waveform generator to DAC.
The sawtooth (a test waveform that contains a transient) is generated using a phase accumulator "oscillator". This is a digital adder and register (I'm using an FPGA) where the adder's output is registered and coupled back to one of it's inputs. The adder's other input has a value called the phase increment. If the phase increment's value is constant, the output of the adder is a sawtooth of a constant fundamental frequency. If the phase increment value is increased, the fundamental frequency of the sawtooth is increased. I realize that this is a naive method for generating a sawtooth and that bandlimited sawtooth generators can be made, but this is a test for an alias reducing method. The actual signal in the end application will be arbitary, but cyclic. One signal type might be granular synthesis, but there can be others and any/all of them can generate transients which will give rise to an infinite series of harmonics. The described adder/register structure is clocked at 200KHz and only at 200KHz. For this test, the fundamental frequency of the sawtooth is varied only by changing the phase increment value applied to one of the adder's inputs.
On Sep 23, 2:00&#4294967295;pm, 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? &#4294967295;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? &#4294967295;I know about BLIT and > >it won't be appropriate for completely arbitrary waveforms. &#4294967295;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. &#4294967295;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. &#4294967295;My > >sample rate is 200KHz, expected range of frequency for the arbitrary > >waveforms is 0Hz to 10KHz. > > >Do I need more poles? &#4294967295; > >A different Fc? &#4294967295; > >More oversampling? &#4294967295; > >Or do I need a completely different method? &#4294967295; > > 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. &#4294967295;If your sample > rate is always 200 KHz, and never higher or lower, there is > no aliasing in your system. &#4294967295;Possibly you are hearing some other > artifact instead. > > Steve
Jerry Avins  <jya@ieee.org> wrote:

>On Sep 23, 3:01&#4294967295;pm, spop...@speedymail.org (Steve Pope) wrote:
>> You are not hearing aliasing. &#4294967295;You are hearing correlated >> quantization noise.
>With all due respect, sir, bullswool. A continuous sawtooth contains >harmonics of strength inversely proportional to the square of the >harmonic number (the fundamental being the "first harmonic") that >extend out to infinity. Discrete time slightly modifies the harmonic >stricture in detail in, but is remains substantially the same >generally.
The "extend out to infinity" part doesn't seem right. A discrete-time, sampled sawtooth waveform, like any waveform of the same sample rate, contains frequency components up to Fs/2, and above that exhibits an aliased version of the frequency components below Fs/2. Harmonics above Fs/2 that would be present in a continuous-time version of the sawtooth are not present. Steve
On Tue, 23 Sep 2008 19:35:25 GMT, no.spam@gte.net (Scott Gravenhorst)
wrote:

>On Tue, 23 Sep 2008 19:20:05 +0000 (UTC), spope33@speedymail.org >(Steve Pope) wrote: > >>Scott Gravenhorst <no.spam@gte.net> wrote: >> >>>On Tue, 23 Sep 2008 12:10:13 -0700, Tim Wescott <tim@seemywebsite.com> >>>wrote: >> >>>>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. >> >>>The siren effect is always the same proportion of total output signal >>>regardless of the amplitude of the naive sawtooth. >> >>Okay, then describe for us the sample rates used in the entire >>chain of signals, from waveform generator to DAC. > >The sawtooth (a test waveform that contains a transient) is generated >using a phase accumulator "oscillator". This is a digital adder and >register (I'm using an FPGA) where the adder's output is registered >and coupled back to one of it's inputs. The adder's other input has a >value called the phase increment. > >If the phase increment's value is constant, the output of the adder is >a sawtooth of a constant fundamental frequency. If the phase >increment value is increased, the fundamental frequency of the >sawtooth is increased. > >I realize that this is a naive method for generating a sawtooth and >that bandlimited sawtooth generators can be made, but this is a test >for an alias reducing method. The actual signal in the end >application will be arbitary, but cyclic. One signal type might be >granular synthesis, but there can be others and any/all of them can >generate transients which will give rise to an infinite series of >harmonics. The described adder/register structure is clocked at >200KHz and only at 200KHz. For this test, the fundamental frequency >of the sawtooth is varied only by changing the phase increment value >applied to one of the adder's inputs.
Sorry, forgot to add that the DAC is also updated at 200KHz. The basic alias test is the naive sawtooth generator clocked at 200KHz connected to the DAC which is also updated at 200 KHz (using the same clock for both).
>
On Tue, 23 Sep 2008 12:11:09 -0700, Tim Wescott <tim@seemywebsite.com>
wrote:

>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. >
Thanks, I'll take some time to digest that. Looks very interesting.
> >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
On Sep 23, 2:00&#4294967295;pm, 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? &#4294967295;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? &#4294967295;I know about BLIT and > >it won't be appropriate for completely arbitrary waveforms. &#4294967295;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. &#4294967295;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. &#4294967295;My > >sample rate is 200KHz, expected range of frequency for the arbitrary > >waveforms is 0Hz to 10KHz. > > >Do I need more poles? &#4294967295; > >A different Fc? &#4294967295; > >More oversampling? &#4294967295; > >Or do I need a completely different method? &#4294967295; > > 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. &#4294967295;If your sample > rate is always 200 KHz, and never higher or lower, there is > no aliasing in your system. &#4294967295;Possibly you are hearing some other > artifact instead.
Please excuse the blank post. Technically, you are correct. If you generate a waveform from a formula, then there can be no aliasing. It is, however, unlikely to be the waveform you expect. Consider this sequence of samples: MAX MAX MAX MIN MIN MIN [repeat]. Since it is generated digitally, it has, by definition, no component frequencies above fs/2. At first sight, it appears to be a square wave at fs/6, but that is impossible. Such a square wave consists of 4/pi*[sin(fs/6) + 1/3*sin(fs/2) + 1/5*sin(5*fs/6) + ...). The specified sequence will be nothing like that. Jerry