DSPRelated.com
Forums

Anti Aliasing of Arbitrary Waveforms

Started by Scott Gravenhorst September 23, 2008
Scott Gravenhorst <no.spam@gte.net> wrote:

>On Tue, 23 Sep 2008 19:20:05 +0000 (UTC), spope33@speedymail.org
>(Steve Pope) wrote:
>>Scott Gravenhorst <no.spam@gte.net> wrote:
>>>>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.
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. You say the problem is not proportionately worse at lower signal levels, generally implying this is not a quantizing error effect either, but it still might be, as follows: I am suspecting the "adder/register" arrangement you are describing has a bit-width larger than the number of bits in your DAC, and that you truncate to your DAC width without dithering. I suspect that for sawtooth frequencies near, but not exactly, a submultiple of your sample rate, the exact numerical values of your sawtooth will wander from one sawtooth cycle to the next, and that these un-dithered variations are audible as extraneous tones. If so, this is indeed a quantizing effect. The question is, if it is a quantizing effect, why isn't it worse at lower signal levels? The answer may be that you have your gain control stage *after* the above-described truncation; so that you are getting the same errors in the waveform regardless of whether you reduce the gain. I am betting that if you make certain your sawtooth waveform presents the exact same set of values to the DAC each sawtooth cycle, your siren effect goes away. Steve
On Tue, 23 Sep 2008 19:52:27 +0000 (UTC), spope33@speedymail.org
(Steve Pope) wrote:

>Scott Gravenhorst <no.spam@gte.net> wrote: > >>On Tue, 23 Sep 2008 19:20:05 +0000 (UTC), spope33@speedymail.org > >>(Steve Pope) wrote: > >>>Scott Gravenhorst <no.spam@gte.net> wrote: > >>>>>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. > >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. > >You say the problem is not proportionately worse at >lower signal levels, generally implying this is not a quantizing >error effect either, but it still might be, as follows: > >I am suspecting the "adder/register" arrangement you are >describing has a bit-width larger than the number of bits in your >DAC, and that you truncate to your DAC width without dithering. >I suspect that for sawtooth frequencies near, but not exactly, >a submultiple of your sample rate, the exact numerical >values of your sawtooth will wander from one sawtooth cycle to >the next, and that these un-dithered variations are audible as >extraneous tones. If so, this is indeed a quantizing effect. > >The question is, if it is a quantizing effect, why isn't >it worse at lower signal levels? The answer may be that >you have your gain control stage *after* the above-described >truncation; so that you are getting the same errors in the >waveform regardless of whether you reduce the gain. > >I am betting that if you make certain your sawtooth waveform >presents the exact same set of values to the DAC each sawtooth >cycle, your siren effect goes away. > >Steve
The siren effect is apparent _only_ while the fundamental frequency of the sawtooth is actively changing, not while it is constant. The test application allows sweeping the fundamental frequency up or down or it can be left to run at a constant frequency. At very high frequencies, I can easily stop the sweep and hear an inharmonic partial that remains constant as long as the fundamental frequency of the sawtooth waveform is not changed.
Scott Gravenhorst <no.spam@gte.net> wrote:

>On Tue, 23 Sep 2008 19:52:27 +0000 (UTC), spope33@speedymail.org
>>I am suspecting the "adder/register" arrangement you are >>describing has a bit-width larger than the number of bits in your >>DAC, and that you truncate to your DAC width without dithering.
>The siren effect is apparent _only_ while the fundamental frequency of >the sawtooth is actively changing, not while it is constant. The test >application allows sweeping the fundamental frequency up or down or it >can be left to run at a constant frequency.
Right. So, can you comment on whether the sitaution I describe above applies (the added/accumulator are a large bit-width than the DAC)?
>At very high frequencies, >I can easily stop the sweep and hear an inharmonic partial that >remains constant as long as the fundamental frequency of the sawtooth >waveform is not changed.
What's an inharmonic partial? Steve
On Tue, 23 Sep 2008 20:04:39 +0000 (UTC), spope33@speedymail.org
(Steve Pope) wrote:

>Scott Gravenhorst <no.spam@gte.net> wrote: > >>On Tue, 23 Sep 2008 19:52:27 +0000 (UTC), spope33@speedymail.org > >>>I am suspecting the "adder/register" arrangement you are >>>describing has a bit-width larger than the number of bits in your >>>DAC, and that you truncate to your DAC width without dithering. > > >>The siren effect is apparent _only_ while the fundamental frequency of >>the sawtooth is actively changing, not while it is constant. The test >>application allows sweeping the fundamental frequency up or down or it >>can be left to run at a constant frequency. > >Right. So, can you comment on whether the sitaution I describe >above applies (the added/accumulator are a large bit-width >than the DAC)?
Yes, the DAC is 24 bits, and I have tested the counter at both 24 bits and 32 bits with the same siren effect result.
>>At very high frequencies, >>I can easily stop the sweep and hear an inharmonic partial that >>remains constant as long as the fundamental frequency of the sawtooth >>waveform is not changed. > >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. Inharmonic partials are sinewave components that aren't part of the original waveform's infinite series, so they sound bad.
On Sep 23, 3:35 pm, no.s...@gte.net (Scott Gravenhorst) wrote:

