operate

Capsim Block Documentation

Short Description

Perform operations on input buffer.

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 Number of samples to output int N 30000
1 First sample to start from int first 0
2 Gain float gain 1.
3 DC Offset float offset 0.
4 Operation:0=none,1=abs,2=square,3=sqrt,4=dB int operation 0
Top
States
Num Type Name Initial Value Description
0 int count N
1 int wait first
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(wait-- <= 0 ) {
			if(count-- > 0) {
				if(IT_OUT(0)) {
					KrnOverflow("operate",0);
					return(99);
				}
				tmp = gain * xval + offset;
				switch ( operation) {
				  case 0:
					xmod(0) = tmp;
					break;
				  case 1:
					xmod(0) = fabs(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



 

/* operate.s */
/******************************************************************
			operate() 
*******************************************************************
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=none,1=abs,2=square,3=sqrt,4=dB

operate


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=none,1=abs,2=square,3=sqrt,4=dB


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

*/