I'm looking for references to detailed discussions of the
digital representation/generation of audio test tones, specifically a sine
sweep from 20 Hz. to the Nyquist freq.

Let's say we want to generate a sine tone that rises by 1
octave/sec:

The simple answer is to take the sine of
the phase at 0, and add a phase increment each sample period. The
phase increment is calculated according to the frequency which is
rising at the rate 2^(2/Fs), where Fs is the sampling rate.

This DOES generate a rising sine tone.

Unfortunately, the amplitude varies according to the
instantaneous phase. In the worst case, at the Nyquist freq, with only
two samples per period the phase might be 0 and 180 degrees resulting
in a perfect sine tone with ZERO amplitude! These amplitude anomalies
are extremely audible in an audio application.

How then best to hide the problem from an audio/perceptual
point of view? Some sub-audio rate frequency modulation
would be acceptable. Any suggestions? Any code (Forth, C, 680x0, or 56k)?

Chris

--

>    I'm looking for references to detailed discussions of the
>digital representation/generation of audio test tones, specifically a sine
>sweep from 20 Hz. to the Nyquist freq.
>    Let's say we want to generate a sine tone that rises by 1
>octave/sec:
>    The simple answer is to take the sine of
>the phase at 0, and add a phase increment each sample period. The
>phase increment is calculated according to the frequency which is
>rising at the rate 2^(2/Fs), where Fs is the sampling rate.

>    This DOES generate a rising sine tone.

>    Unfortunately, the amplitude varies according to the
>instantaneous phase. In the worst case, at the Nyquist freq, with only
>two samples per period the phase might be 0 and 180 degrees resulting
>in a perfect sine tone with ZERO amplitude! These amplitude anomalies
>are extremely audible in an audio application.
>    How then best to hide the problem from an audio/perceptual
>point of view? Some sub-audio rate frequency modulation
>would be acceptable. Any suggestions? Any code (Forth, C, 680x0, or 56k)?
>Chris

>--

The problem you have could be the result of several factors. First, it
is not possible, in practice, to include frequencies near, or at fs/2
since practical anti-aliasing filters will need a finite transition band
between passband and stopband. A second concern is that aperture
correction may be needed to obtain flat frequency response, depending
on how the D/A converter is used.

The phase accumulation method you propose appears to valid from a
digital point of view. The analog side could be simplified by increasing
fs (ie over-sampling), then your anti-alias filter contraints would
be loosened. Many audio D/A convertors using sigma-delta techniques do
this for you.

Hope this helps,

I am able to generate a linear sine sweep using the following code:

f_lo = StartFrequency / SampleRate;
f_hi = StopFrequency / SampleRate;

samples = SampleRate * sweeptime;

a = 2 * PI * (f_hi - f_lo) / samples;
b = 2 * PI * f_lo;

for (index = 0; index < samples; index ++)
m_pSweepData[index] = sin(a * index * index / 2 + b * index);

I would like to modify this code to generate a logarithmic sweep.  Any
ideas or suggestions?

Thanks!

4. genmod