#!/usr/bin/env bash

trap "rm -f /tmp/$$.ss.d" EXIT

#Calculate the loudness of the main microphone
#signal, and (incidentally) the spectral slope.
# Loudness in channel 0, spectral slope in channel 1.

P=/home/gpk/oxi/bin
rewrite=0

for n in $(select_fiat_entries.py -show "'%s/%s' % (d, f)" DB.fiat)
do
    echo 'Working on' $n
    o=/tmp/$$.ss.dat
    rm -f $o
    if test $rewrite = 1 -o ! -s $n.ss.dat -o ! -s $n.ss.sd
    then
      rm -f $o
      $P/s_slope3.py -dt 0.010 -f $n.dat -c 0 -o $o ||
		g_die "s_slope3 fails!" || exit 1
      rm -f $n.ss.dat $n.ss.sd
      imop -write BITPIX=-32 r $o q spectral_slope dupBox = $n.ss.dat
      imop -write BITPIX=-32 r $o q spectral_slope dupBox = $n.ss.sd
    fi
done

