Capsim Block Documentation
This star convolves its input signal with an impulse response (from file) to generate the output signal.
Port | Type | Name | |
---|---|---|---|
0 | float | x |
Port | Type | Name | |
---|---|---|---|
0 | float | y |
int i; int no_samples; FILE* fp; float val; |
---|
if(impl < (2.89 * log((float)fftl) + 1)) fprintf(stderr,"fconv: direct convolution may be faster\n"); if(impl >= fftl) { fprintf(stderr,"fconv: FFT length smaller than impulse response length\n"); return(1); } if( (temp = (cap_fft_scalar*)calloc(fftl,sizeof(cap_fft_scalar))) == NULL || (iresp = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL || (freqBuffCx = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL || (temp2 = (cap_fft_scalar*)calloc(fftl,sizeof(cap_fft_scalar))) == NULL || (save = (cap_fft_scalar*)calloc(impl,sizeof(cap_fft_scalar))) == NULL ) { fprintf(stderr,"fconv: can't allocate work space\n"); return(2); } if((fp = fopen(impf_name,"r")) == NULL) { fprintf(stderr,"fconv: can't open impulse response file %s\n",impf_name); return(3); } for(i=0; i |
---|
for(no_samples=MIN_AVAIL();no_samples >0; --no_samples) { IT_IN(0); temp[pcount++] = x(0); if(pcount == fftl) { for(i=0; i |
---|
free(temp); free(iresp); free(save); free(temp2); free(freqBuffCx); free(preverse); free(pforward); |
---|
/* 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 */ |
---|
/* fconv.s */ /*********************************************************************** fconv() ************************************************************************ "Linear Convolution": This star convolves its input signal with an impulse response to generate the output signal. Param. 1 - (int) impl: length of impulse response in samples. 2 - (file) impf_name: ASCII file which holds impulse response. 3 - (int) fftexp: log2(fft length). Convolution is performed by the fft overlap-save method (described in Oppenheim & Schafer, Digital Signal Processing, pp. 113). The FFT length must be greater than the impulse response length. For efficiency, it should probably be more than twice as long. |
---|