/*M*
//
//               INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//       Copyright (c) 1995 Intel Corporation. All Rights Reserved.
//
//  RCS:
//      $Source: d:/rcs/nsp20/include/nsptrngl.h $
//      $Revision: 1.3 $
//      $Date: 1995/08/07 11:02:30 $
//
//  Purpose: Generating of signals with triangle wave form.
//           Provides samples of a triangle of arbitrary frequency,
//           phase, magnitude, and asymmetry.
//
//           0 =< phase < 2PI,  -PI < asym < PI,
//           mag > 0, 0 =< rfrec < 0.5
//
//           asym = 0       => Triangle is symmetric (old version)
//           asym = -PI+eps => Triangle with sheer back (0<eps)
//           asym =  PI-eps => Triangle with sheer front-fore
//
//           Like (cos) tone functions the triangle has period equal 2PI
//           Triangle phase is given in radians.
*M*/

/*==========================================================================*/

#if !defined _NSPTRNGL_H  || defined _NSP_BLDPCS
#define _NSPTRNGL_H

/*--- Triangle structures --------------------------------------------------*/
#ifndef _NSP_BLDPCS

 typedef struct _NSPSTrnglState {
   float mag;
   float step;
   float step1;
   float step2;
   float st12;
   float st21;
   float last;
 } NSPSTrnglState;

 typedef struct _NSPCTrnglState {
   float mag;
   SCplx step;
   float step1;
   float step2;
   float st12;
   float st21;
   SCplx last;
 } NSPCTrnglState;

 typedef struct _NSPDTrnglState {
   double mag;
   double step;
   double step1;
   double step2;
   double st12;
   double st21;
   double last;
 } NSPDTrnglState;

 typedef struct _NSPZTrnglState {
   double mag;
   DCplx  step;
   double step1;
   double step2;
   double st12;
   double st21;
   DCplx  last;
 } NSPZTrnglState;

#endif

/*--- Triangle initialization --------------------------------------------*/

NSPAPI(void,nspsTrnglInit,(float rfrq,  float  phase,  float mag,  float asym,
                           NSPSTrnglState     *stPtr));
NSPAPI(void,nspdTrnglInit,(double rfrq, double phase, double mag, double asym,
                           NSPDTrnglState     *stPtr));
NSPAPI(void,nspcTrnglInit,(float  rfrq, float  phase, float  mag, float asym,
                           NSPCTrnglState     *stPtr));
NSPAPI(void,nspzTrnglInit,(double rfrq, double phase, double mag, double asym,
                           NSPZTrnglState     *stPtr));

/*--- Single-Sample-Generating triangle functions -------------------------*/

NSPAPI(float,  nspsTrngl,(NSPSTrnglState* statePtr));
NSPAPI(double, nspdTrngl,(NSPDTrnglState* statePtr));
NSPAPI(SCplx,  nspcTrngl,(NSPCTrnglState* statePtr));
NSPAPI(DCplx,  nspzTrngl,(NSPZTrnglState* statePtr));

/*--- Block-of-Samples-Generating triangle functions -----------------------*/

NSPAPI(void,nspsbTrngl,(NSPSTrnglState* statePtr,float*  samps,int sampsLen));
NSPAPI(void,nspdbTrngl,(NSPDTrnglState* statePtr,double* samps,int sampsLen));
NSPAPI(void,nspcbTrngl,(NSPCTrnglState* statePtr,SCplx*  samps,int sampsLen));
NSPAPI(void,nspzbTrngl,(NSPZTrnglState* statePtr,DCplx*  samps,int sampsLen));

#endif /* _NSPTRNGL_H */
