Chris@0
|
1 #!/bin/bash
|
Chris@0
|
2
|
Chris@119
|
3 . ../include.sh
|
Chris@0
|
4
|
Chris@119
|
5 infile=$audiopath/3clicks8.wav
|
Chris@0
|
6 tmpdir=$mypath/tmp_1_$$.dir
|
Chris@0
|
7 tmpwav=$tmpdir/test.wav
|
Chris@0
|
8
|
Chris@0
|
9 trap "rm -rf $tmpdir" 0
|
Chris@0
|
10
|
Chris@0
|
11 types=`\
|
Chris@0
|
12 $r --help 2>&1 | \
|
Chris@0
|
13 grep 'Supported writer types are:' | \
|
Chris@0
|
14 sed -e 's/^.*://' -e 's/[,\.]//g' \
|
Chris@0
|
15 `
|
Chris@0
|
16 [ -n "$types" ] || \
|
Chris@0
|
17 fail "Fails to report sensible list of writers in help text?"
|
Chris@0
|
18
|
Chris@119
|
19 onsets=$mypath/transforms/percussiononsets-onsets.n3
|
Chris@119
|
20 df=$mypath/transforms/percussiononsets-detectionfunction.n3
|
Chris@0
|
21
|
Chris@0
|
22 adbdir=$tmpdir/audiodb-test
|
Chris@0
|
23 mkdir -p $adbdir
|
Chris@0
|
24
|
Chris@0
|
25 for type in $types; do
|
Chris@0
|
26
|
Chris@0
|
27 mkdir -p $tmpdir
|
Chris@0
|
28 cp $infile $tmpwav
|
Chris@0
|
29
|
Chris@0
|
30 # Some of these are special cases:
|
Chris@0
|
31 #
|
Chris@0
|
32 # * The "default" writer type always prints to stdout instead of
|
Chris@0
|
33 # to a file.
|
Chris@0
|
34 #
|
Chris@0
|
35 # * The "audiodb" writer will not print any output for features
|
Chris@0
|
36 # that have no values (but are only point events). I don't know
|
Chris@0
|
37 # how reasonable that is, but it's clearly intentional. It also
|
Chris@0
|
38 # writes to a subdirectory $basedir/$catid/$trackid.$output
|
Chris@0
|
39
|
Chris@0
|
40 case $type in
|
Chris@0
|
41 audiodb)
|
Chris@0
|
42 $r -t $df -w $type $tmpwav --audiodb-basedir $tmpdir --audiodb-catid `basename $adbdir` 2>/dev/null || \
|
Chris@0
|
43 fail "Fails to run with reader type \"$type\" and default options"
|
Chris@0
|
44 ;;
|
Chris@0
|
45 default)
|
Chris@0
|
46 $r -t $onsets -w $type $tmpwav > $tmpdir/test.out 2>/dev/null || \
|
Chris@0
|
47 fail "Fails to run with reader type \"$type\" and default options"
|
Chris@0
|
48 ;;
|
Chris@0
|
49 *)
|
Chris@0
|
50 $r -t $onsets -w $type $tmpwav 2>/dev/null || \
|
Chris@0
|
51 fail "Fails to run with reader type \"$type\" and default options"
|
Chris@0
|
52 ;;
|
Chris@0
|
53 esac
|
Chris@0
|
54 newfiles=`ls $tmpdir | fgrep -v .wav`
|
Chris@0
|
55 if [ "$type" = audiodb ]; then newfiles=`ls $adbdir`; fi
|
Chris@0
|
56
|
Chris@0
|
57 [ -n "$newfiles" ] || \
|
Chris@0
|
58 fail "Fails to create output file for reader \"$type\" with default options"
|
Chris@0
|
59
|
Chris@0
|
60 case `echo $newfiles | wc -w` in
|
Chris@0
|
61 [2-9])
|
Chris@0
|
62 if [ "$type" != audiodb ]; then
|
Chris@0
|
63 fail "Produces more than one output file for reader \"$type\" with default options"
|
Chris@0
|
64 fi
|
Chris@0
|
65 ;;
|
Chris@0
|
66 1)
|
Chris@0
|
67 if [ "$type" = audiodb ]; then
|
Chris@0
|
68 fail "Produces only one output file for reader \"$type\" with default options (expected two)"
|
Chris@0
|
69 fi
|
Chris@0
|
70 ;;
|
Chris@0
|
71 esac
|
Chris@0
|
72
|
Chris@0
|
73 rm -r $tmpdir
|
Chris@0
|
74 done
|
Chris@0
|
75
|
Chris@119
|
76 exit 0
|
Chris@119
|
77
|