#!/bin/sh
WAVEDIR=../wave/

pushd .
cd $WAVEDIR
ls *cod*.wav > ~/x
ls *ref*.wav > ~/y
popd

k=0
for count in `cat ~/x`; do
  ((k++))
done

i=0
for ref in `cat ~/y`; do 
  case $ref in 
  "freftri.wav") for((x=0;x<2;x++)); do
                   test=`tail -$((k-i)) ~/x | head -n1`;
                   echo Processing...$ref:$test;
                   ./peaqb -r $WAVEDIR$ref -t $WAVEDIR$test;
                   ((i++))
                 done
                 shift
                 ;;
  esac
  test=`tail -$((k-i)) ~/x | head -n1`;
  echo Processing...$ref:$test;
  ./peaqb -r $WAVEDIR$ref -t $WAVEDIR$test;
  ((i++))
done

rm ~/x
rm ~/y