> 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.
Do you "use" all the bits in the phase accumulator in determining the output amplitude? Or do you only use some number of MSB's, and ignore the LSB's in the amplitude, though of course they are retained in the phase accumulation? Reason I ask is that I think ignoring LSB's could introduce jitter in when your amplitude "steps" occur, and perhaps that jitter is what you are hearing? You haven't said how many bits are involved, so it's hard to tell if this could be significant by ear or only to test equipment.
On Tue, 23 Sep 2008 13:14:22 -0700 (PDT), cs_posting@hotmail.com
wrote:

>On Sep 23, 3:35 pm, no.s...@gte.net (Scott Gravenhorst) wrote: > >> 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. > >Do you "use" all the bits in the phase accumulator in determining the >output amplitude? > >Or do you only use some number of MSB's, and ignore the LSB's in the >amplitude, though of course they are retained in the phase >accumulation? > >Reason I ask is that I think ignoring LSB's could introduce jitter in >when your amplitude "steps" occur, and perhaps that jitter is what you >are hearing? > >You haven't said how many bits are involved, so it's hard to tell if >this could be significant by ear or only to test equipment.
The DAC is 24 bits wide. I've tested the system using both a 24 bit and a 32 bit adder/register. All of the bits from the output of the register are connected to the DAC for the 24 bit adder/register. When I use 32 bits for the adder, I send the top 24 bits to the DAC.
Scott Gravenhorst <no.spam@gte.net> wrote:

>On Tue, 23 Sep 2008 20:04:39 +0000 (UTC), spope33@speedymail.org
>(Steve Pope) wrote:
>>Right. So, can you comment on whether the sitaution I describe >>above applies (the added/accumulator are a large bit-width >>than the DAC)?
>Yes, the DAC is 24 bits, and I have tested the counter at both 24 bits >and 32 bits with the same siren effect result.
So in the instance where the counter was 32 bits, you truncated or rounded the signal to 24 bits without dithering? Next question, when you say you hear the same relative level of siren effect at different gains, where is that gain control? (i.e. is it after the sawtooth generator, but before the DAC?)
>>>At very high frequencies, >>>I can easily stop the sweep and hear an inharmonic partial that >>>remains constant as long as the fundamental frequency of the sawtooth >>>waveform is not changed. >> >>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. Inharmonic partials are >sinewave components that aren't part of the original waveform's >infinite series, so they sound bad.
Do you believe the siren effect is hearing these inharmonics sweeping around, or something else? Steve
Scott Gravenhorst <no.spam@gte.net> wrote:

>The DAC is 24 bits wide. I've tested the system using both a 24 bit >and a 32 bit adder/register. All of the bits from the output of the >register are connected to the DAC for the 24 bit adder/register. When >I use 32 bits for the adder, I send the top 24 bits to the DAC.
It's this final step where dithering might make a difference. Computing the sawtooth at high precision, and then dithering when reducing precision to 24 bits, gives you the best possible result. (This may not be the source of your artifact, but it is a possible source of artifacts.) Steve
On Sep 23, 12:20 pm, spop...@speedymail.org (Steve Pope) wrote:
...
> > Okay, then describe for us the sample rates used in the entire > chain of signals, from waveform generator to DAC. > > Steve
The problematic sampling is that which takes place when discrete samples of conceptual waveforms of arbitrary spectrum are generated by the digital hardware. A discussion of the issues the OP faces is given in: http://ccrma-www.stanford.edu/~stilti/papers/blit.pdf and Antialiasing Oscillators in Subtractive Synthesis Signal Processing Magazine, IEEE March 2007, page(s): 116-125 Dale B. Dalrymple http://dbdimages.com
On Sep 23, 4:18 pm, no.s...@gte.net (Scott Gravenhorst) wrote:

> The DAC is 24 bits wide.
Oh, that's almost certainly sigma delta then. Are you sure you are driving it right? Are you sure it likes 200 khz, and not say 192? I don't know that there is an issue here, but sigma delta dacs are quite complicated internally with various filters and such built in, and misusing them slightly could have all sorts of unusual aliasing effects. I wonder what happens when your sawtooth's single-sample step transient hits the DAC's internal filters?