DSPRelated.com
Forums

Anti Aliasing of Arbitrary Waveforms

Started by Scott Gravenhorst September 23, 2008
On Tue, 23 Sep 2008 22:55:00 +0000 (UTC), spope33@speedymail.org
(Steve Pope) wrote:

>Vladimir Vassilevsky <antispam_bogus@hotmail.com> wrote: > >>Steve Pope wrote: > >>> The salient problem here seems to be that that the original >>> waveform, before upsampling/filtering/downsampling, >>> *already contains* the "inharmonics" that are resulting >>> in the audible artifact. They are already below the cutoff frequency >>> of the LPF, they are already in the passband, and so they cannot be >>> filtered out. > >>> This is why it would be helpful to synthesize the target >>> waveform at a higher sample rate to begin with. > >>The problem is known to anyone who dealt with the nonlinear functions in >>the sampled domain. Oversampling is the brute force way; there are more >>elegant methods if either the input signal or the nonlinearity can be >>represented as the analytical functions. > >Sure, but at this stage the OP needs to identify the source >of his problem. This usually means implementing and testing >the straightforward solution, prior to looking for elegant >approaches. > >Steve
Thank you Steve. Yes, I am trying to learn something here. I apologize to Vladimir for not knowing what he does. I invite him to ignore the rest of this thread. -- Scott
On Tue, 23 Sep 2008 11:59:04 -0700 (PDT), robert bristow-johnson
<rbj@audioimagination.com> wrote:

>On Sep 23, 1:35&#4294967295;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? &#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. > >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.) > >> &#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; >> > >you need way more upsampling. (that's equivalent to a densely sampled >interpolation kernel.)
Thank you. That's what I'm looking for.
>> 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?
Not sure exactly what that is, I know what windowed sinc filter is, but "brickwall"? - do you mean huge filter kernel as in tens of thousands of samples? I'm going by what I read in the www.dspguide.com documents that Chebyshev and Windowed sinc filters are both ways of separating one band of frequencies from another and that Windowed sinc requires more computational resources than Chebyshev and that Chebyshev can have "reasonable" performance. I thought that I'd start with Chebyshev because if I find that it's performance is acceptable (i.e., the method reduces aliasing to inaudible) then I can use the remaining computational resources for the other things I want the application to do (rather than using them for a Windowed sinc filter).
glen herrmannsfeldt  <gah@ugcs.caltech.edu> wrote:

>Steve Pope wrote:
>> Then you are not seeing any aliaising. For aliasing to happen, >> you need either a change in sample rate, or a sampling of >> an analog signal.
>Similar to what Jerry said, but in different words, >he is sampling an analog signal.
Nope. There are analog signals that, if they were sampled, would give him the same sampled signal he's using. That's not the same thing as "sampling an analog signal".
>He is sampling an analog sawtooth wave, maybe drawn on >paper or maybe just imagining it, but sampling it >in any case.
Meaningless. Give me a sampled-data signal that has been synthesized by whatever means, and I will give you an infinite number of analog signals that *could* have been sampled to create the sampled signal. But their existence has no bearing on its analysis. Steve
Steve Pope wrote:
(snip)

> Then you are not seeing any aliaising. For aliasing to happen, > you need either a change in sample rate, or a sampling of > an analog signal.
Similar to what Jerry said, but in different words, he is sampling an analog signal. He is sampling an analog sawtooth wave, maybe drawn on paper or maybe just imagining it, but sampling it in any case. -- glen
On Sep 23, 1:09&#4294967295;pm, no.s...@gte.net (Scott Gravenhorst) wrote:
> On Tue, 23 Sep 2008 20:04:39 +0000 (UTC), spop...@speedymail.org > > >What's an inharmonic partial? > > An aliased harmonic that doesn't fold back to a frequency that is > already part of the waveform's spectrum. &#4294967295;Inharmonic partials are > sinewave components that aren't part of the original waveform's > infinite series, so they sound bad.
Depends on how inharmonic. Slight inharmonicity may even make an instrument sound "better". Most large stringed instruments produce inharmonic partials, and real stringed instruments are usually thought to sound better than generic non-sampled synthesizers. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html
Scott Gravenhorst wrote:

