annotate tests/test-csv-destinations/test-csv-destinations.sh @ 271:7b3a80021b7c piper-nopiper

Add MAD_BUFFER_GUARD padding at end of mp3 buffer, in order to ensure last frame is decoded successfully (otherwise the decoded audio is truncated). Another thing learned from madplay.
author Chris Cannam
date Thu, 24 Nov 2016 17:06:31 +0000
parents 7a31201dc42d
children
rev   line source
Chris@50 1 #!/bin/bash
Chris@50 2
Chris@119 3 . ../include.sh
Chris@50 4
Chris@119 5 infile1=$audiopath/3clicks8.wav
Chris@119 6 infile2=$audiopath/6clicks8.wav
Chris@50 7
Chris@119 8 outfile1=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@119 9 outfile2=$audiopath/6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@50 10
Chris@119 11 infile1dot=$audiopath/3.clicks.8.wav
Chris@119 12 outfile1dot=$audiopath/3.clicks.8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@50 13
Chris@119 14 outfile3=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.csv
Chris@119 15 outfile4=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.csv
Chris@50 16
Chris@50 17 tmpcsv=$mypath/tmp_1_$$.csv
Chris@50 18
Chris@50 19 trap "rm -f $tmpcsv $outfile1 $outfile2 $outfile3 $outfile4 $infile1dot $outfile1dot" 0
Chris@50 20
Chris@119 21 transformdir=$mypath/transforms
Chris@50 22
Chris@50 23 check_csv() {
Chris@50 24 test -f $1 || \
Chris@50 25 fail "Fails to write output to expected location $1 for $2"
Chris@50 26 # every line must contain the same number of commas
Chris@50 27 formats=`awk -F, '{ print NF; }' $1 | sort | uniq | wc | awk '{ print $1 }'`
Chris@50 28 if [ "$formats" != "1" ]; then
Chris@50 29 fail "Output is not consistently formatted comma-separated file for $2"
Chris@50 30 fi
Chris@50 31 rm -f $1
Chris@50 32 }
Chris@50 33
Chris@50 34
Chris@50 35 ctx="onsets transform, one audio file, default CSV writer destination"
Chris@50 36
Chris@50 37 rm -f $outfile1
Chris@50 38
Chris@119 39 $r -t $transformdir/onsets.n3 -w csv $infile1 2>/dev/null || \
Chris@50 40 fail "Fails to run with $ctx"
Chris@50 41
Chris@50 42 check_csv $outfile1 "$ctx"
Chris@50 43
Chris@50 44
Chris@50 45 ctx="onsets transform, one audio file with dots in filename, default CSV writer destination"
Chris@50 46
Chris@50 47 rm -f $outfile1
Chris@50 48
Chris@50 49 cp $infile1 $infile1dot
Chris@50 50
Chris@119 51 $r -t $transformdir/onsets.n3 -w csv $infile1dot 2>/dev/null || \
Chris@50 52 fail "Fails to run with $ctx"
Chris@50 53
Chris@50 54 check_csv $outfile1dot "$ctx"
Chris@50 55
Chris@50 56 rm -f $infile1dot $outfile1dot
Chris@50 57
Chris@50 58
Chris@50 59 ctx="onsets and df transforms, one audio file, default CSV writer destination"
Chris@50 60
Chris@50 61 rm -f $outfile1
Chris@50 62
Chris@119 63 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w csv $infile1 2>/dev/null || \
Chris@50 64 fail "Fails to run with $ctx"
Chris@50 65
Chris@50 66 check_csv $outfile1 "$ctx"
Chris@50 67
Chris@50 68
Chris@50 69 ctx="onsets transform, two audio files, default CSV writer destination"
Chris@50 70
Chris@50 71 rm -f $outfile1
Chris@50 72 rm -f $outfile2
Chris@50 73
Chris@119 74 $r -t $transformdir/onsets.n3 -w csv $infile1 $infile2 2>/dev/null || \
Chris@50 75 fail "Fails to run with $ctx"
Chris@50 76
Chris@50 77 check_csv $outfile1 "$ctx"
Chris@50 78 check_csv $outfile2 "$ctx"
Chris@50 79
Chris@50 80
Chris@50 81 ctx="onsets transform, two audio files, one-file CSV writer"
Chris@50 82
Chris@119 83 $r -t $transformdir/onsets.n3 -w csv --csv-one-file $tmpcsv $infile1 $infile2 2>/dev/null || \
Chris@50 84 fail "Fails to run with $ctx"
Chris@50 85
Chris@50 86 check_csv $tmpcsv "$ctx"
Chris@50 87
Chris@50 88
Chris@50 89 ctx="onsets transform, two audio files, stdout CSV writer"
Chris@50 90
Chris@119 91 $r -t $transformdir/onsets.n3 -w csv --csv-stdout $infile1 $infile2 2>/dev/null >$tmpcsv || \
Chris@50 92 fail "Fails to run with $ctx"
Chris@50 93
Chris@50 94 check_csv $tmpcsv "$ctx"
Chris@50 95
Chris@50 96
Chris@50 97 ctx="existing output file and no --csv-force"
Chris@50 98
Chris@50 99 touch $outfile1
Chris@50 100
Chris@119 101 $r -t $transformdir/onsets.n3 -w csv $infile1 2>/dev/null && \
Chris@50 102 fail "Fails by completing successfully when output file already exists (should refuse and bail out)"
Chris@50 103
Chris@50 104
Chris@50 105 ctx="existing output file and --csv-force"
Chris@50 106
Chris@50 107 touch $outfile1
Chris@50 108
Chris@119 109 $r -t $transformdir/onsets.n3 -w csv --csv-force $infile1 2>/dev/null || \
Chris@50 110 fail "Fails to run with $ctx"
Chris@50 111
Chris@50 112 check_csv $outfile1 "$ctx"
Chris@50 113
Chris@50 114 exit 0