4 Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
6 This file is part of aubio.
8 aubio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 aubio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with aubio. If not, see <http://www.gnu.org/licenses/>.
26 (both must be text files with 1 time a line expressed in seconds)
29 -D <delay> delay in seconds
34 results:number of correct detections
35 number of incorrect detections
36 number of doubled detections
37 number of total detections
38 number of total targets
41 $ aubioonset-comp -c checked-onsets.txt -o handlab-onsets.txt -v
42 ( gd fp dd ) tot / real
44 55.5555555556 %GD 44.4444444444 %FP 0.0 %OD
47 does not scale to very long lists
51 from aubio.onsetcompare import onset_diffs
52 from aubio.txtfile import read_datafile
55 fileo=None;filec=None;vmode=None;dmode=None;delay=0.
56 # default tolerance is 50 ms
60 while len(sys.argv) >=2:
61 option = sys.argv[1]; del sys.argv[1]
62 if option == '-h': print __HELP__; sys.exit()
63 if option == '-o': fileo = sys.argv[1]; del sys.argv[1]
64 if option == '-c': filec = sys.argv[1]; del sys.argv[1]
65 if option == '-v': vmode = 'verbose'
66 if option == '-d': dmode = 'debug'
67 if option == '-D': delay = float(sys.argv[1]); del sys.argv[1]
68 if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1]
71 if (not fileo) or (not filec):
72 print 'wrong set of arguments. use \'-h\' for help'
73 sys.exit('error: needs at least \'-c targets.txt -o detected.txt\'')
76 ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0)
78 # delay onsets as required with -D
80 for i in range(len(lres)):
81 lres[i] = lres[i] + delay
82 # compute errors types
83 l = onset_diffs(ltru,lres,tol)
84 # print with 1ms precision
85 for i in l: print "%.3f" % float(i)