#!/bin/bash
OperaExec="remotepeaq"
MultiplexerSettings="-Mux InpRefLeft=0 ChannelRefLeft=0 InpRefRight=0 ChannelRefRight=0 InpTestLeft=1 ChannelTestLeft=0 InpTestRight=1 ChannelTestRight=0"
DelaySettings=
SignalSettings="-Signal StaticGainOn AutoInvertTestSig DCFilterOn"
Algorithm='-Algorithm Name=PEAQ Settings "Version=0"'

RefFile=$1
TestFile=$2
OutFile=$3
shift
shift
shift

AdditionalOperaSwitches=$1
shift
while [ "$1" != "" ]
do
    if [ "$1" == "-Mux" ] 
    then
	MultiplexerSettings=""
	elif [ "$1" == "-Delay" ]
    then
	DelaySettings=""
    elif [ "$1" == "-Signal" ]
    then
	SignalSettings=""
    fi
    AdditionalOperaSwitches="$AdditionalOperaSwitches $1"
    shift
done
OperaSetings="$MultiplexerSettings $DelaySettings $SignalSettings"

echo Running PEAQ with arguments: $RefFile $TestFile $OutFile $AdditionalOperaSwitches
$OperaExec -Exec $Algorithm -Input Inp=0 File=$RefFile Inp=1 File=$TestFile $OperaSetings -Out $OutFile -Append $AdditionalOperaSwitches

