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