annotate tests/test-midi-destinations/test-midi-destinations.sh @ 314:d741e2c90eab

Update Vext and subrepos
author Chris Cannam
date Thu, 13 Jul 2017 17:10:13 +0100
parents 1a6eab755c81
children
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@119 3 . ../include.sh
Chris@0 4
Chris@119 5 infile1=$audiopath/3clicks8.wav
Chris@119 6 infile2=$audiopath/6clicks8.wav
Chris@0 7
Chris@147 8 infile1dot=$audiopath/3.clicks.8.wav
Chris@0 9
Chris@147 10 outfile1=3clicks8.mid
Chris@147 11 outfile2=6clicks8.mid
Chris@44 12
Chris@147 13 outfile3=3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid
Chris@147 14 outfile4=3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid
Chris@147 15 outfile5=6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid
Chris@147 16 outfile6=6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid
Chris@0 17
Chris@147 18 outfile1dot=3.clicks.8.mid
Chris@0 19
Chris@147 20 tmpmid=$mypath/tmp_1_$$.mid
Chris@147 21
Chris@147 22 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 23
Chris@119 24 transformdir=$mypath/transforms
Chris@0 25
Chris@147 26 check_midi() {
Chris@0 27 test -f $1 || \
Chris@0 28 fail "Fails to write output to expected location $1 for $2"
Chris@147 29 case $(strings $1 | head -2 | fmt -80) in
Chris@147 30 MThd\ MTrk) ;;
Chris@147 31 *) fail "MIDI output does not look like MIDI in $2";;
Chris@147 32 esac
Chris@0 33 rm -f $1
Chris@0 34 }
Chris@0 35
Chris@0 36
Chris@147 37 ctx="onsets transform, one audio file, default MIDI writer destination"
Chris@0 38
Chris@147 39 rm -f $audiopath/$outfile1
Chris@0 40
Chris@147 41 $r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null || \
Chris@0 42 fail "Fails to run with $ctx"
Chris@0 43
Chris@147 44 check_midi $audiopath/$outfile1 "$ctx"
Chris@0 45
Chris@0 46
Chris@147 47 ctx="onsets transform, one audio file with dots in filename, default MIDI writer destination"
Chris@44 48
Chris@147 49 rm -f $audiopath/$outfile1
Chris@44 50
Chris@44 51 cp $infile1 $infile1dot
Chris@44 52
Chris@147 53 $r -t $transformdir/onsets.n3 -w midi $infile1dot 2>/dev/null || \
Chris@44 54 fail "Fails to run with $ctx"
Chris@44 55
Chris@147 56 check_midi $audiopath/$outfile1dot "$ctx"
Chris@44 57
Chris@147 58 rm -f $infile1dot $audiopath/$outfile1dot
Chris@44 59
Chris@44 60
Chris@147 61 ctx="onsets and df transforms, one audio file, default MIDI writer destination"
Chris@0 62
Chris@147 63 rm -f $audiopath/$outfile1
Chris@0 64
Chris@147 65 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi $infile1 2>/dev/null || \
Chris@0 66 fail "Fails to run with $ctx"
Chris@0 67
Chris@147 68 check_midi $audiopath/$outfile1 "$ctx"
Chris@0 69
Chris@0 70
Chris@147 71 ctx="onsets transform, two audio files, default MIDI writer destination"
Chris@0 72
Chris@147 73 rm -f $audiopath/$outfile1
Chris@147 74 rm -f $audiopath/$outfile2
Chris@0 75
Chris@147 76 $r -t $transformdir/onsets.n3 -w midi $infile1 $infile2 2>/dev/null || \
Chris@0 77 fail "Fails to run with $ctx"
Chris@0 78
Chris@147 79 check_midi $audiopath/$outfile1 "$ctx"
Chris@147 80 check_midi $audiopath/$outfile2 "$ctx"
Chris@0 81
Chris@0 82
Chris@147 83 ctx="onsets transform, two audio files, one-file MIDI writer"
Chris@0 84
Chris@147 85 $r -t $transformdir/onsets.n3 -w midi --midi-one-file $tmpmid $infile1 $infile2 2>/dev/null || \
Chris@0 86 fail "Fails to run with $ctx"
Chris@0 87
Chris@147 88 check_midi $tmpmid "$ctx"
Chris@0 89
Chris@0 90
Chris@147 91 ctx="onsets transform, two audio files, stdout MIDI writer"
Chris@0 92
Chris@147 93 # stdout writer is not supported for midi
Chris@147 94
Chris@147 95 $r -t $transformdir/onsets.n3 -w midi --midi-stdout $infile1 $infile2 2>/dev/null >$tmpmid && \
Chris@147 96 fail "Fails by completing successfully with $ctx"
Chris@147 97
Chris@147 98
Chris@147 99 ctx="onsets transform, one audio file, many-files MIDI writer"
Chris@147 100
Chris@147 101 rm -f $audiopath/$outfile3
Chris@147 102
Chris@147 103 $r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 2>/dev/null || \
Chris@0 104 fail "Fails to run with $ctx"
Chris@0 105
Chris@147 106 check_midi $audiopath/$outfile3 "$ctx"
Chris@0 107
Chris@0 108
Chris@147 109 ctx="onsets transform, two audio files, many-files MIDI writer"
Chris@0 110
Chris@147 111 rm -f $audiopath/$outfile3
Chris@147 112 rm -f $audiopath/$outfile5
Chris@0 113
Chris@147 114 $r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \
Chris@0 115 fail "Fails to run with $ctx"
Chris@0 116
Chris@147 117 check_midi $audiopath/$outfile3 "$ctx"
Chris@147 118 check_midi $audiopath/$outfile5 "$ctx"
Chris@0 119
Chris@0 120
Chris@147 121 ctx="onsets and df transforms, two audio files, many-files MIDI writer"
Chris@0 122
Chris@147 123 rm -f $audiopath/$outfile3
Chris@147 124 rm -f $audiopath/$outfile4
Chris@147 125 rm -f $audiopath/$outfile5
Chris@147 126 rm -f $audiopath/$outfile6
Chris@0 127
Chris@147 128 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \
Chris@0 129 fail "Fails to run with $ctx"
Chris@0 130
Chris@147 131 check_midi $audiopath/$outfile3 "$ctx"
Chris@147 132 check_midi $audiopath/$outfile4 "$ctx"
Chris@147 133 check_midi $audiopath/$outfile5 "$ctx"
Chris@147 134 check_midi $audiopath/$outfile6 "$ctx"
Chris@0 135
Chris@0 136
Chris@147 137 ctx="output base directory"
Chris@0 138
Chris@147 139 rm -f ./$outfile1
Chris@0 140
Chris@147 141 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-basedir . $infile1 2>/dev/null || \
Chris@0 142 fail "Fails to run with $ctx"
Chris@0 143
Chris@147 144 check_midi ./$outfile1 "$ctx"
Chris@0 145
Chris@0 146
Chris@147 147 ctx="output base directory and many-files"
Chris@0 148
Chris@147 149 rm -f ./$outfile3
Chris@147 150 rm -f ./$outfile5
Chris@0 151
Chris@147 152 $r -t $transformdir/onsets.n3 -w midi --midi-basedir . --midi-many-files $infile1 $infile2 2>/dev/null || \
Chris@147 153 fail "Fails to run with $ctx"
Chris@147 154
Chris@147 155 check_midi ./$outfile3 "$ctx"
Chris@147 156 check_midi ./$outfile5 "$ctx"
Chris@147 157
Chris@147 158
Chris@147 159 ctx="nonexistent output base directory"
Chris@147 160
Chris@147 161 $r -t $transformdir/onsets.n3 -w midi --midi-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \
Chris@147 162 fail "Fails with $ctx by completing successfully (should refuse and bail out)"
Chris@147 163
Chris@147 164
Chris@147 165 ctx="existing output file and no --midi-force"
Chris@147 166
Chris@147 167 touch $audiopath/$outfile1
Chris@147 168
Chris@147 169 $r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null && \
Chris@0 170 fail "Fails by completing successfully when output file already exists (should refuse and bail out)"
Chris@0 171
Chris@0 172
Chris@147 173 ctx="existing output file and --midi-force"
Chris@0 174
Chris@147 175 touch $audiopath/$outfile1
Chris@0 176
Chris@147 177 $r -t $transformdir/onsets.n3 -w midi --midi-force $infile1 2>/dev/null || \
Chris@0 178 fail "Fails to run with $ctx"
Chris@0 179
Chris@147 180 check_midi $audiopath/$outfile1 "$ctx"
Chris@0 181
Chris@0 182
Chris@0 183 exit 0