filter.rgeme
来自「speech signal process tools」· RGEME 代码 · 共 935 行 · 第 1/2 页
RGEME
935 行
^dawk '{for(i=0;i<820;i++) print x=0.1}' - >> fm_wt<ret>^dawk '{for(i=0;i<820;i++) print x=1}' - >> fm_wt<ret>^d.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 a much longerdescription of the file contents; the comment is terminated by a control-d on the last line.Many ESPS filter design programs have this mechanism foradding comments to describe the designed filter.The response for this filter is shown on a linear scale in Figure 2-6 and a decibel scalein Figure 2-7..bp.GP fig2-4.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-4: Desired function input to wmse_filt.".GP fig2-5.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-5: Weighting function input to wmse_filt.".bp.GP fig2-6.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-6: Designed with wmse_filt in the points mode.".GP fig2-7.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-7: Designed with wmse_filt in the points mode.".bp.sh 2 "zero_pole".ppThe program .i "zero_pole (5\-\s-1ESPS\s+1)"allows the user todesign a filter by arbitrary placement of poles and zeroes in thecomplex plane. The user simply specifies the pole and zero locationsin one or two ASCII files, and the program computes the coefficientsand deposits them in a FEAFILT (5\-\s-1ESPS\s+1) file..ppThe .i zero_pole program will be demonstrated by converting ananalog Butterworth filter to its discrete equivalent by using the bilineartransformation..[dsp tretter.]The analog filter is a sixth-order low-pass filterwith a 3-dB corner frequency at one eighth the sampling rate. After the transformation,in the Z-domainthis filter has six zeroes at -1, and poles at the following locations:.nf.sp 1 p0 = 0.597716978 + 0.577350268 i p5 = p0 conjugate. p1 = 0.471404518 + 0.333333333 i p4 = p1 conjugate. p2 = 0.420143458 + 0.108741129 i p3 = p2 conjugate..sp 1The filter is then designed with the following command:.sp 1.ul zero_pole -c "Sixth order Butterworth." -g 1 butter6.filt butter6 butter6.sp 1.fi.ppThe \fI-g\fR option is used above to insure that the filter coefficients are normalized to have unity gain at 0 Hz. The ASCII file .i butter6is shown below. Note that if zero and pole locations are both to be read out ofthe same file, it must be given twice on the command line. Also, for any poleor zero off of the real axis, the complex conjugate is automatically includedand therefore should not be listed in the input ASCII file..sp 1Contents of.i butter6:.sp 1.nf6-1.0 0.0-1.0 0.0-1.0 0.0-1.0 0.0-1.0 0.0-1.0 0.030.597716978 0.5773502680.471404518 0.3333333330.420143458 0.108741129.fi.sp.ppThe frequency response of this filter is shown in Figure 2-8..bp.GP fig2-8.gps 3 6 0 0.GE.sp 1.ce.b "Figure 2-8: Filter designed with zero_pole.".sp 1.sh 2 "impulse_resp".sp 1.ppThe program .i "impulse_resp (5\-\s-1ESPS\s+1)"is used to calculate the impulse response of a filter. A specified number ofpoints on the impulse response are calculated and written either to anoutput FEAFILT (5\-\s-1ESPS\s+1) file, to be used as an FIR filter, or to an SD (sampled data)file for plotting in the time domain. As an example, the Butterworth filter designed in the last section will be converted to an FIR filterusing .i impulse_resp..ppTo obtain another FEAFILT (5\-\s-1ESPS\s+1) file from butter6.filt:.sp 1.ul impulse_resp -n 100 butter6.filt butter6_fir.filt.sp 1.ppThe response for this filter is shown in Figure 2-9. If the user wishes toplot the impulse response in the time domain, the following command shouldbe used to obtain an SD file:.sp 1.ul impulse_resp -s -n 100 butter6.filt butter6_fir.sd.sp 1This file is plotted in Figure 2-10 using .i "plotsd (5\-\s-1ESPS\s+1)"..bp.GP fig2-9.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-9: Designed with impulse_resp.".GP fig2-10.gps 3.5 6 0 0.GE.sp 1.ce.b "Figure 2-10: SD file created by impulse_resp.".bp.sh 2 "atofilt".sp 1.ppThe program.i "atofilt (5\-\s-1ESPS\s+1)"is used to convert a set of known filter coefficients into a FEAFILT (5\-\s-1ESPS\s+1) file. Thecoefficients may be placed in one or two ASCII files, or may be typedin directly from the standard input. The user is strongly advised touse the comment facility of this program to recordinformation about the coefficients in the file header..ppAn example command line would be:.sp 1.ul atofilt filter1.filt filter1.num filter1.den.sp 1Since the \fI-c\fR option is not used above, the user will be prompted for hiscomments..sh 2 "iir_filt".sp 1.ppThe program.i "iir_filt (5\-\s-1ESPS\s+1)"designs digital IIR filters by first designing Butterworth or Chebyshev analog filters and then convertingthem to digitalfilters by using the bilinear transformation.\fIIir_filt \fR supports the design of low pass (LP), high pass (HP), band pass (BP), and band stop (BS)filters.The user must specify the sampling frequency, the filter type (\fIe.g.\fRButterworth), filter response type (\fIe.g.\fR low pass), and the order of the filter.These design parameters may be specified in a parameter file, but the easiest way to design IIR filters isby invoking \fIiir_filt\fR with the \fIeparam (1\-\s-1ESPS\s+1)\fRcommand. By doing this,the user is prompted for all the design parameters..ppThe design of a sixth-order low-pass Butterworth filter with a 3-dB cutoff frequency equal to 1000 Hz.(identical to the one shown in Figure 2-8) is shown belowto illustrate the procedure. As before,the initial command line is shown below with the subsequentcomputer prompts following in bold face and the user's responses in regulartype..sp 1.ul eparam iir_filt Bworth6.filt.sp 1.pp.ft BDesired filter order. [3]:.ft6.pp.ft BDesired sampling frequency. [8000.0]:.ft.pp.ft BDesired pass pand gain. [1.0]:.ft.pp.ft BDesired filter type: BUTTERWORTH or CHEBYSHEV1. [BUTTERWORTH]:.ft.pp.ft BDesired filter response: LP, HP, BP, or BS. [LP]:.ft.pp.ft B3 dB (BUTTERWORTH) or critical (CHEBYSHEV) freqs. [0] <250.0>:.ft1000.pp.ft B3 dB (BUTTERWORTH) or critical (CHEBYSHEV) freqs. [1] <0.0>:.ft.sp 1.ppOnly one 3-dB frequency is required for LP and HP filterdesigns;the reply to the prompt for a second 3-dB frequency is ignored by \fIiir_filt\fR.Also notice,several of the defaults (\fIe.g.\fR filter response \- LP)were appropriate for the desired filter,so simply hitting return is enough to specify those parameters.The filter response is shown below in Figure 2-11..bp.GP fig2-11.gps 3 6 0 0.GE.sp 1.ce.b "Figure 2-11: Butterworth filter designed with iir_filt.".sp 2.sh 2 "xpz".sp 1.ppThe program\fIxpz\fP (1\-\s-1ESPS\s+1)designs filters by allowing the user to arbitrarily place poles and zeros.The pole and zerolocations can be specified by interactivelyplacing poles and zeros on the complexZ-plane by using the mouse, or by using a text editor window tospecify their real and imagaginary parts. Changes in filtercharacteristics are immediately displayed in the filterresponse window.See the manual page for more information..sp 2.sh 1 "FILTERING PROGRAMS".sp 1.ppThis section describes the two programs that may be used to filter sampled data:.i "filter (5\-\s-1ESPS\s+1)"and.i "fft_filter (5\-\s-1ESPS\s+1)".\fIFft_filter (5\-\s-1ESPS\s+1)\fRworks with FIR filters only, but \fIfilter2 (5\-\s-1ESPS\s+1)\fRworks with both IIR and FIR fitlers..sp 1.sh 2 "filter2".sp 1.ppThe program .i "filter2 (1-ESPS)"is used to perform a digital filtering operation on sampled data.The program implements FIR or IIR filters and may read itscoefficients from a FEAFILT (5\-\s-1ESPS\s+1) file, or from a parameter file..ppThe following command reads IIR filter coefficients from a parameter fileand filters the data.Note that the filter must be named on the command line to extractthe correct set of coefficients from the parameter file..sp 1.ul filter2 -P params.filt -f low_pass speech.sd filt_speech.sd.sp 1The parameter file .i params.filtis shown below. In this example the filteringoperation begins at the 10,000th point in the input file and processes20,000 points..sp 1Contents of.i params.filt:.sp 1.nf# Don't do the whole file.int start = 10000 : "Starting point for analysis.";int nan = 20000 : "Number of points to process.";# Define the filter. Third order Butterworth.int low_pass_psiz = 2;int low_pass_zsiz = 2;float low_pass_zeros = { -1, 0, -1, 0};float low_pass_poles = { 0.82068, 0, 0.89362, 0.15394};float low_pass_gain = 0.00078484;.fi.sp 2.sh 2 "fft_filter".ppThe program.i "fft_filter (5\-\s-1ESPS\s+1)"implements FIR filtering operations on sampled data by performing theconvolution in the frequency domain rather in the time domain as.i filterdoes. This algorithm is computationally more efficient than thatused by .i filterwhen the number of filter coefficients is large. If $N sub 1$is the number of data points to process and$N sub 2$is the size of the filter, the regular filtering algorithm requireson the order of${N sub 1}{N sub 2}$multiplications. By contrast the algorithm used by.i fft_filterrequires only about$2{N sub 1} log {N sub 2} + {N sub 1}$multiplications..[dsp tretter%P 298-303.]In experimental results on a Masscomp 5600 system, filtering 100,000samples,.i fft_filterrequired only one eighth as much time as.i filterto implement a 401 point filter and 25 % less time to implement a 51 point filter. In implementing an 11 point filter, however,.i fft_filterwas only half as fast as.i filter..ppThe command below illustrates the use of .i fft_filter.Note that if the -F option is used to specify the filter coefficientsand the \fI-p\fR option is used to specify the range of data points, noparameter file is necessary. The command below causes all of thedata in the file to be processed..sp 1.ul fft_filter -F low_pass.filt -p1: input.sd output.sd.sp 2.sh 2 "sfconvert".ppThis program does sampling frequency conversion for input sampled data file.By default, the program designs a lowpass interpolation/decimation filter using the Kaiser windowing method. A tradeoff between the computational time and the output accuracy is balanced by specifying the filter transition bandwidth and stopband rejection ratio..sp 1.ppThe following example converts a CD-quality signal sampled at 44.1 KHz toa telephone-quality signal sampled at 8 KHz. The output signal is band-limited to 3.5 KHz, instead of the 4 KHz Nyquist rate, byspecifying the corner frequency on the command line..sp 1.ul sfconvert -s 8000 -c 3500 music44_1.sd music8.sd.sp 2.sh 1 "FILTER SPECTRAL RESPONSES".ppThe program .i "filtspec (5\-\s-1ESPS\s+1)"is used to find the frequency response of a filter. The program readscoefficients from a FEAFILT (5\-\s-1ESPS\s+1) file and produces an output FEA_SPEC (5\-\s-1ESPS\s+1) file. Theprogram .i "plotspec (5\-\s-1ESPS\s+1)"can then be used to plot the response on a terminalor printer..ppHere are thecommands used to produce theplots shown in this document..nf.sp 1.b "Figure 2-1:".ul 3filtspec -s 8000 -n 8193 notch120.filt notch120.specplotspec -t "Notch centered at 120 Hz. with 20 Hz. bandwidth." -T imagen notch120.spec.sp 1.b "Figure 2-2:".ul 3filtspec -s 8000 bandpass1.filt bandpass1.specplotspec -y -100:50 -t "201 point bandpass filter." -t "Uniform error weighting, no transition band." -T imagen bandpass1.spec.sp 1.b "Figure 2-3:".ul 3filtspec -s 8000 bandpass2.filt bandpass2.specplotspec -y -100:50 -t "201 point bandpass filter." -t "100 Hz. transition bands." -T imagen bandpass2.spec.sp 1.b "Figure 2-6:".ul 3filtspec -s 20000 -m l fm_demod.filt fm_demod.specplotspec -t "401 point FM demodulation filter." -t "Linear scale." -T imagen fm_demod.lspec.sp 1.b "Figure 2-7:".ul 3filtspec -y -100:50 -s 20000 fm_demod.filt fm_demod.specplotspec -t "401 point FM demodulation filter." -t "Decibel Scale." -T imagen fm_demod.spec.sp 1.b "Figure 2-8:".ul 3filtspec -s 8000 butter6.filt butter6.specplotspec -y -100:50 -t "6th order Butterworth filter." -T imagen butter6.filt.sp 1.b "Figure 2-9:".ul 3filtspec -s 8000 butter6_fir.filt butter6_fir.specplotspec -y -100:50 -t "FIR version of 6th order Butterworth filter." -T imagen butter6_fir.spec.sp 1.b "Figure 2-10:".ul 2plotsd -t"Impulse response of butter6.filt." -T imagen butter6_fir.sd.sp 1.b "Figure 2-11:".ul 3filtspec Bworth6.filt Bworth6.specplotspec -y -100:50 -t "IIR version of 6th order Butterworth filter." -T imagen Bworth6.spec.fi.sp 1.sh 1 "REFERENCES".[$LIST$.]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?