ARMEBS4  revision-26.06.2015
sine_wave_state_t Struct Reference
Collaboration diagram for sine_wave_state_t:
Collaboration graph

Detailed Description

A fast sine wave generator, by Charles Praplan

The following difference equation implements an IIR filter whose poles are on the unit circle if -2 < f_a < 2.

       A*sin(2*pi*f0/FS)

H(z) = --------------------— 1 - f_a*(z^-1) + (z^-2)

We are here interested in the impulse response which is a pure sine wave. Instead of applying a delta impulse at the input of the system we provide initial conditions.

If a little change occurs in the 'a' (due to numerical precision), the stability is maintained as far the coefficient 'a' stays in the limits mentioned above. But both the frequency and the amplitude of the wave change.

The start conditions of the digital oscillator implemented in the sine_wave_sample function are 2 succeeding samples of the sine wave. This 2 values and the knowledge of the frequency (contained in the coefficient 'a') determine completely the sine wave.

We calculate here the start conditions for k = -1 and k = 0 so that the first calculated sample is non zero if phase = 0.

Definition at line 50 of file audio.c.