DSPRelated.com
Forums

Anti Aliasing of Arbitrary Waveforms

Started by Scott Gravenhorst September 23, 2008
On Wed, 24 Sep 2008 12:43:55 -0500, jim <".sjedgingN0sp"@m@mwt.net>
wrote:

> > >Eric Jacobsen wrote: > >> 2. You haven't said much (well, probably not enough) about your >> reconstruction filters. i.e., if you could expand a bit on the >> digital filtering you're doing prior to the ADC, the architecture of >> the ADC (whether it's sigma-delta, and any internal processing it >> might be doing), and the characteristics of your analog reconstruction >> filter. All of this stuff matters and may have a substantial effect >> on the output waveform. > >You seem to be under the impression that the OP has an anolog signal he is >sampling. I thought he made it clear in the first post he does not. > >He said: > >"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? " > >As far as I can tell he is just adding increments to a storage register and when >it overflows it starts over. The pitch of his waveform varies with the size of >increment added. It isn't clear if he "samples" this register after each >addition or if he samples it at some n number of iterations or at some fixed >interval of time. He has been very vague and unclear about describing the actual >process.
Yes, that is correct. Specifically, there is an adder and a storage register on it's output. The adder's A input is fed by the register's output, the B input is connected to the increment value (which sets the waveform's fundamental frequency). The register is clocked at 200 KHz as is the DAC. Each time it is clocked, the register's output value is increased by the increment amount. When the register's value maxes out, it simply wraps. This is the current implementation, but I can see from this thread that I can get better performance if I clock the register/adder affair much faster than 200KHz, lowpass filtering and then decimating down to 200KHz. It may also be desirable for me to lower my DAC sample rate to 48KHz (from 200KHz) or so to allow the ratio of the waveform generating clock to DAC clock to be larger.
Scott Gravenhorst <no.spam@gte.net> wrote:

