source: python.old/aubiodiffs-onset @ c34336e

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since c34336e was b554e41, checked in by Paul Brossier <piem@piem.org>, 12 years ago

moved out old python interface

  • Property mode set to 100755
File size: 2.5 KB
Line 
1#! /usr/bin/python
2
3__LICENSE__ = """\
4  Copyright (C) 2004-2009 Paul Brossier <piem@aubio.org>
5
6  This file is part of aubio.
7
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.
12
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.
17
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/>.
20"""           
21
22__HELP__ = """\
23# required arguments
24 -c targetfilename
25 -o detectfilename
26(both must be text files with 1 time a line expressed in seconds)
27
28# optional arguments
29 -D <delay>     delay in seconds
30 -v             verbose mode
31 -d             debug mode
32
33# output
34results:number of correct detections
35        number of incorrect detections
36        number of doubled detections
37        number of total detections
38        number of total targets
39
40# example:
41$ aubioonset-comp -c checked-onsets.txt -o handlab-onsets.txt -v
42( gd fp dd ) tot / real
43( 5 4 0 ) 9 / 9
4455.5555555556 %GD       44.4444444444 %FP       0.0 %OD
45
46# bugs
47does not scale to very long lists
48"""
49
50import sys
51from aubio.onsetcompare import onset_diffs
52from aubio.txtfile import read_datafile
53
54# default values
55fileo=None;filec=None;vmode=None;dmode=None;delay=0.
56# default tolerance is 50 ms
57#tol = 0.050
58tol = 0.048
59
60while 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]
69
70# arguments required
71if (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\'')
74
75# load files
76ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0)
77
78# delay onsets as required with -D
79if delay:
80    for i in range(len(lres)):
81        lres[i] = lres[i] + delay
82# compute errors types
83l = onset_diffs(ltru,lres,tol)
84# print with 1ms precision
85for i in l: print "%.3f" % float(i)
86
Note: See TracBrowser for help on using the repository browser.