trig

Capsim Block Documentation

Short Description

Perform trig operation on input buffers

Top
Input Connections
Port Type Name
0 float x
Top
Output Connections
Port Type Name
0 float xmod
Top
Parameters
Num Description Type Name Default Value
0 Gain float gain 1.
1 DC Offset float offset 0.
2 Operation:0=sin,1=cos,2=tan,3=arctan,4=arcsin int operation 0
Top

Declarations


 

	int i,j;
	float xval;
	float tmp;



Top

Initialization Code



 





Top

Main Code



 


	for(i=MIN_AVAIL();i>0; --i) {
		IT_IN(0);
		xval = x(0);
				if(IT_OUT(0)) {
					KrnOverflow("trig",0);
					return(99);
				}
				tmp = gain * xval + offset;
				switch ( operation) {
				  case 0:
					xmod(0) = sin(tmp);
					break;
				  case 1:
					xmod(0) = cos(tmp);
					break;
				  case 2:
					xmod(0) = tmp*tmp;
					break;
				  case 3:
					xmod(0) = sqrt(tmp);
					break;
				  case 4:
					if(tmp)
					   xmod(0) = 10*log10(tmp*tmp);
					else 
					   xmod(0)= -200.0;
					break;
				}
	}
	return(0);




Top

Wrapup Code



 





Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/* trig.s */
/******************************************************************
			trig() 
*******************************************************************
Parameter 1: (int) number samples to output; default => all
		2: (int) index first sample; default => start from first
		3: (float) gain; default => unity gain
		4: (float) dc offset; default => no offset
		5: (int) operation: 0=sin,1=cos,2=tan,3=arctan,4=arcsin

trig


Perform trig operation on input buffers
Parameter 1: (int) number samples to output; default => all
		2: (int) index first sample; default => start from first
		3: (float) gain; default => unity gain
		4: (float) dc offset; default => no offset
		5: (int) operation: 0=sin,1=cos,2=tan,3=arctan,4=arcsin


Programmer: 	Sasan Ardalan	
Date:	 	Dec. 29, 1990	
Modified:

*/