DSPRelated.com
Forums

Anti Aliasing of Arbitrary Waveforms

Started by Scott Gravenhorst September 23, 2008
On Sep 25, 9:12&#4294967295;am, Martin Eisenberg <martin.eisenb...@udo.edu> wrote:
> jim wrote: > > Martin Eisenberg wrote: > >> jim wrote: > > >> > Sampling it at a higher rate and smoothing out those > >> > kinks will help a little. But a better way IMO would be > >> > to only change the rate at the beginning of a wave form. > > >> That is, at a waveform peak so that the first derivative will > >> be continuous. > > I should have written "at a critical point". > > > Do you mean "so that the first difference will be constant" > > There is no first dirivative it is a digital signal. > > No, I mean the derivative of the formula Scott is sampling. Changing > frequency at a zero crossing of the signal puts a step in the first > derivative. Changing at a zero of the signal derivative, the step is > only in the second derivative. That means the step's contribution to > the noise floor, which gets sampled along with everything else, falls > off at 18 dB/oct (and more at saddle points) instead of 12 dB/oct. > > Of course, the sawtooth Scott is currently testing with doesn't have > any critical points.
Quite so, but where in a sawtooth is the derivative zero? Jerry
Eric Jacobsen <eric.jacobsen@ieee.org> writes:
> [...] > One of the things I'm trying to get my head around through this > discussion and relevant discussions is how generating the sawtooth at > a higher sample rate and then bandlimiting is different than > generating it at a bit lower frequency and then bandlimiting. What > would be the difference between two sawtooth waveforms bandlimited to, > e.g., 20kHz at the same sample rate, with one generated at 1MHz and > one generated at 200kHz? > > Done correctly, I think, aliasing wouldn't come into play in either > case.
I think it does, but I can't prove it right now. The notion is that the nonlinear function is applied as though the signal was analog, so it generates harmonics. If the sample rate isn't high enough, many of those harmonics alias back into the Nyquist bandwidth. If the sample rate is higher, the harmonics are properly represented up to the Nyquist frequency, THEN start aliasing back in, and since most harmonics decrease with increasing frequency, much less energy gets aliased back in at this higher sample rate. Then when you filter and decimate back to the original sample rate, the properly-generated harmonics are filtered out and the residual aliased energy is much lower than if you hadn't upsampled. Does that make sense? -- % Randy Yates % "So now it's getting late, %% Fuquay-Varina, NC % and those who hesitate %%% 919-577-9882 % got no one..." %%%% <yates@ieee.org> % 'Waterfall', *Face The Music*, ELO http://www.digitalsignallabs.com
Richard Dobson wrote:

> If we use direect computation, we find that we really > cannot get away with single (32bit) precision, as over time the > nominally tiny phase accumulation errors do accumulate, such > that what starts as a clean-looking sawtooth transmogrifies > after half an hour or so into some very different shape. Still > sounds the same, but we want the shape too.
Numerical analysis has methods to keep track of and resum rounding errors. I seem to remember reports here in the past of good results from the recursive boxcar FIR (or perhaps Goertzel) using Kahan summation -- though that term wasn't used so I can't find the post. Has anyone looked into error resumming in phase accumulators? Martin -- The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" but "That's funny..." --Isaac Asimov
Randy Yates  <yates@ieee.org> wrote:

>Eric Jacobsen <eric.jacobsen@ieee.org> writes: >> [...] >> Done correctly, I think, aliasing wouldn't come into play in either >> case.
>I think it does, but I can't prove it right now.
>The notion is that the nonlinear function is applied as though the >signal was analog, so it generates harmonics. If the sample rate isn't >high enough, many of those harmonics alias back into the Nyquist >bandwidth. If the sample rate is higher, the harmonics are properly >represented up to the Nyquist frequency, THEN start aliasing back in, >and since most harmonics decrease with increasing frequency, much less >energy gets aliased back in at this higher sample rate. > >Then when you filter and decimate back to the original sample rate, the >properly-generated harmonics are filtered out and the residual aliased >energy is much lower than if you hadn't upsampled.
>Does that make sense?
Makes sense to me. I'd probably say, as an additional description, that the sampled- data sawtooth has energy everywhere up to Fs/2, in the general case, and if you don't like that energy profile (due to its audible characteristics) you should do something about it. Steve
On Thu, 25 Sep 2008 09:43:57 -0400, Randy Yates <yates@ieee.org>
wrote:

