Capsim Block Documentation
This star convolves the input samples with the impulse response (finite duration, FIR ) given in a file.
| Port | Type | Name | |
|---|---|---|---|
| 0 | float | x |
| Port | Type | Name | |
|---|---|---|---|
| 0 | float | y |
| Num | Description | Type | Name | Default Value | |
|---|---|---|---|---|---|
| 0 | File name containing impulse response samples | file | filename | ||
| 1 | Order of impulse response | int | N |
| Num | Type | Name | Initial Value | Description |
|---|---|---|---|---|
| 0 | float* | x_P | ||
| 1 | float* | h_P |
int i;
int j;
float tmp1,tmp2;
float sum;
FILE *fopen();
FILE *imp_F;
|
|---|
/*
* Allocate memory and return pointers for tapped delay line x_P and
* array containing impulse response samples, h_P.
*
*/
if( (x_P = (float*)calloc(N,sizeof(float))) == NULL ||
(h_P = (float*)calloc(N,sizeof(float))) == NULL ) {
fprintf(stderr,"convolve: can't allocate work space\n");
return(4);
}
/*
* open file containing impulse response samples. Check
* to see if it exists.
*
*/
if( (imp_F = fopen(filename,"r")) == NULL) {
fprintf(stderr,"Convolve could not be opened file was %s \n",
filename);
return(4);
}
/*
* Read in the impulse response samples into the array
* and initialize the tapped delay line to zero.
*
*/
for (i=0; i |
|---|
while(IT_IN(0)){
/*
* Shift input sample into tapped delay line
*/
tmp2=x(0);
for(i=0; i |
|---|
free(x_P); free(h_P); |
|---|
/* 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 */
|
|---|
/* convolve.s */
/***********************************************************************
convolve()
************************************************************************
This star convolves the input samples with the impulse response (finite
duration, FIR ) given in a file.
Param: 1 - (file) File with the impulse response samples
2 - (int) N number of samples in the impulse response.
|
|---|