#!/bin/sh

# This is the first step in processing:
# it converts .wav files for a format that my
# programs can understand.

err="$0: OXILIB needs to be set in the environment. Try /home/mint/gpk/lib."
L=${OXILIB:?$err}

rewrite=0
if test "$1" = '-rewrite'
then
  rewrite=1
fi

for n in $(select_fiat_entries.py -show "'%s/%s' % (d, f)" DB.fiat)
do
    echo 'Working on' $n
    if test ! -s $n.wav
    then
      g_die "No data: $n" || exit 1
    elif test $rewrite = 1 -o $n.wav -nt $n.dat
    then
      rm -f $n.dat
      python $L/wavio.py -wavin $n.wav $n.dat || g_die "Wavio fails!" || exit 1
    fi
done