>On Wed, 24 Sep 2008 10:06:15 -0700 (PDT), cs_posting@hotmail.com >wrote: >>The high frequency components come from the single-sample step "reset" >>of the saw tooth.
That may or may not be a useful way to look at it.
>Yes, I get that. In fact, I've read about using BLIT to band limit >the waveform acceptably. However - I won't necessarily be using a >waveform that is easily constructed with BLIT.
Not sure what BLIT is, but if instead of synthesizine a sawtooth, you could try synthesizing a waverform that is the sum of this sawtooth's fundamental plus harmonics up to Fs/2 (or maybe Fs/2.5, to be conservative). Obviously it would be a more rounded-looking waveform. Steve
On Sep 23, 7:43&#4294967295;pm, no.s...@gte.net (Scott Gravenhorst) wrote:
> On Tue, 23 Sep 2008 11:59:04 -0700 (PDT), robert bristow-johnson > > > > <r...@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. &#4294967295;(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. &#4294967295;(that's equivalent to a densely sampled > >interpolation kernel.) > > Thank you. &#4294967295;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?
well, if 120 dB S/N is good enough, you can interpolate pretty much anything with BLIT using a 32-tap polyphase FIR that has 512 phases that are linearly interpolated between (i guess that means two 32-tap FIRs for two neighboring phases or fractional delays). so there are 64 MAC instructions plus what it takes to linearly interpolate (1 or 2 MACs) and a teeny bit more overhead.
> > I'm going by what I read in thewww.dspguide.comdocuments 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. &#4294967295;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).
but you'll need to oversample so much (before downsampling), and since it's an IIR, not FIR (like in BLIT), you actually have to compute all of the intermediate samples (which you don't have to in the polyphase FIR method). r b-j
On Wed, 24 Sep 2008 18:01:39 +0000 (UTC), spope33@speedymail.org
(Steve Pope) wrote:

>Scott Gravenhorst <no.spam@gte.net> wrote: > >>On Wed, 24 Sep 2008 10:06:15 -0700 (PDT), cs_posting@hotmail.com >>wrote: >>>The high frequency components come from the single-sample step "reset" >>>of the saw tooth. > >That may or may not be a useful way to look at it. > >>Yes, I get that. In fact, I've read about using BLIT to band limit >>the waveform acceptably. However - I won't necessarily be using a >>waveform that is easily constructed with BLIT. > >Not sure what BLIT is, but if instead of synthesizine a sawtooth, >you could try synthesizing a waverform that is the sum of this >sawtooth's fundamental plus harmonics up to Fs/2 (or maybe Fs/2.5, >to be conservative). > >Obviously it would be a more rounded-looking waveform. >
BLIT stands for Band Limited Impulse Train, it can be generated by adding sines up to Nyquist to create a band limited impulse. I believe it can also be generated using a sinc function. This is then used with an integrator to create a sawtooth (or something like it) and the sawtooth inherits the band limitation. This kind of waveform can then be used without concern for aliasing because it's already bandlimited. Other "classic" waveforms such as pulse and triangle can be generated with BLIT, but I think that not all arbitrary waveforms can be generated this way, at least not with any simplicity. Alternatively, a wavetable can be used (which I believe is what you were describing) that is constructed with sines up to Nyquist - but the problem with this and with BLIT is that the number of harmonics that are below Nyquist depends on the fundamental frequency of the waveform required. So if the table is constructed to properly bandlimit the waveform at the highest fundamental frequency that would ever be produced (this is a musical instrument application), the wavetable will produce a lackluster sound at low frequencies because harmonics that should be there because they would be below Nyquist at the lower fundamental will not be in the table. A solution is to use multiple tables with interpolation, but this is a RAM resource hog and from what I can see a table switching challenge. This why I am trying to use naively generated waveforms in an attempt to synthesize completely arbitrary waveforms without apparent alias effects. For me, the desirable range of the instrument is from 30 Hz to about 4 KHz.

Scott Gravenhorst wrote:
> > On Wed, 24 Sep 2008 12:43:55 -0500, jim <".sjedgingN0sp"@m@mwt.net> > wrote: > > > > > > >Eric Jacobsen wrote: > > > >> 2. You haven't said much (well, probably not enough) about your > >> reconstruction filters. i.e., if you could expand a bit on the > >> digital filtering you're doing prior to the ADC, the architecture of > >> the ADC (whether it's sigma-delta, and any internal processing it > >> might be doing), and the characteristics of your analog reconstruction > >> filter. All of this stuff matters and may have a substantial effect > >> on the output waveform. > > > >You seem to be under the impression that the OP has an anolog signal he is > >sampling. I thought he made it clear in the first post he does not. > > > >He said: > > > >"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? " > > > >As far as I can tell he is just adding increments to a storage register and when > >it overflows it starts over. The pitch of his waveform varies with the size of > >increment added. It isn't clear if he "samples" this register after each > >addition or if he samples it at some n number of iterations or at some fixed > >interval of time. He has been very vague and unclear about describing the actual > >process. > > Yes, that is correct. Specifically, there is an adder and a storage > register on it's output. The adder's A input is fed by the register's > output, the B input is connected to the increment value (which sets > the waveform's fundamental frequency). The register is clocked at 200 > KHz as is the DAC. Each time it is clocked, the register's output > value is increased by the increment amount. When the register's value > maxes out, it simply wraps. This is the current implementation, but I > can see from this thread that I can get better performance if I clock > the register/adder affair much faster than 200KHz, lowpass filtering > and then decimating down to 200KHz. It may also be desirable for me > to lower my DAC sample rate to 48KHz (from 200KHz) or so to allow the > ratio of the waveform generating clock to DAC clock to be larger.
OK. My guess is the aliasing problem may be in your head not your process. Of course that assumes the process works as you describe. If it is working as you describe then when you sweep the frequency it doesn't alias so much as to distort the sawtooth. Instead of a constant rise you get a kink in the ramp where it changes rates. Those kinks appear every so many waveforms and your ear is hearing this as a lower frequency (no actual lower frequency is present the ear interprets harmonics and constructs the lower frequency). This is aliasing of a sort. 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 would mean calculating what the average rate needs to be for that wave period (i.e. do linear interpolation of the entire ramp to remove the kink). -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 =---
> 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.
funny, my interpretation of the OP's first question: " What are the common method(s) for preventing aliasing of arbitrary waveforms generated within a DSP application? " somehow became, "how do i generate a nice bandlimited sawtooth?" (or whatever); which of course was not really the quesiton at all, but it is still an interesting one (to me...) so i looked and found this paper: http://www.acoustics.hut.fi/dafx08/papers/dafx08_05.pdf , which basically looks at integration of pulse trains. seems rather straightforward, but requires a final DC filtering stage... i also saw these plugins: http://blop.sourceforge.net/ which i have yet to check out really. maybe there are some other ideas...? thanks -zeb
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. Martin -- Quidquid latine scriptum est, altum videtur.

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.
Do you mean "so that the first difference will be constant" There is no first dirivative it is a digital signal. But terminology aside you are correct. To implement his sweep he needs another accumalator register that keeps track of the frequency increment value at a constant rate of increase. Then whenever the main accumulator overflows/resets the increment register that feeds the main adder gets updated from the accumulator that is keeping track of frequency (actually the inverse of frequency). -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 =---
zebra  <ezra@eastwestsounds.com> wrote:

>so i looked > >and found this paper: >http://www.acoustics.hut.fi/dafx08/papers/dafx08_05.pdf > >, which basically looks at integration of pulse trains. seems rather >straightforward, but requires a final DC filtering stage...
Thanks, look interesting. There is some jargon in this paper that would be nice to know what it means -- "subtractive synthesis", and "anti-aliasing oscillator". Maybe these are routine terms in digial music; I have no idea. Steve
On Wed, 24 Sep 2008 20:44:57 +0000 (UTC), spope33@speedymail.org
(Steve Pope) wrote:

>zebra <ezra@eastwestsounds.com> wrote: > >>so i looked >> >>and found this paper: >>http://www.acoustics.hut.fi/dafx08/papers/dafx08_05.pdf >> >>, which basically looks at integration of pulse trains. seems rather >>straightforward, but requires a final DC filtering stage... > >Thanks, look interesting. > >There is some jargon in this paper that would be nice to know >what it means -- "subtractive synthesis",
This one refers to both digital and analog music synthesis methods, it involves starting with a waveform rich in harmonics, such as sawtooth, pulse, square or triangle and using filters to remove harmonics as a way of changing timbre. The most desirable filters for this purpose can have their Fc easily maniplulated, a state variable filter is an example.
>and "anti-aliasing oscillator".
This one is for digital synthesis and refers to any oscillator method that produces a waveform without harmonics above Nyquist. Pretty much a band limited waveform generator.
>Maybe these are routine terms in digial music; >I have no idea. > >Steve