Reply by Scott Gravenhorst October 21, 20082008-10-21
On Mon, 20 Oct 2008 01:49:37 GMT, no.spam@gte.net (Scott Gravenhorst)
posted:

I have a version of this working using 18 bit floating point
coefficients with 18 bit fixed point history and an accumulator of 36
bits.  This allowed me to use a single multiplier instead of 4.  Fc
was lowered to .87/32.  I notice no audible difference between the
floating point and the fixed point versions.  Both provide very good
suppression of folding artifacts when used with waveforms at
fundamentals of 5 KHz or less.



Reply by Scott Gravenhorst October 20, 20082008-10-20
On 20 Oct 2008 20:23:15 GMT, Martin Eisenberg
<martin.eisenberg@udo.edu> wrote:

>Scott Gravenhorst wrote: > >> The signal is FIR (511 taps) filtered at Fc of 1/32 and >> then decimated by 32 for a DAC sample rate of 48 KHz. > >You may gain runtime efficiency if you do deep decimation (*) in >stages of 2x, or perhaps 4x, instead of all at once. The reason is >that the earlier stage filters can afford a softer transition band >and thus be shorter. For example, to go down from 4*fs to 2*fs, the >filter must pass up to pi/4 and block above pi*3/4 -- only the last, >2x-1x stage needs a really sharp halfband filter.
I am implementing this as an FPGA design. Since the filter has a single ROM image as a coefficient store, it is easy to update the filter by changing it's initialization data. For multiple filters in stages, I'd still have to store many coefficients, so either way I use a RAM resource. It so happens that one RAM resource allows a 511 tap FIR filter, so I picked that as a starting point. I've played around a bit with adjusting the filter and I'm getting good results by lowering Fc from 1/32 to .87/32 which represents 22.88 KHz. I'm getting useful suppression of alias/folding up to about 5.5 KHz fundamental. And the timbre remains true to my ears, that is, a sawtooth processed this way still sounds like a sawtooth. For me, up to 5.5 KHz fundamental frequencies (just above piccolo) will be more than adequate for musical synthesis.
>Each stage stopband still gets designed to the overall attenuation >spec. A disadvantage is that passband ripple may compound, depending >on where each filter's wiggles end up, so you have to check the >cascade passband response and possibly fiddle it into submission. >(Alternatively, find or devise a joint optimization code.) > >* Terminology note: I seem to remember that the consensus in previous >discussions has been that "downsample" should mean "demux and throw >some away", and "decimate" says "filter and downsample" -- mutatis >mutandis for "upsample" and "interpolate". Do folks agree?
> >Martin > >-- >Quidquid latine scriptum est, altum videtur.
Reply by Martin Eisenberg October 20, 20082008-10-20
Scott Gravenhorst wrote:

> The technique as I am currently applying it does not completely > eliminate the effect. It becomes audible around 2000 Hz > fundamental. Below 2000 Hz, it's not audible (to me). I may be > able to extend that by adjusting the filter.
At fundamental frequency f0, output samplerate fs, and oversampling ratio R, the first harmonic to fold back into baseband unfiltered has the index k = floor((2*R - 1)*fs/2 / f0). (Or k+1; make a drawing to understand.) With your values this becomes k = 756, which in turn is -20*log10(k) ~= -57 dB below the fundamental for a sawtooth. That is acceptable for listening but not really for music production. For waveforms with such slow rolloff, you should probably combine one of the cheaper quasi-bandlimited generation methods with moderate oversampling. Martin -- There are three kinds of people -- those who can count and those who can't.
Reply by Martin Eisenberg October 20, 20082008-10-20
Scott Gravenhorst wrote:

