firfil

Capsim Block Documentation

Short Description

This star designs FIR low pass, high pass, band pass, and band stop filters using the windowing method.

Top
Input Connections
Port Type Name
0 float x
Top
Output Connections
Port Type Name
0 float y
Top
Parameters
Num Description Type Name Default Value
0 Filter Type:1=LowPass,2=HighPass,3=BandPass,4=BandStop int filterType 1
1 Window Type:1=Rect,2=Tri,3=Hamm,4=GenHamm,5=Hann,6=Kaiser,7=Cheb,8=Parz int windType 3
2 Number of Taps int ntap 128
3 Cut Off Freq. (LowPass/HighPass Only) float fc 0.25
4 Lower cutoff freq. 0<=fl<=0.5 float fl 0.25
5 Upper cutoff freq. 0<=fh<=0.5 float fh 0.4
6 Alpha parameter for generalized Hamming window <=1.0 float alpha 0.5
7 Ripple, dB for Chebyshev Window float dbripple 0.5
8 Transition Width Chebyshev Window float twidth 0.1
9 Attenuation for Kaiser Window float att 30.0
Top
States
Num Type Name Initial Value Description
0 float* x_P
1 float* h_P
2 int N
Top

Declarations


 

   	int i;
   	int j;
	int status;
	int numberTaps;
	float tmp1,tmp2;
        float sum;
	int	no_samples;
	FILE *fopen();
	FILE *imp_F;



Top

Initialization Code



 

	status=FIRDesign(fc,fl,fh,alpha,dbripple,twidth,att,
				ntap,windType,filterType);
	if(status) {
		fprintf(stderr,"firfil: Error in FIR design.\n");
		return(4);
	}
	/*
	 * open file containing impulse response samples. Check 
	 * to see if it exists.
	 *
	 */
        if( (imp_F = fopen("tmp.tap","r")) == NULL) {
		fprintf(stderr,"firfil:tmp.tap file could not be opened.\n");
		return(4);
	}
	fscanf(imp_F,"%d",&numberTaps);
	/*
	 * Allocate memory and return pointers for tapped delay line x_P and
	 * array containing impulse response samples, h_P.
	 *
	 */
	if( (x_P = (float*)calloc(numberTaps,sizeof(float))) == NULL ||
	    (h_P = (float*)calloc(numberTaps,sizeof(float))) == NULL ) {
	   	fprintf(stderr,"firfil: can't allocate work space\n");
		return(4);
	}
	/*
	 * Read in the impulse response samples into the array
	 * and initialize the tapped delay line to zero.
	 *
	 */
	for (i=0; i
    
Top

Main Code



 




	for(no_samples=MIN_AVAIL();no_samples >0; --no_samples) {
		IT_IN(0);
		/*
		 * Shift input sample into tapped delay line
		 */
		tmp2=x(0);
		for(i=0; i
    
Top

Wrapup Code



 

	free(x_P); free(h_P); 




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



 

/* firfil.s */
/***********************************************************************
                             firfil()
************************************************************************
This star designs FIR low pass, high pass, band pass, and band stop 
filters using the windowing method.
The star stores the specs of the FIR filter in the file tmp.spec.
The star stores the FIR filter taps in the file tmp.tap.
Date:  October 19, 1989 
Programmer: Sasan H. Ardalan. 

firfil


This star designs FIR low pass, highj pass, band pass, and band stop 
filters using the windowing method.
The star stores the specs of the FIR filter in the file tmp.spec.
The star stores the FIR filter taps in the file tmp.tap.


Date:  October 19, 1989 
Programmer: Sasan H. Ardalan. 

*/