bpf

Capsim Block Documentation

Short Description

Star implements a band pass IIR digital filter.

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 Sampling Frequency float fs 8000.0
1 Center Frequency float freq 1000.0
2 Modulus: determines Q. Must be < 1.0 float ro 0.99
Top
States
Num Type Name Initial Value Description
0 float xs[3]
1 float ys[3]
Top

Declarations


 

   	int i;
        float tetha;
	int	 no_samples;



Top

Initialization Code



 

         for (i=0; i<3; i++)
             {
              xs[i] = 0.0; 
              ys[i] = 0.0; 
             }
              tetha=0.0;




Top

Main Code



 


	for(no_samples=MIN_AVAIL();no_samples >0; --no_samples) {
       		IT_IN(0);
                tetha = (2.0* (PI * freq) ) / fs;
		xs[0] = x(0);
               /*
                *
                * Calculate the next output.
                *
                */
                ys[0] = xs[0]-xs[2]+2.0*ro*cos(tetha)*ys[1]-ro*ro*ys[2];  
                if(IT_OUT(0)) {
			KrnOverflow("bpf",0);
			return(99);
		}
                y(0)=ys[0];
                xs[2] = xs[1];
		xs[1] = xs[0];
                ys[2] = ys[1];
                ys[1] = ys[0];
               }
        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



 

/* bpf.s */
/***********************************************************************
                             bpf()
************************************************************************
Star implements a band pass IIR digital filter.
Parameters ; 
             fs: sampling frequency
             freq: resonant frequency
	     ro: magnitude of the pole (less than one, for stability)
                 ( Q increases when magnitude of the pole approaches
                  to the unit circle, i.e. when ro is close to one.)
Date:  November 23, 1988
Mod:   November 29, 1988 (Another zero ,at -1, is added.) 
Programmer:  Tulay ADALI

bpf


Star implements a band pass IIR digital filter.
Parameters ; 
             fs: sampling frequency
             freq: resonant frequency
	     ro: magnitude of the pole (less than one, for stability)
                 ( Q increases when magnitude of the pole approaches
                  to the unit circle, i.e. when ro is close to one.)


Date:  November 23, 1988
Mod:   November 29, 1988 (Another zero ,at -1, is added.) 
Programmer:  Tulay ADALI

*/