> The signal is FIR (511 taps) filtered at Fc of 1/32 and > then decimated by 32 for a DAC sample rate of 48 KHz.
You may gain runtime efficiency if you do deep decimation (*) in stages of 2x, or perhaps 4x, instead of all at once. The reason is that the earlier stage filters can afford a softer transition band and thus be shorter. For example, to go down from 4*fs to 2*fs, the filter must pass up to pi/4 and block above pi*3/4 -- only the last, 2x-1x stage needs a really sharp halfband filter. Each stage stopband still gets designed to the overall attenuation spec. A disadvantage is that passband ripple may compound, depending on where each filter's wiggles end up, so you have to check the cascade passband response and possibly fiddle it into submission. (Alternatively, find or devise a joint optimization code.) * Terminology note: I seem to remember that the consensus in previous discussions has been that "downsample" should mean "demux and throw some away", and "decimate" says "filter and downsample" -- mutatis mutandis for "upsample" and "interpolate". Do folks agree? Martin -- Quidquid latine scriptum est, altum videtur.
Reply by Scott Gravenhorst October 20, 20082008-10-20
On Mon, 20 Oct 2008 01:49:37 GMT, no.spam@gte.net (Scott Gravenhorst)
wrote:

>Hello all, > >Thank you for the lively discussion on this. > >This is an update about my practical experiment on using a filter to >band limit an arbitrary waveform signal. I have some preliminary test >results. > >The test design generates the arbitrary waveform at SR a bit over 1.5 >MHz. The signal is FIR (511 taps) filtered at Fc of 1/32 and then >decimated by 32 for a DAC sample rate of 48 KHz. Arithmetic is 35 bit >signed fixed point binary. The design outputs the raw decimated >sawtooth waveform on the right DAC channel with the filtered decimated >signal on the left DAC channel. > >Using the raw signal, It was easy to find a frequency range that >exhibits the "siren alias sound" when the fundamental is slowly swept. >When I switch to the filtered side, I don't hear the siren - note that >this is a noisy room right now, but the nasty siren seems to >significantly attenuated. First impression is that the filtered >sawtooth still sounds like a sawtooth. > >-- ScottG, OP >
More testing: The technique as I am currently applying it does not completely eliminate the effect. It becomes audible around 2000 Hz fundamental. Below 2000 Hz, it's not audible (to me). I may be able to extend that by adjusting the filter.
Reply by Scott Gravenhorst October 20, 20082008-10-20
On Sun, 19 Oct 2008 23:22:15 -0400, Jerry Avins <jya@ieee.org> wrote:

>Jerry Avins wrote: >> Scott Gravenhorst wrote: >>> Hello all, >>> >>> Thank you for the lively discussion on this. >>> >>> This is an update about my practical experiment on using a filter to >>> band limit an arbitrary waveform signal. I have some preliminary test >>> results. >>> >>> The test design generates the arbitrary waveform at SR a bit over 1.5 >>> MHz. The signal is FIR (511 taps) filtered at Fc of 1/32 and then >>> decimated by 32 for a DAC sample rate of 48 KHz. Arithmetic is 35 bit >>> signed fixed point binary. The design outputs the raw decimated >>> sawtooth waveform on the right DAC channel with the filtered decimated >>> signal on the left DAC channel. >>> >>> Using the raw signal, It was easy to find a frequency range that >>> exhibits the "siren alias sound" when the fundamental is slowly swept. >>> When I switch to the filtered side, I don't hear the siren - note that >>> this is a noisy room right now, but the nasty siren seems to >>> significantly attenuated. First impression is that the filtered >>> sawtooth still sounds like a sawtooth. >> >> Happy day! I hope out kibbitzing helped. > OUR >> >> Jerry
Yes, thanks to all, the kibbitzing got me thinking about many things. For one thing, the discussion here moved me away from the Chebyshev I was trying to use before - and my oversampling of 32x came from suggestions here that 16 should be considered minimum for a worthwhile experiment.
Reply by Jerry Avins October 20, 20082008-10-20
Jerry Avins wrote:
> Scott Gravenhorst wrote: >> Hello all, >> >> Thank you for the lively discussion on this. >> >> This is an update about my practical experiment on using a filter to >> band limit an arbitrary waveform signal. I have some preliminary test >> results. >> >> The test design generates the arbitrary waveform at SR a bit over 1.5 >> MHz. The signal is FIR (511 taps) filtered at Fc of 1/32 and then >> decimated by 32 for a DAC sample rate of 48 KHz. Arithmetic is 35 bit >> signed fixed point binary. The design outputs the raw decimated >> sawtooth waveform on the right DAC channel with the filtered decimated >> signal on the left DAC channel. >> >> Using the raw signal, It was easy to find a frequency range that >> exhibits the "siren alias sound" when the fundamental is slowly swept. >> When I switch to the filtered side, I don't hear the siren - note that >> this is a noisy room right now, but the nasty siren seems to >> significantly attenuated. First impression is that the filtered >> sawtooth still sounds like a sawtooth. > > Happy day! I hope out kibbitzing helped.
OUR
> > Jerry
-- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by Jerry Avins October 20, 20082008-10-20
Scott Gravenhorst wrote:
> Hello all, > > Thank you for the lively discussion on this. > > This is an update about my practical experiment on using a filter to > band limit an arbitrary waveform signal. I have some preliminary test > results. > > The test design generates the arbitrary waveform at SR a bit over 1.5 > MHz. The signal is FIR (511 taps) filtered at Fc of 1/32 and then > decimated by 32 for a DAC sample rate of 48 KHz. Arithmetic is 35 bit > signed fixed point binary. The design outputs the raw decimated > sawtooth waveform on the right DAC channel with the filtered decimated > signal on the left DAC channel. > > Using the raw signal, It was easy to find a frequency range that > exhibits the "siren alias sound" when the fundamental is slowly swept. > When I switch to the filtered side, I don't hear the siren - note that > this is a noisy room right now, but the nasty siren seems to > significantly attenuated. First impression is that the filtered > sawtooth still sounds like a sawtooth.
Happy day! I hope out kibbitzing helped. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by Scott Gravenhorst October 19, 20082008-10-19
On Mon, 29 Sep 2008 09:46:42 -0500, jim <".sjedgingN0sp"@m@mwt.net>
wrote:

