AF_sine_int(3)						       AF_sine_int(3)



NAME
  AF_sine_int, AF_sine_float - sine wave tables, for frequency synthesis

SYNTAX
  #include <AF/AFUtils.h>

  extern int AF_sine_int[];

  extern float AF_sine_float[];

DESCRIPTION
  AF_sine_int and AF_sine_float	are precomputed	tables you can link with your
  application.	Each table contains 1024 equally spaced	samples	of a single
  sine wave cycle.  AF_sine_int	contains 16 bit	integers scaled	so that	the
  peaks	of the sine wave are at	+32767 and -32767.  AF_sine_float contains
  single precision floating point numbers scaled so that the peaks of the
  sine wave are	at +1.0	and -1.0.

  The general idea of direct digital frequency synthesis is to step through
  the sine wave	table using a phase accumulator.  Each sample time, add	into
  the phase accumulator	a value	(the phase increment) which is the desired
  frequency divided by the sample rate and multiplied by the number of sam-
  ples in the sine table (1024).  The phase accumulator	must be	wrapped	MOD
  1024.	 Each sample time the output value is the value	in the sine table
  indexed by the integer part of the phase accumulator.

EXAMPLES
  Typical usage	is:

  float	frequency, sample_rate;	/* input parameters */
  float	phase_inc, phase;
  float	output;
  /* first compute the phase increment */
  phase_inc = (frequency / sample_rate)	* 1024.0;
  phase	= 0;
  /* then generate */
  for (;;)
  {
    output = AF_sine_float[phase];
    phase += phase_inc;
    if (phase >= 1024.0) phase -= 1024.0;
  }

DIAGNOSTICS
  If you index the table with an out-of-range value you	may cause a protec-
  tion fault and crash your application.

SEE ALSO
  AF(1)



BUGS
  If you encounter a reproducible bug, please submit a problem report to
  (af-bugs@crl.dec.com).



COPYRIGHT
  Copyright 1990-1994, Digital Equipment Corporation.
  See AF(1) for	a full statement of rights and permissions.

AUTHORS
  Larry	Stewart, Digital Cambridge Research Lab