Chris@50: #!/bin/bash Chris@50: Chris@119: . ../include.sh Chris@50: Chris@119: infile1=$audiopath/3clicks8.wav Chris@119: infile2=$audiopath/6clicks8.wav Chris@50: Chris@154: outfile1=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.lab Chris@154: outfile2=$audiopath/6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.lab Chris@50: Chris@119: infile1dot=$audiopath/3.clicks.8.wav Chris@154: outfile1dot=$audiopath/3.clicks.8_vamp_vamp-example-plugins_percussiononsets_onsets.lab Chris@50: Chris@154: outfile3=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.lab Chris@154: outfile4=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.lab Chris@50: Chris@154: tmplab=$mypath/tmp_1_$$.lab Chris@50: Chris@154: trap "rm -f $tmplab $outfile1 $outfile2 $outfile3 $outfile4 $infile1dot $outfile1dot" 0 Chris@50: Chris@119: transformdir=$mypath/transforms Chris@50: Chris@154: check_lab() { Chris@50: test -f $1 || \ Chris@50: fail "Fails to write output to expected location $1 for $2" Chris@154: # every line must contain the same number of tabs Chris@154: formats=`awk -F'\t' '{ print NF; }' $1 | sort | uniq | wc | awk '{ print $1 }'` Chris@50: if [ "$formats" != "1" ]; then Chris@154: fail "Output is not consistently formatted tab-separated file for $2" Chris@50: fi Chris@50: rm -f $1 Chris@50: } Chris@50: Chris@50: Chris@154: ctx="onsets transform, one audio file, default LAB writer destination" Chris@50: Chris@50: rm -f $outfile1 Chris@50: Chris@154: $r -t $transformdir/onsets.n3 -w lab $infile1 2>/dev/null || \ Chris@50: fail "Fails to run with $ctx" Chris@50: Chris@154: check_lab $outfile1 "$ctx" Chris@50: Chris@50: Chris@154: ctx="onsets transform, one audio file with dots in filename, default LAB writer destination" Chris@50: Chris@50: rm -f $outfile1 Chris@50: Chris@50: cp $infile1 $infile1dot Chris@50: Chris@154: $r -t $transformdir/onsets.n3 -w lab $infile1dot 2>/dev/null || \ Chris@50: fail "Fails to run with $ctx" Chris@50: Chris@154: check_lab $outfile1dot "$ctx" Chris@50: Chris@50: rm -f $infile1dot $outfile1dot Chris@50: Chris@50: Chris@154: ctx="onsets and df transforms, one audio file, default LAB writer destination" Chris@50: Chris@50: rm -f $outfile1 Chris@50: Chris@154: $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w lab $infile1 2>/dev/null || \ Chris@50: fail "Fails to run with $ctx" Chris@50: Chris@154: check_lab $outfile1 "$ctx" Chris@50: Chris@50: Chris@154: ctx="onsets transform, two audio files, default LAB writer destination" Chris@50: Chris@50: rm -f $outfile1 Chris@50: rm -f $outfile2 Chris@50: Chris@154: $r -t $transformdir/onsets.n3 -w lab $infile1 $infile2 2>/dev/null || \ Chris@50: fail "Fails to run with $ctx" Chris@50: Chris@154: check_lab $outfile1 "$ctx" Chris@154: check_lab $outfile2 "$ctx" Chris@50: Chris@50: Chris@154: ctx="onsets transform, two audio files, one-file LAB writer" Chris@50: Chris@154: # Writer should refuse to write results from more than one audio file Chris@154: # together (as the audio file is not identified) Chris@154: Chris@154: $r -t $transformdir/onsets.n3 -w lab --lab-one-file $tmplab $infile1 $infile2 2>/dev/null && \ Chris@154: fail "Fails by completing successfully with $ctx" Chris@154: Chris@154: Chris@154: ctx="onsets transform, two audio files, stdout LAB writer" Chris@154: Chris@154: $r -t $transformdir/onsets.n3 -w lab --lab-stdout $infile1 $infile2 2>/dev/null >$tmplab || \ Chris@50: fail "Fails to run with $ctx" Chris@50: Chris@154: check_lab $tmplab "$ctx" Chris@50: Chris@50: Chris@154: ctx="existing output file and no --lab-force" Chris@50: Chris@50: touch $outfile1 Chris@50: Chris@154: $r -t $transformdir/onsets.n3 -w lab $infile1 2>/dev/null && \ Chris@50: fail "Fails by completing successfully when output file already exists (should refuse and bail out)" Chris@50: Chris@50: Chris@154: ctx="existing output file and --lab-force" Chris@50: Chris@50: touch $outfile1 Chris@50: Chris@154: $r -t $transformdir/onsets.n3 -w lab --lab-force $infile1 2>/dev/null || \ Chris@50: fail "Fails to run with $ctx" Chris@50: Chris@154: check_lab $outfile1 "$ctx" Chris@50: Chris@50: exit 0