>Eric Jacobsen <eric.jacobsen@ieee.org> writes: >> [...] >> One of the things I'm trying to get my head around through this >> discussion and relevant discussions is how generating the sawtooth at >> a higher sample rate and then bandlimiting is different than >> generating it at a bit lower frequency and then bandlimiting. What >> would be the difference between two sawtooth waveforms bandlimited to, >> e.g., 20kHz at the same sample rate, with one generated at 1MHz and >> one generated at 200kHz? >> >> Done correctly, I think, aliasing wouldn't come into play in either >> case. > >I think it does, but I can't prove it right now. > >The notion is that the nonlinear function is applied as though the >signal was analog, so it generates harmonics. If the sample rate isn't >high enough, many of those harmonics alias back into the Nyquist >bandwidth. If the sample rate is higher, the harmonics are properly >represented up to the Nyquist frequency, THEN start aliasing back in, >and since most harmonics decrease with increasing frequency, much less >energy gets aliased back in at this higher sample rate. > >Then when you filter and decimate back to the original sample rate, the >properly-generated harmonics are filtered out and the residual aliased >energy is much lower than if you hadn't upsampled. > >Does that make sense?
That is how I understand it. As was already pointed out, I need to seriously increase my upsampling (or simply generate my arbitrary waveform at a much higher sample rate than my DAC's).
On Sep 25, 9:43&#4294967295;am, Randy Yates <ya...@ieee.org> wrote:
> Eric Jacobsen <eric.jacob...@ieee.org> writes: > > [...] > > One of the things I'm trying to get my head around through this > > discussion and relevant discussions is how generating the sawtooth at > > a higher sample rate and then bandlimiting is different than > > generating it at a bit lower frequency and then bandlimiting. &#4294967295; &#4294967295;What > > would be the difference between two sawtooth waveforms bandlimited to, > > e.g., 20kHz at the same sample rate, &#4294967295;with one generated at 1MHz and > > one generated at 200kHz? > > > Done correctly, I think, aliasing wouldn't come into play in either > > case. > > I think it does, but I can't prove it right now. > > The notion is that the nonlinear function is applied as though the > signal was analog, so it generates harmonics. If the sample rate isn't > high enough, many of those harmonics alias back into the Nyquist > bandwidth. If the sample rate is higher, the harmonics are properly > represented up to the Nyquist frequency, THEN start aliasing back in, > and since most harmonics decrease with increasing frequency, much less > energy gets aliased back in at this higher sample rate. > > Then when you filter and decimate back to the original sample rate, the > properly-generated harmonics are filtered out and the residual aliased > energy is much lower than if you hadn't upsampled. > > Does that make sense?
Of course it makes sense. I'm at a loss to see why this isn't obvious to everyone involved. I was wrong when I wrote earlier about the number of harmonics needed to represent a sawtooth. I had in mind a triangle wave (square wave integrated). A sawtooth needs significantly more if the sharp transition is to be represented reasonably well. Jerry
On Thu, 25 Sep 2008 09:43:57 -0400, Randy Yates <yates@ieee.org>
wrote:

>Eric Jacobsen <eric.jacobsen@ieee.org> writes: >> [...] >> One of the things I'm trying to get my head around through this >> discussion and relevant discussions is how generating the sawtooth at >> a higher sample rate and then bandlimiting is different than >> generating it at a bit lower frequency and then bandlimiting. What >> would be the difference between two sawtooth waveforms bandlimited to, >> e.g., 20kHz at the same sample rate, with one generated at 1MHz and >> one generated at 200kHz? >> >> Done correctly, I think, aliasing wouldn't come into play in either >> case. > >I think it does, but I can't prove it right now. > >The notion is that the nonlinear function is applied as though the >signal was analog, so it generates harmonics.
By "nonlinear function" do you just mean sampling?
>If the sample rate isn't >high enough, many of those harmonics alias back into the Nyquist >bandwidth. If the sample rate is higher, the harmonics are properly >represented up to the Nyquist frequency, THEN start aliasing back in, >and since most harmonics decrease with increasing frequency, much less >energy gets aliased back in at this higher sample rate. > >Then when you filter and decimate back to the original sample rate, the >properly-generated harmonics are filtered out and the residual aliased >energy is much lower than if you hadn't upsampled. > >Does that make sense?
Thanks, I think the lights just came on for me. That sort of bends the notion of aliasing as distortion, since it seems to suggest that a properly represented numerical sawtooth has the aliased energy built-in. It still makes me wonder what differences one would see between two similarly bandlimited sawtooth waveforms sampled at the same rate but generated from differently oversampled sources. If both waves are phase-accumulated and accurately reproduced waves, does removing the aliased harmonics from one make it more "distorted" now (when viewed as a trace)? The differences must be subtle, I think. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.ericjacobsen.org Blog: http://www.dsprelated.com/blogs-1/hf/Eric_Jacobsen.php

Eric Jacobsen wrote:
> > On Thu, 25 Sep 2008 09:43:57 -0400, Randy Yates <yates@ieee.org> > wrote: > > >Eric Jacobsen <eric.jacobsen@ieee.org> writes: > >> [...] > >> One of the things I'm trying to get my head around through this > >> discussion and relevant discussions is how generating the sawtooth at > >> a higher sample rate and then bandlimiting is different than > >> generating it at a bit lower frequency and then bandlimiting. What > >> would be the difference between two sawtooth waveforms bandlimited to, > >> e.g., 20kHz at the same sample rate, with one generated at 1MHz and > >> one generated at 200kHz? > >> > >> Done correctly, I think, aliasing wouldn't come into play in either > >> case. > > > >I think it does, but I can't prove it right now. > > > >The notion is that the nonlinear function is applied as though the > >signal was analog, so it generates harmonics. > > By "nonlinear function" do you just mean sampling? > > >If the sample rate isn't > >high enough, many of those harmonics alias back into the Nyquist > >bandwidth. If the sample rate is higher, the harmonics are properly > >represented up to the Nyquist frequency, THEN start aliasing back in, > >and since most harmonics decrease with increasing frequency, much less > >energy gets aliased back in at this higher sample rate. > > > >Then when you filter and decimate back to the original sample rate, the > >properly-generated harmonics are filtered out and the residual aliased > >energy is much lower than if you hadn't upsampled. > > > >Does that make sense? > > Thanks, I think the lights just came on for me. > > That sort of bends the notion of aliasing as distortion, since it > seems to suggest that a properly represented numerical sawtooth has > the aliased energy built-in. It still makes me wonder what > differences one would see between two similarly bandlimited sawtooth > waveforms sampled at the same rate but generated from differently > oversampled sources. If both waves are phase-accumulated and > accurately reproduced waves, does removing the aliased harmonics from > one make it more "distorted" now (when viewed as a trace)? > > The differences must be subtle, I think.
There is no difference when the waveform is static (at least there shouldn't be if its done correctly and there is insignificant quantization error). The distortion only comes in when you start peicing together wave forms of different amplitude or frequency. That's when oversampling can make a difference. -jim
> > Eric Jacobsen > Minister of Algorithms > Abineau Communications > http://www.ericjacobsen.org > > Blog: http://www.dsprelated.com/blogs-1/hf/Eric_Jacobsen.php
----== 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 =---

Jerry Avins wrote:

> > I was wrong when I wrote earlier about the number of harmonics needed > to represent a sawtooth. I had in mind a triangle wave (square wave > integrated). A sawtooth needs significantly more if the sharp > transition is to be represented reasonably well.
At 5khz the OP has around 40 samples per period in his sawtooth waveformat the sample rate he is working at. Above 5khz most people can't hear the difference between a sawtooth and sine wave anyway. -jim ----== 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 Thu, 25 Sep 2008 11:11:13 -0500, jim <".sjedgingN0sp"@m@mwt.net>
wrote:

> > >Eric Jacobsen wrote: >> >> On Thu, 25 Sep 2008 09:43:57 -0400, Randy Yates <yates@ieee.org> >> wrote: >> >> >Eric Jacobsen <eric.jacobsen@ieee.org> writes: >> >> [...] >> >> One of the things I'm trying to get my head around through this >> >> discussion and relevant discussions is how generating the sawtooth at >> >> a higher sample rate and then bandlimiting is different than >> >> generating it at a bit lower frequency and then bandlimiting. What >> >> would be the difference between two sawtooth waveforms bandlimited to, >> >> e.g., 20kHz at the same sample rate, with one generated at 1MHz and >> >> one generated at 200kHz? >> >> >> >> Done correctly, I think, aliasing wouldn't come into play in either >> >> case. >> > >> >I think it does, but I can't prove it right now. >> > >> >The notion is that the nonlinear function is applied as though the >> >signal was analog, so it generates harmonics. >> >> By "nonlinear function" do you just mean sampling? >> >> >If the sample rate isn't >> >high enough, many of those harmonics alias back into the Nyquist >> >bandwidth. If the sample rate is higher, the harmonics are properly >> >represented up to the Nyquist frequency, THEN start aliasing back in, >> >and since most harmonics decrease with increasing frequency, much less >> >energy gets aliased back in at this higher sample rate. >> > >> >Then when you filter and decimate back to the original sample rate, the >> >properly-generated harmonics are filtered out and the residual aliased >> >energy is much lower than if you hadn't upsampled. >> > >> >Does that make sense? >> >> Thanks, I think the lights just came on for me. >> >> That sort of bends the notion of aliasing as distortion, since it >> seems to suggest that a properly represented numerical sawtooth has >> the aliased energy built-in. It still makes me wonder what >> differences one would see between two similarly bandlimited sawtooth >> waveforms sampled at the same rate but generated from differently >> oversampled sources. If both waves are phase-accumulated and >> accurately reproduced waves, does removing the aliased harmonics from >> one make it more "distorted" now (when viewed as a trace)? >> >> The differences must be subtle, I think. > >There is no difference when the waveform is static (at least there shouldn't be >if its done correctly and there is insignificant quantization error). The >distortion only comes in when you start peicing together wave forms of different >amplitude or frequency. That's when oversampling can make a difference. > >-jim
That seems to thicken the plot, since it seems that the OP is claiming problems for the static case. His described methodology for sweeping the frequency is pretty good, too. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.ericjacobsen.org Blog: http://www.dsprelated.com/blogs-1/hf/Eric_Jacobsen.php