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

📄 xfir_filt

📁 speech signal process tools
💻
📖 第 1 页 / 共 2 页
字号:
#!/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) 1990-1993  Entropic Research Laboratory, Inc. #                   All rights reserved"## The copyright notice above does not evidence any actual or intended # publication of this source code.     ## @(#)xfir_filt	1.8	7/30/97	ERL# # Written by:  Derek Lin# Checked by:# Revised by:  David Burton - 7/30/97# # Brief description: script cover for all ESPS FIR filter design programs.# USE_ESPS_COMMON=off;export USE_ESPS_COMMONESPS_VERBOSE=0;export ESPS_VERBOSEoutfile=$1 paramfile=$2firkindfile='/tmp/firkind'queryfile='/tmp/Pquery'donefile='/tmp/done'pre_donefile='/tmp/pre_done'cnt='1 2 3 4 5 6 7 8 9 10'PARAM=`get_esps_base`/lib/params/Pxfir_filt#PARAM=./Pxfir_filtif test x$outfile = xthen   echo "ERROR: Output file must be specified"   echo "Usage: xfir_filt feafilt_file [param_file]"   echo "feafilt_file: output ESPS FEA_FILT file"   echo "param_filt: the optional output parameter file created by xfir_filt for"   echo "            input to pkmc_filt or cb_filt"   exitfiexprompt -X0 -Y0 -P $PARAM -h xfir_filt $firkindfile filt_mthd=`getparam -P $firkindfile  -p filt_mthd`filt_type=`getparam -P $firkindfile  -p filt_type`nbands=`getparam -P $firkindfile  -p nbands`samp_freq=`getparam -P$firkindfile  -p samp_freq`echo "#" > $queryfileecho "#" > $donefileecho "#" > $pre_donefileif test $filt_type = 'MULTIBAND'then	echo "WARNING: It is your responsibility to enter valid design"	echo "   parameters for a multiband filters.  Default settings"	echo "   do not work."fiif test $filt_mthd = 'CONSTRAINT_BASED'then#--------CONSTRAINT_BASED LOWPASS --------------------   if test $filt_type = 'LOWPASS'   then	cat >> $queryfile << END	int filt_length_L ?= 31: "Largest Length";	int filt_length_S ?= 21: "Smallest length";	float samp_freq ?= 8000;	int nspec = 5: "number of specifications";	string model ?= "cosine" : "model": {"cosine", "sine"};	string push_direction ?= "neither": "push direction": {"neither", "left", "right"};	string spec1_type ?= "limit":"spec type":{"concave", "limit"};	string spec1_sense ?= "+": "spec sense":{"+", "-"};	float spec1_edge1 ?= 0;	float spec1_edge2 ?= 1600;	float spec1_bound1 ?= 1;	float spec1_bound2 ?= 1;	string spec1_hug ?= "hugged":"spec hug": {"hugged", "not hugged"};	string spec1_interp ?= "arithmetic": "interpolation method": {"arithmetic", "geometric"};	string spec2_type ?= "limit":"spec type":{"concave", "limit"};	string spec2_sense ?= "-": "spec sense":{"+", "-"};	float spec2_edge1 ?= 0;	float spec2_edge2 ?= 1600;	float spec2_bound1 ?= 0.9;	float spec2_bound2 ?= 0.9;	string spec2_hug ?= "not hugged":"spec hug": {"hugged", "not hugged"};	string spec2_interp ?= "arithmetic":"interpolation method": {"arithmetic", "geometric"};	string spec3_type ?= "limit":"spec type":{"concave", "limit"};	string spec3_sense ?= "+": "spec sense":{"+", "-"};	float spec3_edge1 ?= 2000;	float spec3_edge2 ?= 4000;	float spec3_bound1 ?= 0.1;	float spec3_bound2 ?= 0.1;	string spec3_hug ?= "not hugged":"spec hug": {"hugged", "not hugged"};	string spec3_interp ?= "arithmetic":"interpolation method": {"arithmetic", "geometric"};	string spec4_type ?= "limit":"spec type":{"concave", "limit"};	string spec4_sense ?= "-": "spec sense":{"+", "-"};	float spec4_edge1 ?= 2000;	float spec4_edge2 ?= 4000;	float spec4_bound1 ?= -0.1;	float spec4_bound2 ?= -0.1;	string spec4_hug ?= "not hugged":"spec hug": {"hugged", "not hugged"};	string spec4_interp ?= "arithmetic":"interpolation method": {"arithmetic", "geometric"};	string spec5_type ?= "concave": "spec type": {"concave", "limit"};	string spec5_sense ?= "-": "spec sense": {"+", "-"};	float spec5_edge1 ?= 0;	float spec5_edge2 ?= 1600;END	exprompt -X10 -Y10 -P $queryfile  -h cb_filt $donefile		if test x$paramfile != x	then             cp $donefile  $paramfile	fi	    	            cb_filt -P$donefile  $outfile	filtspec -ml $outfile - |plotspec - &   fi#--------CONSTRAINT_BASED HIGHPASS --------------------   if test $filt_type = 'HIGHPASS'   then	cat >> $queryfile << END	int filt_length_L ?= 31: "Largest Length";	int filt_length_S ?= 21: "Smallest length";	float samp_freq ?= 8000;	int nspec = 5: "number of specifications";	string model ?= "cosine" : "model": {"cosine", "sine"};	string push_direction ?= "neither": "push direction": {"neither", "left", "right"};	string spec1_type ?= "limit":"spec type":{"concave", "limit"};	string spec1_sense ?= "+": "spec sense":{"+", "-"};	float spec1_edge1 ?= 0;	float spec1_edge2 ?= 1600;	float spec1_bound1 ?= 0.1;	float spec1_bound2 ?= 0.1;	string spec1_hug ?= "hugged":"spec hug": {"hugged", "not hugged"};	string spec1_interp ?= "arithmetic": "interpolation method": {"arithmetic", "geometric"};	string spec2_type ?= "limit":"spec type":{"concave", "limit"};	string spec2_sense ?= "-": "spec sense":{"+", "-"};	float spec2_edge1 ?= 0;	float spec2_edge2 ?= 1600;	float spec2_bound1 ?= -0.1;	float spec2_bound2 ?= -0.1;	string spec2_hug ?= "not hugged":"spec hug": {"hugged", "not hugged"};	string spec2_interp ?= "arithmetic":"interpolation method": {"arithmetic", "geometric"};	string spec3_type ?= "limit":"spec type":{"concave", "limit"};	string spec3_sense ?= "+": "spec sense":{"+", "-"};	float spec3_edge1 ?= 2000;	float spec3_edge2 ?= 4000;	float spec3_bound1 ?= 1.0;	float spec3_bound2 ?= 1.0;	string spec3_hug ?= "not hugged":"spec hug": {"hugged", "not hugged"};	string spec3_interp ?= "arithmetic":"interpolation method": {"arithmetic", "geometric"};	string spec4_type ?= "limit":"spec type":{"concave", "limit"};	string spec4_sense ?= "-": "spec sense":{"+", "-"};	float spec4_edge1 ?= 2000;	float spec4_edge2 ?= 4000;	float spec4_bound1 ?= 0.9;	float spec4_bound2 ?= 0.9;	string spec4_hug ?= "not hugged":"spec hug": {"hugged", "not hugged"};	string spec4_interp ?= "arithmetic":"interpolation method": {"arithmetic", "geometric"};	string spec5_type ?= "concave": "spec type": {"concave", "limit"};	string spec5_sense ?= "-": "spec sense": {"+", "-"};	float spec5_edge1 ?= 2000;	float spec5_edge2 ?= 4000;END	exprompt -X10 -Y10 -P $queryfile  -h cb_filt $donefile		if test x$paramfile != x	then             cp $donefile  $paramfile	fi	    	            cb_filt -P$donefile  $outfile	filtspec -ml $outfile - |plotspec - &   fi#--------CONSTRAINT_BASED MULTIBAND -------------------   if test $filt_type = 'MULTIBAND'   then	str="int filt_length_L ?= 31:"'"maximum filter length <= 128";'	echo $str >> $queryfile 	str="int filt_length_S ?= 21:"'"minimum filter length >= 1";'	echo $str >> $queryfile 	for i in $cnt	do	    if test $i -le $nbands	    then              str="float band"$i"_edge1 ?= 0.0: "'"left edge for band '$i'";'              echo $str >> $queryfile               str="float band"$i"_edge2 ?= 0.0: "'"right edge for band '$i'";'	      echo $str >> $queryfile               str="float band"$i"_upbound ?= 0: "'"upperbound for band '$i'";'	      echo $str >> $queryfile               str="float band"$i"_lowbound ?= 0: "'"lowerbound for band '$i'";'	      echo $str >> $queryfile 	    fi	done		exprompt -X10 -Y10 -P $queryfile -h cb_filt $pre_donefile	str="float samp_freq = $samp_freq;"	echo $str >> $donefile	str='string model = "cosine";'	echo $str >> $donefile	str='string push_direction = "neither";'	echo $str >> $donefile	filt_length_L=`getparam -P$pre_donefile -p filt_length_L`	filt_length_S=`getparam -P$pre_donefile -p filt_length_S`	str="int filt_length_L = $filt_length_L;"	echo $str >> $donefile	str="int filt_length_S = $filt_length_S;"	echo $str >> $donefile	echo " " >> $donefile# need to translate number of bands into number of specs,# add concavity constraint	i=0	for j in $cnt	do	    if test $j -le $nbands	    then           # + limit spec              i=`echo "$i 1 + p q"|dc`	      str="string spec"$i"_type = "'"limit";'	      echo $str >> $donefile	      str="string spec"$i"_sense = "'"+";'	      echo $str >> $donefile           #spec edges	      edge1=`getparam -P$pre_donefile -p"band"$j"_edge1"`	      str="float spec"$i"_edge1 = $edge1;"	      echo $str >> $donefile	      edge2=`getparam -P$pre_donefile -p"band"$j"_edge2"`	      str="float spec"$i"_edge2 = $edge2;"	      echo $str >> $donefile	   #spec upper bounds	      str="band"$j"_upbound"              up=`getparam -P$pre_donefile -p $str`	      str="float spec"$i"_bound1 = $up;"	      echo $str>> $donefile	      str="float spec"$i"_bound2 = $up;"	      echo $str>> $donefile	      str="string spec"$i"_hug ="'"hugged";'              echo $str >> $donefile	      str="string spec"$i"_interp ="'"arithmetic";'	      echo $str >> $donefile	      echo " " >> $donefile	   #concavity for passband              if test $up -ge 1              then	        i=`echo "$i 1 + p q"|dc`	        str="string spec"$i"_type ="'"concave";'	        echo $str >> $donefile                str="string spec"$i"_sense = "'"-";'	        echo $str >> $donefile	        str="float spec"$i"_edge1 = $edge1;" 	        echo $str >> $donefile	        str="float spec"$i"_edge2 = $edge2;" 	        echo $str >> $donefile	        up=0	      fi	      echo " " >> $donefile           # - limit spec	      i=`echo "$i 1 + p q"|dc`	      str="string spec"$i"_type = "'"limit";'	      echo $str >> $donefile	      str="string spec"$i"_sense = "'"-";'	      echo $str >> $donefile           #spec edges	      edge1=`getparam -P$pre_donefile -p"band"$j"_edge1"`	      str="float spec"$i"_edge1 = $edge1;"	      echo $str >> $donefile	      edge2=`getparam -P$pre_donefile -p"band"$j"_edge2"`	      str="float spec"$i"_edge2 = $edge2;"	      echo $str >> $donefile	   #spec lower bounds	      str="band"$j"_lowbound"              low=`getparam -P$pre_donefile -p $str`	      str="float spec"$i"_bound1 = $low;"	      echo $str>> $donefile	      str="float spec"$i"_bound2 = $low;"	      echo $str>> $donefile              str="string spec"$i"_hug ="'"not hugged";'              echo $str >> $donefile	      str="string spec"$i"_interp ="'"arithmetic";'	      echo $str >> $donefile	      echo " " >> $donefile	   fi	done	str="int nspec ="$i";"	echo $str >> $donefile	if test x$paramfile != x	then             cp $donefile  $paramfile	fi	    	            cb_filt -P$donefile  $outfile	filtspec -ml $outfile - |plotspec - &   fi#-----------CONSTRAINT-BASED DIFFRENTIATOR   if test $filt_type = 'DIFFERENTIATOR'   then	str="int filt_length ?= 16:"'"filter length <= 128";'	echo $str >> $queryfile         str="float pass_edge ?= 2000: "'"passband edge";'        echo $str >> $queryfile         str="float stop_edge ?= 3200: "'"stopband edge";'        echo $str >> $queryfile         str="float slope ?= 1: "'"slope for differentiator";'        echo $str >> $queryfile         str="float deviation ?= 0.01: "'"diviation on the passband";'        echo $str >> $queryfile         str="float stop_upbound ?= 0.01: "'"upperbound for stopband";'        echo $str >> $queryfile         str="float stop_lowbound ?= -0.01: "'"lowerbound for stopband";'        echo $str >> $queryfile 		exprompt -X10 -Y10 -P $queryfile  $pre_donefile	str="float samp_freq = $samp_freq;"	echo $str >> $donefile	str='string model = "sine";'	echo $str >> $donefile	str='string push_direction = "left";'	echo $str >> $donefile	filt_length_L=`getparam -P$pre_donefile -p filt_length`	filt_length_S=$filt_length_L	str="int filt_length_L = $filt_length_L;"	echo $str >> $donefile	str="int filt_length_S = $filt_length_S;"	echo $str >> $donefile	echo " " >> $donefile# need to translate above into 4 specs,     # passband limit spec        str="string spec1_type = "'"limit";'        echo $str >> $donefile	str="string spec1_sense = "'"+";'	echo $str >> $donefile        str="string spec2_type = "'"limit";'	echo $str >> $donefile	str="string spec2_sense = "'"-";'	echo $str >> $donefile     #spec edges	str="float spec1_edge1 = 0;"	echo $str >> $donefile	str="float spec2_edge1 = 0;"	echo $str >> $donefile	pass=`getparam -P$pre_donefile -p pass_edge"`        str="float spec1_edge2 = $pass;"        echo $str >> $donefile        str="float spec2_edge2 = $pass;"        echo $str >> $donefile     #spec upper bounds        slope=`getparam -P$pre_donefile -p slope`        down=0	pass=`echo "5 k $pass $samp_freq / p q"|dc`        up=`echo "5 k $slope $pass * p q"| dc`        dev=`getparam -P$pre_donefile -p deviation`        down_dev=`echo "5 k $down $dev + p q"|dc`        up_dev=`echo "5 k $up $dev + p q"|dc`        str="float spec1_bound1 = $down_dev;"        echo $str>> $donefile        str="float spec1_bound2 = $up_dev;"        echo $str>> $donefile        str="float spec2_bound1 = $down;"        echo $str>> $donefile        str="float spec2_bound2 = $up;"        echo $str>> $donefile        str="string spec1_hug ="'"not hugged";'        echo $str >> $donefile        str="string spec1_interp ="'"arithmetic";'        echo $str >> $donefile        str="string spec2_hug ="'"hugged";'        echo $str >> $donefile        str="string spec2_interp ="'"arithmetic";'        echo $str >> $donefile        echo " " >> $donefile     # stopband limit spec        str="string spec3_type = "'"limit";'        echo $str >> $donefile        str="string spec3_sense = "'"+";'        echo $str >> $donefile        str="string spec4_type = "'"limit";'        echo $str >> $donefile        str="string spec4_sense = "'"-";'        echo $str >> $donefile     #spec edges        stop=`getparam -P$pre_donefile -p stop_edge"`        str="float spec3_edge1 = $stop;"        echo $str >> $donefile        str="float spec3_edge2 = 4000;"        echo $str >> $donefile        str="float spec4_edge1 = $stop;"        echo $str >> $donefile        str="float spec4_edge2 = 4000;"        echo $str >> $donefile     #spec lower bounds        up=`getparam -P$pre_donefile -p stop_upbound`        str="float spec3_bound1 = $up;"        echo $str>> $donefile        str="float spec3_bound2 = $up;"        echo $str>> $donefile        low=`getparam -P$pre_donefile -p stop_lowbound`        str="float spec4_bound1 = $low;"        echo $str>> $donefile        str="float spec4_bound2 = $low;"        echo $str>> $donefile

⌨️ 快捷键说明

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