> Right, the purpose of my practical experiment is to see how well > upsample-filter-downsample reduces aliasing and what the realistic > parameters are to do that at a "good enough" level.
The upsample, non-linear processing, downsample approach really only works if your non-linear processing is also band limited. An example of band-limited non-linear processing would be waveshaping using a polynomial. In the case of an Nth order polynomial, the band limit is N times the band width of the source signal. The problem is that your sawtooth is not anywhere near band limited.
>>It would >>be theoretically possible to reduce the alias components by >>applying a filter that allows through the harmonic components >>and attenuates the alias components, but I suspect that is >>too hard for you FPGA. > > Because the computational load is too large?
Well, there are a couple of problems: - The filter design is difficult. You require a filter that attenuates everywhere except where your desired harmonics are. Ie if the sawtooth is at fs, it will have harmonics at fs/3, fs/5 and so on. Your filter needs to pass these frequencies but attenuated frequencies in bands like (fs+epsilon)/3 to (fs-epsilong)/5, (fs+epsilon)/5 to (fs-epsilong)/7 an so on. - Not only is the filter difficult to design, it also needs to change its frequency response as you change the frequency of the generated sawtooth. Quite honestly, I think doing the above is great in theory, but in practice is probably a couple of orders of magnitude more difficult than generating a band limited signal to begin with.
>>BTW, I am a lurker on the FPGA Synth mailing list. > > (c; so you've seen some of the whacky stuff I've done.
Yes :-) Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "I ran it on my DeathStation 9000 and demons flew out of my nose." --Kaz
Steve Pope wrote:

> Erik de Castro Lopo <nospam@mega-nerd.com> wrote: > >>He isn't sampling an analog signal, but he is sampling a >>continuous time mathematical expression describing a >>sawtooth. Hence aliasing. > > I can see this, however I do not consider it correct usage > of "aliasing".
The "bad" frequency components generated mathematically are identical to the ones generated by sampling the ideal analogue waveform. They may not be aliasing, but they are aliasing components or aliasing artifacts (aliasing for short :-) ). Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "Ever since GNOME development began, I have urged people to aim to make it as good as the Macintosh. To try to be like Windows is to try for second-best." - Richard Stallman
Erik de Castro Lopo  <nospam@mega-nerd.com> wrote:

>Steve Pope wrote:
>> Erik de Castro Lopo <nospam@mega-nerd.com> wrote:
>>>He isn't sampling an analog signal, but he is sampling a >>>continuous time mathematical expression describing a >>>sawtooth. Hence aliasing.
>> I can see this, however I do not consider it correct usage >> of "aliasing".
>The "bad" frequency components generated mathematically are >identical to the ones generated by sampling the ideal analogue >waveform.
>They may not be aliasing, but they are aliasing components >or aliasing artifacts (aliasing for short :-) ).
You can choose to use the term this way, but for me it is going in the wrong direction -- aliasing is a specific phenomenom that occurs only when you sample one signal to produce another signal, and is not simply a way to complain about the characteristics of a signal you've generated from no signal. Steve
On Sep 23, 1:36 pm, spop...@speedymail.org (Steve Pope) wrote:
> ... > I can see why there's confusion over the term "aliasing". > This paper uses "aliasing" as a catch-all for undesired > characteristics of a discrete-time waveform such as a sawtooth... > even if one never downsampled, other than perhaps conceptually. > > Steve
The ideal (continuous) waveform has infinitely many samples. The discrete waveform generated has a finite number per unit time. That's as real a downsampling as any other as far as aliasing is concerned. The same thing happens in an A to D converter. All it takes is sampling to get aliasing, no 'down' required. Dale B. Dalrymple

Scott Gravenhorst wrote:

> >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.
No that won't help. The best that will do is nothing - the worst would be to add more aliasing. It still isn't clear to me how you get your signal, but that is probably where you need to look for a solution. Starting with a high sample rate and then filtering and decimating may help. Upsampling an already affected signal and then downsampling is pointless. -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 =---