#!/bin/csh
#
# Generic option parser for speech scripts
#
# options are supplied in keyword=value format
#

# Actually do the argument parsing here

set fast = 0
set geometry1 = 1200x300+150+0
set geometry2 = 1200x300+150+280
set ft = 16kHzlin
set fussy = 1
set zoom = 0
set trsubdir = trans/

# Actually do the argument parsing here

while ( "$1" != "" )
	switch ("$1")
	case *=*:
		set key = `echo $1 | cut -d= -f1`
		set val = `echo $1 | cut -d= -f2`
		eval "set $key "= \'"$val"\'
		unset key val
		shift
		breaksw
        default:
		break
        endsw
end

# end option parser

set reffile = $1

if( $reffile:e == "16" ) then
  set filetype = raw_s16_
  set frequency = 16000
else if( $reffile:e == "wav" ) then
  set filetype = wav
  set frequency = 16000
else if( $reffile:e == "raw" ) then
  set filetype = raw_s16_
  set frequency = 16000
endif

set sp1 = `echo $1:r | sed 's/^......//'`
set sp2 = `echo $2:r | sed 's/^......//'`

endif

set dlg = `echo $1:r | sed 's/..$//'`

if( -e $1 ) then
  echo found $1. good.
else
  echo missing $1...
  exit
endif

if( -e $2 ) then
  echo found $2. good.
else
  echo missing $2...
  exit
endif

#if( -w $trsubdir$dlg.mar ) then
#echo found $trsubdir$dlg.mar. good.
#else
#  echo missing/not writeable $trsubdir$dlg.mar. Contact vm-admin
#  exit
#endif

#if( -w $trsubdir*.trl ) then
#echo found $trsubdir*.trl. good.
#else
#  echo missing/not writeable $trsubdir$dlg.trl. Contact vm-admin
#  exit
#endif



cat <<EOB>! /tmp/vmussconfig1
SIGNAL
filename=$1
height=125
rows=2
filetype=$filetype
frequency=$frequency
framesize=128
buffsize=500000
reflabel=labeler_ref
zoomon=$zoom
END
EOB

cat <<EOB>! /tmp/vmussconfig2
SIGNAL
filename=$2
height=125
rows=2
filetype=$filetype   
frequency=$frequency
framesize=128
buffsize=500000
reflabel=labeler_ref
zoomon=$zoom
END 
EOB

chmod 666 /tmp/vmussconfig1
chmod 666 /tmp/vmussconfig2

if( `ps | grep -v grep | grep xemacs` != "" ) then
  echo xemacs already running
else
  if ( -e /usr/X11/bin/xemacs ) then
    echo starting xemacs $trsubdir$dlg.trl
    /usr/X11/bin/xemacs -geometry 80x30+0+500 $trsubdir$dlg.trl &
  else
    echo FEHLER: xemacs nicht gefunden !!
  endif
endif

/usr/local/bin/uss-3.4a config=/tmp/vmussconfig1 fast=$fast vmturncut -geometry $geometry1 & 
/usr/local/bin/uss-3.4a config=/tmp/vmussconfig2 fast=$fast vmturncut -geometry $geometry2
