#!/bin/sh

# Test plots for PLTFILTER
# rename plot files for plot device PS (all uppercase)

# $Id: tpltfilter,v 1.2 1993/02/05 pltfilter-V2R1 $


# usage
verb=`basename $0`
case $# in
0)   dev="PS";;
1)   dev=$1;;
*)   echo "Usage: $verb [plot_device]" 1>&2
     exit 1;;
esac


if [ -f ./pltfilter ]; then
  PLTF=./pltfilter
elif [ -f ../pltfilter ]; then
  PLTF=../pltfilter
else
  PLTF=pltfilter
fi

cat << EoF > test1_FIR.cof
!FIR - Bandpass Filter                        
 -3.49010043E-02   4.30197984E-01   5.69801986E-01   4.30197984E-01
 -3.49010043E-02
EoF
$PLTF test1_FIR.cof $dev sampling_frequency=320E3 amplitude \
	'title="Test 1 FIR"'
rm -f test1_FIR.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf1.epsf
fi

cat << EoF > test2_ALL.cof
!ALL
1, -0.8
EoF
$PLTF test2_ALL.cof $dev << EoF
sampling_frequency=320E6, dB_amplitude_response, log_frequency
title="Test 2 ALL"
EoF
rm -f test2_ALL.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf2.epsf
fi


cat << EoF > test3_IIR.cof
!IIR
 0.1000000E+01  0.1808052E+01  0.1000000E+01  0.7221175E+00  0.2360188E+00
 0.1000000E+01  0.1963544E+01  0.1000000E+01  0.1344155E+01  0.8002729E+00
EoF
$PLTF test3_IIR.cof $dev 'log_amplitude,radian_frequency,title="Test 3 IIR"'
rm -f test3_IIR.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf3.epsf
fi


cat << EoF > test4_IIR.cof
!IIR
 0.1000000E+01 -0.2631026E+01  0.1816858E+01 -0.1448118E+01  0.5504006E+00
 0.1000000E+01 -0.2089076E+01  0.1790429E+01 -0.1166801E+01  0.5585252E+00
 0.1000000E+01 -0.1132810E+01  0.1760286E+01 -0.6435372E+00  0.5680894E+00
 0.1000000E+01  0.3756143E-01  0.1709651E+01  0.2197023E-01  0.5849146E+00
 0.1000000E+01  0.1154556E+01  0.1604867E+01  0.7194088E+00  0.6231045E+00
EoF
$PLTF test4_IIR.cof $dev samp=320E9 delay 'title="Test 4 IIR"'
rm -f test4_IIR.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf4.epsf
fi


cat << EoF > test5_CAS.cof
!CAS
! Analogue C-Message weighting filter coefficients (properly scaled)
!  J.F. Kaiser, IEEE COM, June 1977
0.0  0.0   4.8534341E+29  3625.869  4229994.0
0.0  1.0   0.0            5409.131  3.3901536E+07
0.0  1.0   0.0            10189.79  4.7428726E+08
0.0  1.0   0.0            13336.95  3.0139475E+08
0.0  0.0   1.0            29490.13  7.0321549E+08
EoF
$PLTF test5_CAS.cof $dev 'phase x-limits=(0,4000) title="Test 5 CAS"'
rm -f test5_CAS.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf5.epsf
fi


cat << EoF > test6_IIR.cof
!IIR
! C-message filter coefficients -- J.F. Kaiser, IEEE COM, June 1977
 0.39062500  -0.78125000   0.39062500   0.39843750   0.08203125
 1.00000000  -0.47656250   0.17578125  -1.52343750   0.58203125
 1.00000000   0.20312500  -1.20312500  -1.10937500   0.49218750
EoF
$PLTF test6_IIR.cof $dev samp=8000 radian_phase_response 'title="Test 6 IIR"'
rm -f test6_IIR.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf6.epsf
fi


cat << EoF >  test7_IIR.cof
!IIR
! C-message filter coefficients -- J.F. Kaiser, IEEE COM, June 1977
 0.39062500  -0.78125000   0.39062500   0.39843750   0.08203125
 1.00000000  -0.47656250   0.17578125  -1.52343750   0.58203125
 1.00000000   0.20312500  -1.20312500  -1.10937500   0.49218750
EoF
$PLTF test7_IIR.cof $dev 'samp=320e3 impulse title="Test 7 IIR"'
rm -f  test7_IIR.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf7.epsf
fi


cat << EoF >  test8_FIR.cof
!FIR
! pitch filter
1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0.043 .1864 0.016
EoF
$PLTF test8_FIR.cof $dev amplitude 'title="Test 8 FIR"'
rm -f  test8_FIR.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf8.epsf
fi


cat << EoF >  test9_ALL.cof
!ALL
! pitch filter (doubled components)
2 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0.086 .3728 0.032
EoF
$PLTF test9_ALL.cof $dev impulse  'x=(10,100)' 'Sampl=1' 'title="Test 9 ALL"'
rm -f  test9_ALL.cof
if [ "$dev" = "PS" ]
then
  mv pltfilter.epsf tpf9.epsf
fi
