Capsim Block Documentation
Perform operations on input buffer.
| Port | Type | Name | |
|---|---|---|---|
| 0 | float | x |
| Port | Type | Name | |
|---|---|---|---|
| 0 | float | xmod |
| Num | Type | Name | Initial Value | Description |
|---|---|---|---|---|
| 0 | int | count | N | |
| 1 | int | wait | first |
int i,j; float xval; float tmp; |
|---|
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);
|
|---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
Copyright (C) 1989-2002 XCAD 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://capsimtmk.sourceforge.net
XCAD Corporation
Raleigh, North Carolina */
|
|---|
/* 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 |
|---|