> > >Jerry Avins wrote: >> >> On Sep 29, 8:56 am, jim <"sjedgingN0sp"@m...@mwt.net> wrote: >> > Jerry Avins wrote: >> > >> > > On Sep 28, 2:32 pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote: >> > > > Jerry Avins wrote: >> > >> > > > > The triangle wave is supposed to be one example for a generalized >> > > > > method of handling arbitrary waveforms. Quantizing the frequency to >> > > > > make special cases is outside the spirit of the OP's question. >> > >> > > > Really? Sounded to me like the main thing he wanted was something simple and >> > > > easy to implement. What he is going to need beyond that wasn't explained in >> > > > detail. And it applies to any periodic waveform. He has yet to explain what >> > > > method he intends to use to generate other waveforms. >> > >> > > Read his posts. >> > >> > I thought I read them. I didn't see a single thing that even vaguely hinted how >> > he intends to make his other waveforms. >> >> This is the first sentence of Scott's first post on the subject: "What >> are the common method(s) for preventing aliasing of arbitrary >> waveforms generated within a DSP application? " > >That's what I meant - that statement provides no hint of how he is going to do >it. His current waveform is produced by incrementing a register. What method >are the other waveforms going to use?
As an example, 4 different NCO signals might be summed. 2 might be sawtooth, one a width modulated pulse and a sine wave. All 4 can be different frequencies and levels. This scenario is easy to generate from a single phase accumulator. It can be done at a high rate in an FPGA. Filter and decimate. Wavetable granules might be used, these can also be driven by a phase accumulator.
Reply by Scott Gravenhorst October 19, 20082008-10-19
Hello all,

Thank you for the lively discussion on this.

This is an update about my practical experiment on using a filter to
band limit an arbitrary waveform signal.  I have some preliminary test
results.

The test design generates the arbitrary waveform at SR a bit over 1.5
MHz.  The signal is FIR (511 taps) filtered at Fc of 1/32 and then
decimated by 32 for a DAC sample rate of 48 KHz.  Arithmetic is 35 bit
signed fixed point binary.  The design outputs the raw decimated
sawtooth waveform on the right DAC channel with the filtered decimated
signal on the left DAC channel.

Using the raw signal, It was easy to find a frequency range that
exhibits the "siren alias sound" when the fundamental is slowly swept.
When I switch to the filtered side, I don't hear the siren - note that
this is a noisy room right now, but the nasty siren seems to
significantly attenuated.  First impression is that the filtered
sawtooth still sounds like a sawtooth.

-- ScottG, OP