Chris@0: #!/bin/bash
Chris@0: 
Chris@119: . ../include.sh
Chris@0: 
Chris@119: infile=$audiopath/3clicks8.wav
Chris@0: tmpfile1=$mypath/tmp_1_$$
Chris@0: tmpfile2=$mypath/tmp_2_$$
Chris@0: 
Chris@0: trap "rm -f $tmpfile1 $tmpfile2" 0
Chris@0: 
Chris@118: $r --skeleton $percplug > $tmpfile1 2>/dev/null || \
Chris@118:     fail "Fails to run with --skeleton $percplug"
Chris@0: 
Chris@0: $r -t $tmpfile1 -w csv --csv-stdout $infile > $tmpfile2 2>/dev/null || \
Chris@119:     fail "Fails to run with -t $tmpfile1 -w csv --csv-stdout $infile"
Chris@0: 
Chris@119: csvcompare $tmpfile2 $mypath/expected/skeleton-1.csv || \
Chris@119:     faildiff "Output mismatch for skeleton-1.csv" $tmpfile2 $mypath/expected/skeleton-1.csv
Chris@0: 
Chris@0: for suffix in \
Chris@0:     -no-parameters-default-output \
Chris@0:     -no-parameters \
Chris@0:     "" \
Chris@96:     -start-and-duration \
Chris@0:     -set-parameters \
Chris@0:     -set-step-and-block-size \
Chris@0:     -set-sample-rate \
Chris@51:     -df-windowtype-default \
Chris@51:     -df-windowtype-hanning \
Chris@51:     -df-windowtype-hamming \
Chris@96:     -df-start-and-duration \
Chris@55:     -multiple-outputs \
Chris@99:     -multiple-outputs-start-and-duration \
Chris@0:     ; do
Chris@0: 
Chris@0:     for type in xml n3 ; do 
Chris@0: 
Chris@119: 	transform=$mypath/transforms/percussiononsets$suffix.$type
Chris@119: 	expected=$mypath/expected/percussiononsets$suffix.csv
Chris@0: 
Chris@55: 	if [ ! -f $transform ]; then
Chris@55: 	    if [ $type = "xml" ]; then
Chris@55: 		continue # not everything can be expressed in the XML
Chris@55: 			 # format, e.g. the multiple output test can't
Chris@55: 	    fi
Chris@55: 	fi
Chris@55: 
Chris@0: 	test -f $transform || \
Chris@51: 	    fail "Internal error: no transforms file for suffix $suffix (looking for $transform)"
Chris@0: 
Chris@0: 	test -f $expected || \
Chris@51: 	    fail "Internal error: no expected output file for suffix $suffix (looking for $expected)"
Chris@0: 
Chris@0: 	$r -t $transform -w csv --csv-stdout $infile > $tmpfile2 2>/dev/null || \
Chris@0: 	    fail "Fails to run transform $transform"
Chris@0: 
Chris@28: 	csvcompare $tmpfile2 $expected || \
Chris@108: 	    faildiff "Output mismatch for transform $transform" $tmpfile2 $expected
Chris@0:     done
Chris@0: done
Chris@0: 
Chris@121: # Check we can't run with multiple transforms if one or more is missing!
Chris@121: 
Chris@121: $r -t $mypath/transforms/percussiononsets-set-step-and-block-size.n3 \
Chris@121:    -t $mypath/transforms/squiggly.n3 \
Chris@121:    -t $mypath/transforms/percussiononsets-start-and-duration.n3 \
Chris@121:     -w csv --csv-stdout $infile > $tmpfile2 2>/dev/null && \
Chris@121:     fail "Incorrectly seems to succeed in running with a missing transform file"
Chris@121: 
Chris@121: 
Chris@121: # Check we can run with multiple transforms if they're all present
Chris@121: 
Chris@121: $r -t $mypath/transforms/percussiononsets-set-step-and-block-size.n3 \
Chris@121:    -t $mypath/transforms/percussiononsets-set-parameters.xml \
Chris@121:    -t $mypath/transforms/percussiononsets-start-and-duration.n3 \
Chris@121:     -w csv --csv-stdout $infile > $tmpfile2 2>/dev/null || \
Chris@121:     fail "Fails to run with multiple transforms"
Chris@121: 
Chris@121: csvcompare $tmpfile2 $mypath/expected/multiple.csv || \
Chris@121:     faildiff "Output mismatch for multiple transforms" $tmpfile2 $mypath/expected/multiple.csv
Chris@121: 
Chris@0: exit 0
Chris@0: