filtdemo
来自「speech signal process tools」· 代码 · 共 392 行 · 第 1/2 页
TXT
392 行
echo "(save the response in win.spec)"echo " "echo " %filtspec -s 8000 -n513 win.filt - | tee win.spec | plotspec -"filtspec -s 8000 -n513 win.filt - | tee win.spec | plotspec -y-60: -t "FIR multiband by Kaiser-Windowing method by win_filt(1-ESPS)" -W "=450x400+0+0" - 2> /dev/nullrm $paramecho " "###################################BUTTERWORTH##################cat >$param <<EOFstring filt_method = "BUTTERWORTH": "Desired filter type:":{"BUTTERWORTH", "CHEBYSHEV1", "CHEBYSHEV2", "ELLIPTICAL"};float samp_freq = 8000: "Desired sampling frequency.";float gain = 1: "Desired pass band gain.";string filt_type = "LP": "Desired filter reponse":{"LP", "HP","BP","BS"};float pass_band_loss = 1: "Desired maximum pass band loss (dB).";float stop_band_loss = 20.: "Desired minimum stop band attenuation (dB).";float p_freq1 = 500: "Passband frequency 1";float s_freq1 = 1500: "Stopband frequency 1";EOFecho Now design a lowpass IIR filter by the Butterworth methodecho with 0 to 500 Hz as passband, 1500 to 4000 Hz 20dB down stopband.echo " "echo " %iir_filt -P$param butt.filt"iir_filt -P$param butt.filtecho " "echo Compute the spectral response of the lowpass filter, and plot itecho "(save the response in butt.spec)"echo " "echo " %filtspec -s 8000 -n513 butt.filt - | tee butt.spec | plotspec -" filtspec -s 8000 -n513 butt.filt - | tee butt.spec | plotspec -y-50: -t "IIR Butterworth Lowpass by iir_filt(1-ESPS)" -W "=450x400+0+0" - 2> /dev/nullrm $paramecho " "####################################CHEBYSHEV1###################cat >$param <<EOFstring filt_method = "CHEBYSHEV1": "Desired filter type:":{"BUTTERWORTH", "CHEBYSHEV1", "CHEBYSHEV2", "ELLIPTICAL"};float samp_freq = 8000: "Desired sampling frequency.";float gain = 1: "Desired pass band gain.";string filt_type = "HP": "Desired filter reponse":{"LP", "HP","BP","BS"};float pass_band_loss = 1: "Desired maximum pass band loss (dB).";float stop_band_loss = 20.: "Desired minimum stop band attenuation (dB).";float s_freq1 = 1500: "Stopband frequency 1";float p_freq1 = 1800: "Passband frequency 1";EOFecho Now design a highpass IIR filter by Chebyshev I methodecho with 0 to 1500 Hz as 20 dB down stopband and 1800 to 4000 Hz as passband.echo " "echo " %iir_filt -P$param chev1.filt"iir_filt -P$param chev1.filtecho " "echo Compute the spectral response of the highpass filter, and plot itecho "(save the response in chev1.spec)"echo " "echo " %filtspec -s 8000 -n513 chev1.filt - | tee chev1.spec | plotspec -" filtspec -s 8000 -n513 chev1.filt - | tee chev1.spec | plotspec -y-50: -t "IIR Chebyshev I Highpass by iir_filt(1-ESPS)" -W "=450x400+0+0" - 2> /dev/nullrm $paramecho " "###################################CHEBYSHEV II##################cat >$param <<EOFstring filt_method = "CHEBYSHEV2": "Desired filter type:":{"BUTTERWORTH", "CHEBYSHEV1", "CHEBYSHEV2", "ELLIPTICAL"};float samp_freq = 8000: "Desired sampling frequency.";float gain = 1: "Desired pass band gain.";string filt_type = "BP": "Desired filter reponse":{"LP", "HP","BP","BS"};float pass_band_loss = 1: "Desired maximum pass band loss (dB).";float stop_band_loss = 20.: "Desired minimum stop band attenuation (dB).";float p_freq1 = 1500: "Passband frequency 1";float p_freq2 = 2200: "Passband frequency 2";float s_freq1 = 1300: "Stopband frequency 1";float s_freq2 = 2400: "Stopband frequency 2";EOFecho Now design a bandpass IIR filter by Chebyshev II methodecho with passband 1500 to 2200 Hz, and 20 dB down on stopbands of 0 to 1500 Hzecho and 2400 to 4000 Hz.echo " "echo " %iir_filt -P$param chev2.filt"iir_filt -P$param chev2.filtecho " "echo Compute the spectral response of the bandpass filter, and plot itecho "(save the response in chev2.spec)"echo " "echo " %filtspec -s 8000 -n513 chev2.filt - | tee chev2.spec | plotspec -"filtspec -s 8000 -n513 chev2.filt - | tee chev2.spec | plotspec -y-50: -t "IIR Chebyshev II Bandpass by iir_filt(1-ESPS)" -W "=450x400+0+0" - 2> /dev/nullrm $paramecho " "###################################ELLIPTICAL##################cat >$param <<EOFstring filt_method = "ELLIPTICAL": "Desired filter type:":{"BUTTERWORTH", "CHEBYSHEV1", "CHEBYSHEV2", "ELLIPTICAL"};float samp_freq = 8000: "Desired sampling frequency.";float gain = 1: "Desired pass band gain.";string filt_type = "BS": "Desired filter reponse":{"LP", "HP","BP","BS"};float pass_band_loss = 1: "Desired maximum pass band loss (dB).";float stop_band_loss = 65: "Desired minimum stop band attenuation (dB).";float p_freq1 = 1300: "Passband frequency 1";float p_freq2 = 2400: "Passband frequency 2";float s_freq1 = 1500: "Stopband frequency 1";float s_freq2 = 2200: "Stopband frequency 2";EOFecho Now design an bandstop IIR filter by Elliptical polynomial approximation echo technique with 40 dB down on stopband 1500 to 2200 Hz.echo " "echo " %iir_filt -P$param elli.filt"iir_filt -P$param elli.filtecho " "echo Compute the spectral response of the bandstop filter, and plot itecho "(save the response in elli.spec)"echo " "echo " %filtspec -s 8000 -n513 elli.filt - | tee elli.spec | plotspec -"filtspec -s 8000 -n513 elli.filt - | tee elli.spec | plotspec -y-60: -t "IIR Elliptical Bandstop by iir_filt(1-ESPS)" -W "=450x400+0+0" - 2> /dev/nullrm $paramecho " "############FILTERING############FILTERING############FILTERING###########echo Now sampled data files can be filtered using any of the above designedecho "filters by filter(1-ESPS), spectrum for pre-filtered and post-filtered "echo "sampled data can be computed and viewed by refcof(1-ESPS) and me_spec(1-ESPS)"echo " "echo Generate 2500 points of three summed sine waves \(1000Hz, 2000 Hz, and 3000 Hz.\)echo " "echo " %testsd -p2600 -Tsine -f1000 sine1.sd"testsd -p2600 -Tsine -f1000 sine1.sdecho " %testsd -p2600 -Tsine -f3000 - | addsd - sine1.sd sines2.sd"testsd -p2600 -Tsine -f3000 - | addsd - sine1.sd sines2.sdecho " %testsd -p2600 -Tsine -f2000 - | addsd - sines2.sd sines3.sd"testsd -p2600 -Tsine -f2000 - | addsd - sines2.sd sines3.sdecho "Now filter the three sine waves with the notch filter, and then compute"echo "the pre- and post-filter spectrum based on 25th order maximum entropy"echo " "echo "First filter the data."echo " %filter -Fnotch.filt sines3.sd nfiltered.sd"filter -Fnotch.filt sines3.sd nfiltered.sdecho " "#note that the first 100 points (transient) are skippedecho "Now compute reflection coefficients and pipe them to me_spec(1-ESPS)"echo "to compute a maximum entropy spectrum estimate of the pre-filtered signal."echo " %refcof -o25 -p100:+2500 -l0 sines3.sd -\ "echo " | me_spec - sines3.spec"echo " "echo "Finally, compute the spectrum estimate for the post-filtered signal."refcof -o25 -p100:+2500 -l0 sines3.sd - | me_spec - sines3.spececho " %refcof -o25 -p100:+2500 -l0 nfiltered.sd -\ "echo " | me_spec - nfiltered.spec"refcof -o25 -p100:+2500 -l0 nfiltered.sd - | me_spec - nfiltered.spececho " "echo Now filter the three sine waves with the IIR bandstop filter, and thenecho compute the post-filter spectrum based on 25th order maximum entropyecho " "echo " %filter -Felli.filt sines3.sd sfiltered.sd"filter -Felli.filt sines3.sd sfiltered.sdecho " %refcof -o25 -p100:+2500 -l0 sfiltered.sd -\ "echo " | me_spec - sfiltered.spec"refcof -o25 -p100:+2500 -l0 sfiltered.sd - | me_spec - sfiltered.spececho " "sleep 3echo After the demo script finishes, compare the notch filter echo spectral response with the pre- and post-filter sine wave spectrumecho by typing the following commands manually:echo " "echo " %plotspec sines3.spec"echo " %plotspec nfiltered.spec"echo " "echo Then look at the spectral response of the band-stop filter and theecho spectrum after band-stop filtering by manually running the following command:echo " "echo " %plotspec sfiltered.spec"echo " "echo Here is a list of filters and their spectrum file names created in this demoecho " "echo " filter file spectral response file"echo " =========== ======================"echo " notch.filt notch.spec"echo " pkmc.filt pkmc.spec"echo " wmse.filt wmse.spec"echo " cb.filt cb.spec"echo " win.filt win.spec"echo " butt.filt butt.spec"echo " chev1.filt chev1.spec"echo " chev2.filt chev2.spec"echo " elli.filt elli.spec"echo " "echo " "echo "Finally, all filter design programs can be invoked by xeparam(1-ESPS)"echo "and eparam(1-ESPS). For example,"echo " "echo " %xeparam iir_filt my.filt"echo " "echo "for X-windows based interface for parameter input, and"echo " "echo " %eparam iir_filt my.filt"echo " "echo "for command-line prompt style parameter input."echo " "echo "It is also possible to build customized signal processing tool interface"echo "with ESPS using exprompt(1-ESPS), expromptrun(1-ESPS), get_param(1-ESPS),"echo "...etc. See the cover shell script xfir_filt(1-ESPS) as an example to"echo "build X-windows based FIR filter design system."echo " "echo " "
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?