Chris@0: #!/bin/bash Chris@0: Chris@119: . ../include.sh Chris@0: Chris@119: infile1=$audiopath/3clicks8.wav Chris@119: infile2=$audiopath/6clicks8.wav Chris@0: Chris@147: infile1dot=$audiopath/3.clicks.8.wav Chris@0: Chris@147: outfile1=3clicks8.mid Chris@147: outfile2=6clicks8.mid Chris@44: Chris@147: outfile3=3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid Chris@147: outfile4=3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid Chris@147: outfile5=6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid Chris@147: outfile6=6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid Chris@0: Chris@147: outfile1dot=3.clicks.8.mid Chris@0: Chris@147: tmpmid=$mypath/tmp_1_$$.mid Chris@147: Chris@147: trap "rm -f $tmpmid $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot $audiopath/$outfile1 $audiopath/$outfile2 $audiopath/$outfile3 $audiopath/$outfile4 $audiopath/$outfile5 $audiopath/$outfile6 $audiopath/$outfile1dot" 0 Chris@0: Chris@119: transformdir=$mypath/transforms Chris@0: Chris@147: check_midi() { Chris@0: test -f $1 || \ Chris@0: fail "Fails to write output to expected location $1 for $2" Chris@147: case $(strings $1 | head -2 | fmt -80) in Chris@147: MThd\ MTrk) ;; Chris@147: *) fail "MIDI output does not look like MIDI in $2";; Chris@147: esac Chris@0: rm -f $1 Chris@0: } Chris@0: Chris@0: Chris@147: ctx="onsets transform, one audio file, default MIDI writer destination" Chris@0: Chris@147: rm -f $audiopath/$outfile1 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $audiopath/$outfile1 "$ctx" Chris@0: Chris@0: Chris@147: ctx="onsets transform, one audio file with dots in filename, default MIDI writer destination" Chris@44: Chris@147: rm -f $audiopath/$outfile1 Chris@44: Chris@44: cp $infile1 $infile1dot Chris@44: Chris@147: $r -t $transformdir/onsets.n3 -w midi $infile1dot 2>/dev/null || \ Chris@44: fail "Fails to run with $ctx" Chris@44: Chris@147: check_midi $audiopath/$outfile1dot "$ctx" Chris@44: Chris@147: rm -f $infile1dot $audiopath/$outfile1dot Chris@44: Chris@44: Chris@147: ctx="onsets and df transforms, one audio file, default MIDI writer destination" Chris@0: Chris@147: rm -f $audiopath/$outfile1 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi $infile1 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $audiopath/$outfile1 "$ctx" Chris@0: Chris@0: Chris@147: ctx="onsets transform, two audio files, default MIDI writer destination" Chris@0: Chris@147: rm -f $audiopath/$outfile1 Chris@147: rm -f $audiopath/$outfile2 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -w midi $infile1 $infile2 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $audiopath/$outfile1 "$ctx" Chris@147: check_midi $audiopath/$outfile2 "$ctx" Chris@0: Chris@0: Chris@147: ctx="onsets transform, two audio files, one-file MIDI writer" Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -w midi --midi-one-file $tmpmid $infile1 $infile2 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $tmpmid "$ctx" Chris@0: Chris@0: Chris@147: ctx="onsets transform, two audio files, stdout MIDI writer" Chris@0: Chris@147: # stdout writer is not supported for midi Chris@147: Chris@147: $r -t $transformdir/onsets.n3 -w midi --midi-stdout $infile1 $infile2 2>/dev/null >$tmpmid && \ Chris@147: fail "Fails by completing successfully with $ctx" Chris@147: Chris@147: Chris@147: ctx="onsets transform, one audio file, many-files MIDI writer" Chris@147: Chris@147: rm -f $audiopath/$outfile3 Chris@147: Chris@147: $r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $audiopath/$outfile3 "$ctx" Chris@0: Chris@0: Chris@147: ctx="onsets transform, two audio files, many-files MIDI writer" Chris@0: Chris@147: rm -f $audiopath/$outfile3 Chris@147: rm -f $audiopath/$outfile5 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $audiopath/$outfile3 "$ctx" Chris@147: check_midi $audiopath/$outfile5 "$ctx" Chris@0: Chris@0: Chris@147: ctx="onsets and df transforms, two audio files, many-files MIDI writer" Chris@0: Chris@147: rm -f $audiopath/$outfile3 Chris@147: rm -f $audiopath/$outfile4 Chris@147: rm -f $audiopath/$outfile5 Chris@147: rm -f $audiopath/$outfile6 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $audiopath/$outfile3 "$ctx" Chris@147: check_midi $audiopath/$outfile4 "$ctx" Chris@147: check_midi $audiopath/$outfile5 "$ctx" Chris@147: check_midi $audiopath/$outfile6 "$ctx" Chris@0: Chris@0: Chris@147: ctx="output base directory" Chris@0: Chris@147: rm -f ./$outfile1 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-basedir . $infile1 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi ./$outfile1 "$ctx" Chris@0: Chris@0: Chris@147: ctx="output base directory and many-files" Chris@0: Chris@147: rm -f ./$outfile3 Chris@147: rm -f ./$outfile5 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -w midi --midi-basedir . --midi-many-files $infile1 $infile2 2>/dev/null || \ Chris@147: fail "Fails to run with $ctx" Chris@147: Chris@147: check_midi ./$outfile3 "$ctx" Chris@147: check_midi ./$outfile5 "$ctx" Chris@147: Chris@147: Chris@147: ctx="nonexistent output base directory" Chris@147: Chris@147: $r -t $transformdir/onsets.n3 -w midi --midi-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \ Chris@147: fail "Fails with $ctx by completing successfully (should refuse and bail out)" Chris@147: Chris@147: Chris@147: ctx="existing output file and no --midi-force" Chris@147: Chris@147: touch $audiopath/$outfile1 Chris@147: Chris@147: $r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null && \ Chris@0: fail "Fails by completing successfully when output file already exists (should refuse and bail out)" Chris@0: Chris@0: Chris@147: ctx="existing output file and --midi-force" Chris@0: Chris@147: touch $audiopath/$outfile1 Chris@0: Chris@147: $r -t $transformdir/onsets.n3 -w midi --midi-force $infile1 2>/dev/null || \ Chris@0: fail "Fails to run with $ctx" Chris@0: Chris@147: check_midi $audiopath/$outfile1 "$ctx" Chris@0: Chris@0: Chris@0: exit 0