--- /dev/null
+#! /usr/bin/python
+
+"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
+
+print aubio.__LICENSE__ for the terms of use
+
+or see LICENSE.txt in the numarray installation directory.
+"""
+__LICENSE__ = """\
+ Copyright (C) 2004 Paul Brossier <piem@altern.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+
+__HELP__ = """\
+# required arguments
+ -c targetfilename
+ -o detectfilename
+(both must be text files with 1 time a line expressed in seconds)
+
+# optional arguments
+ -D <delay> delay in seconds
+ -v verbose mode
+ -d debug mode
+
+# output
+results:number of correct detections
+ number of incorrect detections
+ number of doubled detections
+ number of total detections
+ number of total targets
+
+# example:
+$ aubioonset-comp -c checked-onsets.txt -o handlab-onsets.txt -v
+( gd fp dd ) tot / real
+( 5 4 0 ) 9 / 9
+55.5555555556 %GD 44.4444444444 %FP 0.0 %OD
+
+# bugs
+does not scale to very long lists
+"""
+
+import sys
+from aubio.onsetcompare import onset_diffs
+from aubio.txtfile import read_datafile
+
+# default values
+fileo=None;filec=None;vmode=None;dmode=None;delay=0.
+# default tolerance is 50 ms
+#tol = 0.050
+tol = 0.048
+
+while len(sys.argv) >=2:
+ option = sys.argv[1]; del sys.argv[1]
+ if option == '-h': print __HELP__; sys.exit()
+ if option == '-o': fileo = sys.argv[1]; del sys.argv[1]
+ if option == '-c': filec = sys.argv[1]; del sys.argv[1]
+ if option == '-v': vmode = 'verbose'
+ if option == '-d': dmode = 'debug'
+ if option == '-D': delay = float(sys.argv[1]); del sys.argv[1]
+ if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1]
+
+# arguments required
+if (not fileo) or (not filec):
+ print 'wrong set of arguments. use \'-h\' for help'
+ sys.exit('error: needs at least \'-c targets.txt -o detected.txt\'')
+
+# load files
+ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0)
+
+# delay onsets as required with -D
+if delay:
+ for i in range(len(lres)):
+ lres[i] = lres[i] + delay
+# compute errors types
+l = onset_diffs(ltru,lres,tol)
+for i in l: print i
+