comparison tests/test-lab-destinations/test-lab-destinations.sh @ 154:6ff4da31db8b labfile

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