From 7445aea4eaa48f1083b613251ed50992cc3f5525 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 29 Mar 2005 15:46:05 +0000 Subject: [PATCH] updated aubiocompare-onset and onsetcompare.py --- python/aubio/onsetcompare.py | 6 ++++++ python/aubiocompare-onset | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/python/aubio/onsetcompare.py b/python/aubio/onsetcompare.py index f6ee9fb0..e15c01c0 100644 --- a/python/aubio/onsetcompare.py +++ b/python/aubio/onsetcompare.py @@ -53,6 +53,12 @@ def onset_roc(la, lb, eps): bad += 1 ok = n - missed hits = m - bad + # at this point, we must have ok = hits. if not we had + # - a case were one onset counted for two labels (ok>hits) + # - a case were one labels matched two onsets (hits>ok) + # bad hack for now (fails if both above cases have happened): + if ok > hits: bad += ok-hits; ok = hits + if hits > ok: missed += hits-ok; hits = ok total = n return ok,bad,missed,total,hits diff --git a/python/aubiocompare-onset b/python/aubiocompare-onset index 1d2fe229..3b24a5a0 100755 --- a/python/aubiocompare-onset +++ b/python/aubiocompare-onset @@ -60,7 +60,8 @@ 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.050 +tol = 0.048 while len(sys.argv) >=2: option = sys.argv[1]; del sys.argv[1] @@ -70,6 +71,7 @@ while len(sys.argv) >=2: 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): @@ -80,8 +82,9 @@ if (not fileo) or (not filec): ltru, lres = read_datafile(fileo,depth=0),read_datafile(filec,depth=0) # delay onsets as required with -D -for i in range(len(lres)): - lres[i] = lres[i] + delay +if delay: + for i in range(len(lres)): + lres[i] = lres[i] + delay # compute errors types ok, bad, missed, total, hits = onset_roc(ltru,lres,tol) -- 2.26.2