text: #include <math.h>
  
  #ifndef M_PI
  #define M_PI (3.1415926535897932)
  #endif
  #define TWO_PI (M_PI * 2.0)
  
  typedef struct t_oscil {
      double twopiovrsr;
      double curphase;
      double curfreq;
      double incr;
  } OSCIL;
  
  typedef double (*wavefunc)(OSCIL* osc, double freq);
  
  /* creates an oscilator with initial values */
  OSCIL* new_oscil(unsigned long srate);
  
  /* Single iteration in a sine wave */
  double sinetick(OSCIL* osc, double freq);
  
  /* Single increment of a square wave */
  double squaretick(OSCIL* osc, double freq);
  
  /* Single increment of a Downward Saw Wave */
  double dsawtick(OSCIL* osc, double freq);
  
  /* Single increment of an upward saw wave */
  double usawtick(OSCIL* osc, double freq);
  
  /* Single increment of a triangle wave */
  double tritick(OSCIL* osc, double freq);