filter.rgeme.old
来自「speech signal process tools」· OLD 代码 · 共 935 行 · 第 1/2 页
OLD
935 行
.\" refer -n -p filt.bib -e filter.rgeme | eqn | gpstt | iroff -me -D'prerasterization on' -S /tmp/filter.impress.lo.de SM \"macro to shrink left margin.br.nr $i \\n($i+\\$1i...de RM \"macro to restore original left margin.br.nr $i 0...de MS \"macro for main section (sans serif bold).ft SB.nf\\$1.sp -.8.fi...de SS \"macro for sub-section (sans serif italics).ft SI.nf\\$1.sp -.8.fi...sc.he 'FILTERING APPLICATIONS NOTE''page %'.fo '1.4'\ERL'7/28/89'.nf.ce \s+4\fBENTROPIC RESEARCH LABORATORY, INC.\fR\s-4.sp .75i.ce 100\s+1\fBESPS APPLICATIONS NOTE: Filtering Sampled Data\fP\s-1.sp .3i\fIBrian Sublett and David Burton\fP.sp .3iEntropic Research Laboratory, Inc.600 Pennsylvania Ave SE Suite 202Washington DC 20003(202) 547-1420.sp .5i.fi.ft LR.RM.EQdelim $$.EN.sh 1 "INTRODUCTION".sp 1.ppThe Entropic Signal Processing System (ESPS) contains a variety ofprograms used in the digital filtering of sampled data. Thisdocument introduces the reader to programsthat deal with filtering and illustrates their usethrough some common examples..(f\(co Copyright 1987, 1988 Entropic Speech, Inc., 1991 Entropic Research Laboraroty, Inc.; All rights reserved. .)f.ppDigital filters are characterized by their coefficients. In ESPS,these coefficients are usually stored in FILT (5\-\s-1ESPS\s+1) files. Programsthat create FILT (5\-\s-1ESPS\s+1) files are called filter design programs. These are discussed in Section 2. Programsthat use FILT (5\-\s-1ESPS\s+1) files to perform the digital filtering operation arecalled filtering programs, and Section 3 describes these programs. Finally, Section 4discussesprograms used to calculate and plot the frequency response ortransferfunction of the coefficients in a FILT (5\-\s-1ESPS\s+1) file..sp 1.sh 2 "User Level Programs".ppESPS includes the following user level programs that support the filtering of sampled data. Each of these programs is described in this document..nf.ta 1.5i\fInotch_filt\fP (1\-ESPS) - Design a second order notch filter.\fIwmse_filt\fP (1\-ESPS) - Design an FIR filter using the weighted mean square error criterion.\fIzero_pole\fP (1\-ESPS) - Convert ASCII zero and pole locations to an ESPS FILT (5\-\s-1ESPS\s+1) file.\fIimpulse_resp\fP (1\-ESPS) - Compute unit impulse responses of filters in FILT (5\-\s-1ESPS\s+1) file.\fIatofilt\fP (1\-ESPS) - Convert ASCII files to an ESPS FILT (5\-\s-1ESPS\s+1) file.\fIiir_filt\fP (1\-ESPS) - Design a Recursive (IIR) filter.\fIfilter\fP (1\-ESPS) - Perform digital filtering on a sampled data file.\fIfft_filter\fP (1\-ESPS) - Perform FIR digital filtering using frequency domain convolution.\fIfiltspec\fP (1\-ESPS) - Generate spectral record file for specified records in a FILT (5\-\s-1ESPS\s+1) file..fi.sh 2 "Library Functions".ppThe following ESPS library functions support the use of filters. Libraryfunctions are not discussed in this document. The user should refer to the appropriatesection 3 manual page for further help with filtering library functions..nf.ta 2i\fIallo_filt_rec\fP (3\-ESPS) - Allocate memory for a FILT (5\-\s-1ESPS\s+1) file record.\fIblock_filter\fP (3\-ESPS) - Filter a data array.\fIget_filt_rec\fP (3\-ESPS) - Get the next data record from an ESPS FILT (5\-\s-1ESPS\s+1) file.\fIinterp_filt\fP (3\-ESPS) - Perform interpolation filtering on a data array.\fIprint_filt_rec\fP (3\-ESPS) - Print an ESPS FILT (5\-\s-1ESPS\s+1) record.\fIput_filt_rec\fP (3\-ESPS) - Put an ESPS FILT (5\-\s-1ESPS\s+1) record into a file.\fIpz_to_co\fP (3-ESPS) - Convert pole or zero locations to filter coefficients..fi.sh 1 "FILTER DESIGN".ppThere are two kinds of filters often dicsussed in the literature and text books:finite impulse response (FIR) and infinite impulse response (IIR).FIR filters have only numerator coefficients, and are sometimescalled \fImoving-average\fR or \fIall-zero\fR filters.IIR filters have denominator (and possibly numerator) coefficients,and are also called \fIrecursive\fR filters.ESPS programs provide design support for both types of filters,andthis section describes those programs that calculate filter coefficientsand store them in FILT (5\-\s-1ESPS\s+1) files. .sp 1.sh 2 "notch_filt".ppThe program .i "notch_filt (5\-\s-1ESPS\s+1)" designs a second order IIR filterthat removes or "notches out" a narrow region in the frequencydomain and passes all other frequencies. This is done by placinga zero on the unit circle in the Z-plane at a point corresponding to thisnotch frequency, and then placing a pole very close to it and justinside the unit circle. The complex conjugates of this pole and zeroare also included to guarantee a filter with real coefficients.The frequency response will therefore be zero when evaluated at thezero frequencies, but nearly everywhere else on the unit circle,the effects of the poles and zeroes will cancel..ppTo use .i notch_filt, the user must specify the sampling frequency,the notch frequency, the notch bandwidth, and, of course, the outputfile name. The notch bandwidthis defined as the distance (in the frequency domain) between the-6 dB. points on either side of the notch. The three critical frequencies maybe specified on the command line or in a parameter file. If allthree are specified on the command line, noparameter file is necessary..sh 3 "notch_filt Example.".ppTo illustrate the use of .i notch_filt, a filter will be designed toremove 120 Hz noise from 8 kHz. sampled data. The notch bandwidth willbe 20 Hz. The command for this is:.nf.sp 1.ul 2 notch_filt -s8000 -n120 -b20 notch120.filt.bp.fi.ppThe response for the resulting filter (in the file .i notch120.filt) isshown in Figure 2-1. The commands used to obtain the plot in Figure 2-1are covered in section 4..GP fig2-1.gps 3 6 0 0.GE.sp 1.ce.b "Figure 2-1: Filter designed by notch_filt.".sp 1.sh 2 "wmse_filt".sp 1 .ppThe program .i "wmse_filt (5\-\s-1ESPS\s+1)" designs an FIR filter of specified length using theweighted mean-square-error criterion. The user specifiesa desired frequency response and a weighting function and the program finds the set of filter coefficients whose response minimizes the mean square error withrespect to the desired response, when weighted by the weighting function.In other words, for desired response.i D(f)and weighting function.i W(f),the program finds the coefficients of the filter.i H(f)which minimizes:.nf.ce.if t \{.EQint from W to -W ^{{left |^ D(f) - H(f) right | } sup 2 ~W(f)}~ df.EN\}.if n \{integral (from -W to W) of |D(f)-H(f)|(squared) * W(f) df\}.fiIf uniform weighting is used ( i.e. W(f) = 1 ),the solution to the above equation will simply be the Inverse DiscreteFourier Transform of.i D(f),truncated to the desired number of coefficients..ppThe user may specify the desired response and weighting function in one of twomodes: \fIprompt\fR and \fIpoints\fR. .ppIn "prompt mode" the program assumes that the desired response andthe weighting function are constant throughout a set of adjacentfrequency bands from zero to half the sampling frequency.The user is prompted onstandard output for the sampling frequency, the number of frequency bands,the edges of each band, the desiredmagnitude response of each band, and the weighting value of each band. The user enters these values on standard input.The first band always starts at zero and the last band always ends athalf the sampling frequency.Since the bands are assumed contiguous, the user will only enter .i "nbands+1"edges for.i nbandsbands..ppIn "points mode" the program allows the desired response and weighting function to be arbitrarily shaped and to be specified ata number of uniformly spaced points from zero to half the sampling frequency.The number of points must be one plus a power of two. The point values ofthe desired response and the weighting functionare specified in two ASCII files.The first number in each of these filesis an integer telling how many point values arein the file, and the point values follow.Data in both files may be separated by any combinationof spaces or newlines. The desired response dataand the weighting function data maybe in the same file, in which case the desired response comesfirst and the same file name must be given twice on the command line..ppIn either mode,points on the desired response may be negative in order to cause theresulting filter gain to be negative in that particular region.No part of the weighting function may be negative, however..ppBesides being easier, the prompt mode is more accurate than the points mode if the desired responseand the weighting function are in the right form (\fIi.e.\fR, piecewise constant functions).This is because the design algorithm must calculate the convolution of two infinitetime domain functions. The prompt mode uses an analyticalsolution for this convolution, but the points mode only estimates itusing truncated versions of the two functions. When using the points mode,the accuracy of the solution can be increased by increasing the number ofpoints in the desired response and the weighting function..sp 1.sh 3 "Prompt Mode Example.".ppTo illustrate the "prompt mode" of operation, a simple band pass filter willbe designed. The initial command line is shown below with the subsequentcomputer prompts following in bold face and the user's responses in regulartype. This example uses uniform weighting..sp 1.ul wmse_filt band_pass1.filt.sp 1.pp.ft BPlease enter the number of coefficients: .ft201.pp.ft BPlease enter the number of bands: .ft3.pp.ft BPlease enter the sampling rate: .ft8000.pp.ft BPlease enter the bandedges..ft0 1000 2000 4000.pp.ft BPlease enter the band gains: .ft0 1 0.pp.ft BPlease enter the band weights: .ft1 1 1.pp.nf.ft Bwmse_filt: Please enter comments..pp.ft Bwmse_filt: Must be less than 2047 characters and terminated with ^D..ft.ppThis is a bandpass filter with passband from 1 Khz..ppto 2 Khz. The error was weighted uniformly..fi.sp 1.ppThe response for this filter is shown in Figure 2-2..ppThe user can obtain better stop band rejection by allowing the filterresponse to roll off more slowly than in the above example.This can be accomplished with .i wmse_filt by specifying transitionbands on either side of the passband, where the error is weightedwith a factor of zero. This allows the filter designalgorithm to concentrate the zeroes in the regions of interestsince the error in the transition region can grow arbitrarilylarge without affecting the total weighted error. Note that the desiredresponse function is the same in this example as in the one above, eventhough it is specified by using more bands..sp 1.ul wmse_filt band_pass2.filt.sp 1.pp.ft BPlease enter the number of coefficients: .ft201.pp.ft BPlease enter the number of bands: .ft5.pp.ft BPlease enter the sampling rate: .ft8000.pp.ft BPlease enter the bandedges..ft0 900 1000 2000 2100 4000.pp.ft BPlease enter the band gains: .ft0 0 1 0 0.pp.ft BPlease enter the band weights: .ft1 0 1 0 1.pp.nf.ft Bwmse_filt: Please enter comments..pp.ft Bwmse_filt: Must be less than 2047 characters and terminated with ^D..ft.ppThis is a bandpass filter with passband from 1 Khz..ppto 2 Khz. A 100 Hz. transition region was provided .ppon either side of the passband with zero error weighting..fi.sp 1.ppThe response for this filter is shown in Figure 2-3. Note that thepassband ripple has been reduced and the stop band attenuation has beenincreased by about 30 dB..bp.GP fig2-2.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-2: Filter designed by wmse_filt.".GP fig2-3.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-3: Filter designed by wmse_filt.".bp.sh 3 "Points Mode Example.".ppIn this section, a more complicated filter will be designed using the"points mode" method. Suppose a filter with the characteristics shown in Figure 2-4is desired. This filter, with the amplitude response proportional tofrequency over the range of interest, could be used as an FMdemodulation filter. The weighting function shown in Figure 2-5 will again allow for atransition band..ppBefore the filter can be designed, ASCII files must be created containingthe desired response and the weighting function. For best results, thenumber of points in these functions should be large.These ASCII files can be created easily by using the Masscomputilities .i "gas (1G)" and .i "af (1G)." The .i gas command creates an additivesequence of numbers and the .i af command performs arithmetic functionson these sequences of numbers. For this example, only .i gas is necessary.The desired response function shown in Figure 2-4 contains 1025 points andis created as follows:.sp 1.nfcat > fm_des (This puts the number of points at the beginning of the file.)1025^dgas -s0 -n820 -c1 -i0.012195121 >> fm_desgas -s10 -n100 -c1 -i-0.1 >> fm_desgas -s0 -n105 -c1 -i0 >> fm_des.fi.sp 1.ppThe weighting function shown in Figure 2-5 is createdbelow.The transition band receives low weighting to improve performancein the pass band and stop band..sp 1.nfcat > fm_wt1025^dgas -s1 -n820 -c1 -i0 >> fm_wtgas -s0.1 -n100 -c1 -i0 >> fm_wtgas -s1 -n105 -c1 -i0 >> fm_wt.fi.sp 1.ppThe filter is designed with the following command:.sp 1.nf.ul wmse_filt -c "FM demodulator." -n 401 -d fm_des -w fm_wt fm_demod.filt.fi.spThe commentstring following the \fI-c\fR option will be copied into the comment portion of theoutput file header. If the \fI-c\fR option had not been specified, the programwould have prompted for comments.This allows the user to conveniently enter
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?