Re: DirectSound example sought

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Bob Masta (NoSpam_at_daqarta.com)
Date: 09/20/04


Date: Mon, 20 Sep 2004 13:10:57 GMT

On Tue, 14 Sep 2004 21:35:35 -0400, Joseph M. Newcomer
<newcomer@flounder.com> wrote:

<SNIP>

>There was a reference to using
>complex arithmetic to avoid doing sin/cos on each waveform, but I'm too far out from my
>complex analysis course (1966-1967) to remember how this is done. Any good pointers?

An even easier and faster way to generate sine waves is via table
look-up. You generate a full-cycle circular sine wave table once when
your program starts, maybe 8K or 16K values. Then to generate a sine
wave of any frequency, you step around the table with a step size
proportional to the frequency and inversely to sample rate. (Steps
will always be less than half the table size to avoid aliasing.) You
basically just compute the step size whenever the frequency changes
and then add that amount to an index to get the table entry for each
sample. Make the table a power-of-2 size so you can mask the index
to keep it in the table.

Same method works for FM by adding an extra modulation step size
onto the carrier step size as above.

The table look-up is very fast. If you want more precision than
provided by the basic table size, you can do a linear interpolation
on the table. This is still very fast compared to complex math.
Linear interpolation works well at these 8-16K table sizes, and you
can easily get decent 16-bit resolution.

This basic scheme is what is used in commerical DDS (Direct
Digital Synthesis) signal generators. You are not confined to
sine tables, and in fact you can use an arbitrary waveform. This
gives variable frequency on any waveform, at no extra cost.

Hope this helps!

Bob Masta
dqatechATdaqartaDOTcom
 
            D A Q A R T A
Data AcQuisition And Real-Time Analysis
           www.daqarta.com



Relevant Pages

  • Re: Please check my article on DSP basics
    ... with simple school type maths (no integration, no radians, no complex maths ... for each waveform with the Y axis showing the wave's Amplitude and the X ... Channel Lock-In Amplifier using nothing more than simple high school ... the same input sine waves multiplied by each other produce a ...
    (comp.dsp)
  • Please check my article on DSP basics
    ... Below is my attempt at describing the needed maths for programming the DSP ... for each waveform with the Y axis showing the wave's Amplitude and the X ... degrees per second where a complete cycle of the sine wave is 360 degrees. ... For these sine waves, the X1 and X2 above are as ...
    (comp.dsp)
  • Re: Additive Synthesis
    ... it is the combination of sine waves to produce more ... complex waveforms such as in the old Yamaha DX synths but surely that is ... you take the original waveform and change its ... Somebody else followed up by saying that additive synthesis works ...
    (rec.music.makers.synth)
  • Re: Calc. energy harmonics
    ... Pure sine waves, for example, have no harmonics. ... I am referring to a "resonant" frequency irrespective of waveform. ... twenty times to produce a distant lower octave. ...
    (sci.physics)