Shop OBEX P1 Docs P2 Docs Learn Events
Interpolation needed? — Parallax Forums

Interpolation needed?

John A. ZoidbergJohn A. Zoidberg Posts: 514
edited 2011-08-13 04:33 in General Discussion
Hey ladies and gentlemen,

I've constructed a DDS generator for my music-box, however, there is one issue which comes to me when it hits higher frequencies - aliasing.

My DDS has an 8-bit R2R DAC, and with 22.1kHz sampling rate. When the thing hits 1760Hz, I noticed the sine waves in my oscilloscope has become like a staircase up, and a staircase down. In fact, it has unbecoming of the sine waves already on much higher frequencies. The 'jumps' caused by the phase adders probably caused that.

Are interpolation much needed there? For those who developed Prop-based music boxes, have you actually tested them in higher frequencies? I tried to make a chord with that, but the aliased higher frequency components destroys the sound immediately.

I could have increased the DAC bits, but doing so, I must extend the sine-waves lookup table to another 512 bytes which could be tedious later.

Opinions?

Thanks. :)

Comments

  • davejamesdavejames Posts: 4,047
    edited 2011-08-11 20:53
    My first thought would be to increase the sampling rate. Is that possible to do, at least as an experiment?
  • Ahle2Ahle2 Posts: 1,179
    edited 2011-08-12 13:39
    22 kHz is a terrible low sampling frequency. For DDS, anything below 80 kHz will produce audible aliasing distortion if no antialising algorithm is used.
    8 bit resolution will be a bit noisy when there are no high frequencies in the digital signal masking the quantization noise.
    But your problem is, with out a doubt, because of the low sample rate.

    Why settle with such poor sample rate?
    Why not use the counter modules in "duty mode" for much better than 8 bit resolution using only a single pin?
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-08-12 15:44
    You won't have any aliasing as long as you are generating frequencies less than 11 KHz. However, you will generate high frequency harmonics if you don't low-pass filter the output from your DAC. Unless you use a high order filter, your low-pass filter will need to cut off well below 11 KHz if you want to eliminate the upper harmonics.
  • Ahle2Ahle2 Posts: 1,179
    edited 2011-08-12 23:22
    DDS will always produce "higher than half the sample rate frequencies" (aliasing) if no antialiasing/interpolations is used. It will, however, be more or less audible depending on the output sample rate, the size of the LUT used by the phase accumulator and of course the shape of the waveform in the LUT.
    So even if the fundamental frequency prouced by the phase accumulator is way below 11 kHz, the waveform (even if "sinus") will have frequency components higher than the fundamental frequency; That's the nature of sampled audio. This will produce aliasing distortion/jitter when the phase accumulators fundamental frequency is not even divisible by the sample rate.

    Anyway, all these kinds of "harmonic distortions" will be less audible with a higher sample rate and a bigger LUT.
    The 8 bit resolution you are using will just add more audible quantization noise compared to >8 bit and is obviously not your main concern.
  • Mark_TMark_T Posts: 1,981
    edited 2011-08-13 04:13
    Ahle2 wrote: »
    22 kHz is a terrible low sampling frequency. For DDS, anything below 80 kHz will produce audible aliasing distortion if no antialising algorithm is used.
    8 bit resolution will be a bit noisy when there are no high frequencies in the digital signal masking the quantization noise.
    But your problem is, with out a doubt, because of the low sample rate.

    Why settle with such poor sample rate?
    Why not use the counter modules in "duty mode" for much better than 8 bit resolution using only a single pin?
    The sampling frequency needs to be more than twice the highest frequency of interest - the human ear is a very good low pass filter so 44.1kHz sampling works for CDs... o 48kHz sampling is used too.

    If its not the human ear you are driving (say the signal is being used to modulate an RF carrier) then you need to add your own brick-wall low pass filter to remove the aliases. A higher sampling frequency pushes the aliases to a higher frequency and makes the LPF easier to build.
  • Ahle2Ahle2 Posts: 1,179
    edited 2011-08-13 04:25
    People have to understand that there's a HUGE difference between sampling an analog signal after a brick wall filter at 19 kHz into cd quality audio (44,1 kHz) and DDS.

    Anyone that knows anything about DDS knows that without a very high sample frequency(>80 kHz) you will get audible aliasing distortion/jitter if you don't have some kind of interpolation/antialaising.
    Just try to resample a digital image from 320x200 to 300x180 without interpolation and you will get the same effect. It all comes down to the fact that the conversion is digital to digital and not analog to digital.

    I have been doing DDS and synthesis for >15 years, so I know this as a fact.
    Knowing nyquists theorem is just the top of the iceberg so to speak.
  • John A. ZoidbergJohn A. Zoidberg Posts: 514
    edited 2011-08-13 04:33
    Apologies for the late reply. Was busy with my work, so my DDS system is not checked for a while.

    I'm running this using a dsPIC, and it has an option for increasing the clock frequency up to 16x by PLL. I may try 4-5 mHz and see whether the higher frequencies will alias or not.
Sign In or Register to comment.