⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 我自己改写的Remez,FIR滤波器参数计算程序
💻 TXT
字号:
    -------------------------------------------------------------------------
    README file for Remez FIR Filter Design Program
    Copyright (C) 1999  Jim Ledin (jim@ledin.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    -------------------------------------------------------------------------

This program (remez.exe) designs optimal linear phase FIR filters
using filter specifications read from an input file. It is based
on an implementation of the Parks-McClellan equiripple design program
by Jake Janovetz (janovetz@uiuc.edu).

Input file format:

Statements in the input file can be arranged in free format. There
should be at most one of each type of statement {order, bands,
amplitudes}. {type, weights} are optional statements with default
values as specified below.

Numerical values must be in C floating point format except that
no exponents or minus signs are allowed.

Mandatory statements:

order = integer
    The filter order. The number of filter coefficients =
    order+1.

bands = (number, number) [, (number, number) ...]
    Each pair within parentheses contains the lower and upper
    band edges, with lower listed first. The frequency is
    defined in the range [0,1] where 1 is the Nyquist frequency,
    which is half the sampling rate. Bands must be listed
    in increasing frequency order. The first band must begin at
    0 and the last band must end at 1. The separation between
    bands must be greater than zero to allow for a transition
    region.

amplitudes = number [, number ...]
    Each amplitude goes with the corresponding band in the
    band statement. Amplitudes must be >= 0.

Optional statements:

type = bandpass | hilbert | differentiator
    defaults to bandpass if this statement is not provided. 

weights = number [, number ...]
    Each weight goes with the corresponding band in the
    bands statement. Weights must be greater than 0. All weights
    default to 1 if this statement is not provided.

Comments: Comments can be included in the input file using C/C++ syntax:

// This is a C++ end-of-line comment
/* This is C-style comment */

Example input file (test.rem):

    // Lowpass filter example
    // Note: type defaults to bandpass & weights default to 1
    // This file describes a lowpass filter with a desired amplitude
    // of 1 in the frequency range [0, 0.45] and zero in the range
    // [0.55, 1]. The range [0.45, 0.55] is a transition region.

    // For an 8 KHz sampling rate the Nyquist frequency is 4 Khz and
    // the passband will be 0 to 1800 Hertz and the stopband will be
    // 2200 to 4000 Hertz.

    type = bandpass
    weights = 1, 1
    order = 22
    bands = (0, 0.45), (0.55, 1)
    amplitudes = 1, 0

Execute the command file test.bat to process this file.

The filter.dat output file produced by this example is:

    #define N 23

    static double H[N] =
    {
        -3.279199345817378200e-002,
        -9.447491858515190300e-005,
         2.540825979405659000e-002,
        -7.219108010618943700e-005,
        -3.720689102197431700e-002,
        -6.954083711178532800e-005,
         5.770408717695533300e-002,
        -8.033893988899294400e-005,
        -1.023035371036797900e-001,
        -9.592081101169122500e-005,
         3.171424233766678100e-001,
         4.999104052948560900e-001,
         3.171424233766678100e-001,
        -9.592081101169122500e-005,
        -1.023035371036797900e-001,
        -8.033893988899294400e-005,
         5.770408717695533300e-002,
        -6.954083711178532800e-005,
        -3.720689102197431700e-002,
        -7.219108010618943700e-005,
         2.540825979405659000e-002,
        -9.447491858515190300e-005,
        -3.279199345817378200e-002
    };

Program operation:

usage: remez filename.rem [freqresp.csv] [filename.m]
       filename.rem  = Input filter specifications
       freqresp.csv  = Spreadsheet format frequency response data
       filename.m    = Filter parameters in Matlab format
       C source output file = filter.dat

The filter coefficients are always output to the file filter.dat. The file
filter.c contains a functional, though not very efficient, FIR filter
implementation that #includes filter.dat.

Executing the command: remez lp.rem lp.csv lp.m
will produce the output files filter.dat, lp.csv and lp.m. lp.csv contains
frequency response data for plotting in a program such as Excel. lp.m is a
Matlab script that defines the filter specifications for use with the Matlab
remez function as: remez(N, F, A, W). It also contains the computed impulse
response H which can be compared to the output of the remez function.

Note that it is not necessary to generate the .csv or .m files. To just
generate the filter.dat coefficients use the command:
remez lp.rem

Original program README file:

/**************************************************************************
 * Parks-McClellan algorithm for FIR filter design (C version)
 *-------------------------------------------------
 *  Copyright (c) 1995,1998  Jake Janovetz (janovetz@uiuc.edu)
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 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
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *************************************************************************/

DESCRIPTION:
============
The Parks-McClellan program is a filter design program which creates
optimal filters in the sense that there is equirriple in the pass bands
and stop bands of the resulting frequency response.

This version was written for use in another program in which I required
C access to the design routine.  Therefore, Matlab's 'remez' function
wouldn't do.  I also didn't like all the FORTRAN to C conversions done
because they're impossible to read.  This version is based on the original
FORTRAN code and equations presented in Oppenheim & Schafer.

To use the code, simply include all but 'main' in your own code.  There
is no front end supplied with this code, but that should be simple to
implement.

If any errors are found, please let me know.  I have compared the output
to that of Matlab's 'remez' function and get close (within reasonable
rounding error -- on the order of 1e-13) to the impulse response.  However,
I have not exhaustively tested it with a lot of vectors.
  Jake

COMPILE INSTRUCTIONS:
=====================
To compile the test program that generates a single filter, but asks for
no input (it truly is a test program), very simply type:

   cc -o test test.c remez.c -lm

On a UNIX machine.  You may use other compilers (namely gcc), but you
must link the math libraries (-lm).  If you have problems compiling on
a system, let me know and I'll see what I can do.  The code should be
very portable, though.

Then, you can run the compiled program (test) and watch it generate some
fascinating (!) coefficients.

THANKS:
=======
Thanks to Dr Peter Kootsookos for his help in finding a couple bugs in
the original code.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -