filtdemo

来自「speech signal process tools」· 代码 · 共 392 行 · 第 1/2 页

TXT
392
字号
#! /bin/sh# This material contains unpublished, proprietary software of# Entropic Research Laboratory, Inc. Any reproduction, distribution,# or publication of this work must be authorized in writing by Entropic# Research Laboratory, Inc., and must bear the notice:##    "Copyright (c) 1986-1990  Entropic Speech, Inc.#    "Copyright (c) 1990-1991  Entropic Research Laboratory, Inc.#                   All rights reserved"## The copyright notice above does not evidence any actual or intended# publication of this source code.## @(#)filtdemo	3.15   6/18/94     ESI/ERL## Written by:# Checked by:# Revised by: Derek Lin## Brief description:  Illustrates basic filter design and filtering#USE_ESPS_COMMON=offESPS_VERBOSE=0export USE_ESPS_COMMONexport ESPS_VERBOSEif test `mach_type` = CONVEX -o `mach_type` = SONY_RISC -o `mach_type` = SONY_68 then  echo This script will fail if you do not have write permission on this directory. else  if test ! -w .     then	echo "You do not have write permission in this directory."	exit 1  fifiparam=./paramdemoecho " "echo IIR and FIR filters with various design methods are created in this echo demo.  Their frequency responses are generated and plotted.  Then aecho test signal is generated and filtered using the designed filters.echo All filters are sampled at 8000 Hz.echo " "echo PRESS THE "QUIT" BUTTON ON PLOTS TO CONTINUEecho " "############################NOTCH_FILT###########################echo Now design a notch filter with 200 Hz wide notch at 2000 Hz.echo " "echo "   %notch_filt -b200 -n2000 -s8000  notch.filt"notch_filt -b200 -n2000 -s8000  notch.filtecho " "echo 'Compute the spectral response of the notch filter (by using filtspec(1-ESPS))'echo 'and plot it by using plotspec(1-ESPS) (save the response in notch.spec).'echo " "echo "   %filtspec -s8000 -n513 notch.filt - | tee notch.spec | plotspec -"filtspec -s8000 -n513 notch.filt - | tee notch.spec | plotspec -t "Notch Response by notch_filt(1-ESPS)" -W "=450x400+0+0" - echo " "#############################PKMC_FILT############################cat > $param << EOFint filt_length = 21;float band1_edge2 = 2000.000000;float band2_edge1 = 3200.000000;float band1_des = 1.000000;float band1_wt = 1.000000;float band2_wt = 1.000000;string filt_type = "DIFFERENTIATOR";float samp_freq = 8000.000000;int nbands = 2;float band1_edge1 = 0.000000;float band2_edge2 = 4000.000000;float band2_des = 0.000000;EOFecho Now design a FIR differentiator by the Parks-McClellan algorithmecho with 21 taps, 0 to 2000 Hz as passband and 3200 to 4000 Hz stopbandecho " "echo "   %pkmc_filt -P$param pkmc.filt"pkmc_filt -P$param pkmc.filtecho " "echo where $param is an ASCII parameter file.  The $param file echo is generated on the fly, and will contain appropriate designecho parameters for all the following design examples.echo " "echo Compute the spectral response of the equiripple filter, and plotecho "in linear scale. (save the response in pkmc.spec)."echo " "echo "   %filtspec -s 8000 -n513 -ml pkmc.filt - | tee pkmc.spec | plotspec -"filtspec -s 8000 -n513 -ml pkmc.filt - | tee pkmc.spec | plotspec -t "FIR Equiripple Differentiator by pkmc_filt(1-ESPS)" -W  "=450x400+0+0" -  rm $paramecho " "##############################CB_FILT################################cat > $param << EOFint filt_length_L = 31;int filt_length_S = 21;float samp_freq = 8000.000000;int nspec = 5;string model = "cosine";string push_direction = "neither";string spec1_type = "limit";string spec1_sense = "+";float spec1_edge1 = 0.000000;float spec1_edge2 = 1500.000000;float spec1_bound1 = 1.000000;float spec1_bound2 = 1.000000;string spec1_hug = "hugged";string spec1_interp = "arithmetic";string spec2_type = "limit";string spec2_sense = "-";float spec2_edge1 = 0.000000;float spec2_edge2 = 1500.000000;float spec2_bound1 = 0.800000;float spec2_bound2 = 0.800000;string spec2_hug = "not hugged";string spec2_interp = "arithmetic";string spec3_type = "limit";string spec3_sense = "+";float spec3_edge1 = 1800.000000;float spec3_edge2 = 4000.000000;float spec3_bound1 = 0.100000;float spec3_bound2 = 0.100000;string spec3_hug = "not hugged";string spec3_interp = "arithmetic";string spec4_type = "limit";string spec4_sense = "-";float spec4_edge1 = 1800.000000;float spec4_edge2 = 4000.000000;float spec4_bound1 = -0.100000;float spec4_bound2 = -0.100000;string spec4_hug = "not hugged";string spec4_interp = "arithmetic";string spec5_type = "concave";string spec5_sense = "-";float spec5_edge1 = 0.000000;float spec5_edge2 = 1500.000000;EOFecho Now design a lowpass FIR filter with maximally flat passband by theecho constraint-based technique, 0 to 1500 Hz as passband, 1800 to 4000 Hz echo as stopband.echo " "echo "   %cb_filt -P$param cb.filt"cb_filt -P$param cb.filtecho Compute the spectral response of the maximally-flat passband filter, echo "and plot it.  (save the response in cb.spec)"echo " "echo "   %filtspec -s 8000 -n513 cb.filt - | tee cb.spec | plotspec -"  filtspec -s 8000 -n513 cb.filt - | tee cb.spec | plotspec -y-40: -t "FIR Maximally Flat Passband by cb_filt(1-ESPS)" -W "=450x400+0+0" - 2> /dev/nullrm $paramecho " "###################################WMSE_FILT####################cat > $param << EOFfloat samp_freq = 8000.000000;int filt_length = 201;int nbands = 2;float band_edge1 = 0.000000;float band_edge2 = 1800.000000;float band_edge3 = 4000.000000;float band1_des = 0.000000;float band2_des = 1.000000;float band1_wt = 1.000000;float band2_wt = 1.000000;EOFecho Now design a highpass FIR filter by the minimum-mean square error criteriaecho with 201 taps, 0 to 1800 Hz as stopband and 1500 to 4000 Hz as passbandecho " "echo "   %wmse_filt -P$param wmse.filt"wmse_filt -P$param wmse.filtecho " "echo Compute the spectral response of the highpass filter, and plot itecho "(save the response in wmse.spec)"echo " "echo "   %filtspec -s 8000 -n513 wmse.filt - | tee wmse.spec | plotspec -"filtspec -s 8000 -n513 wmse.filt - | tee wmse.spec | plotspec -y-50: -t "FIR Lowpass with Weighted Mean Square Error Criteria by wmse_filt(1-ESPS)" -W "=450x400+0+0" -  2> /dev/nullrm $paramecho " "##################################WIN_FILT#####################cat >$param <<EOFfloat band1_des = 0.000000;float band2_des = 1.000000;float band3_des = 0.000000;float band4_des = 1.000000;float band_edge1 = 0.000000;float band_edge2 = 1100.000000;float band_edge3 = 1600.000000;float band_edge4 = 2600.000000;float band_edge5 = 4000.000000;float rej_db = 20.000000;float trans_band = 100.000000;float samp_freq = 8000.000000;int nbands = 4;EOFecho Now design a multiband FIR filter by the Kaiser-Windowing methodecho with passband 1100 to 1600 Hz and 2600 to 4000 Hz.echo " "echo "   %win_filt -P$param win.filt"win_filt -P$param win.filtecho " "echo Compute the spectral response of the multiband filter, and plot it

⌨️ 快捷键说明

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