Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -54,7 +54,7 @@ does not scale to very long lists · 53 unmodified lines | |||
| 54 | """ | 54 | """ |
| 55 | 55 | ||
| 56 | import sys | 56 | import sys |
| 57 | from aubio.onsetcompare import onset_roc | 57 | from aubio.onsetcompare import onset_roc, onset_diffs |
| 58 | from aubio.txtfile import read_datafile | 58 | from aubio.txtfile import read_datafile |
| 59 | 59 | ||
| 60 | # default values | 60 | # default values |
| @@ -62,6 +62,8 @@ fileo=None;filec=None;vmode=None;dmode=None;delay=0. · 1 unmodified line | |||
| 62 | # default tolerance is 50 ms | 62 | # default tolerance is 50 ms |
| 63 | #tol = 0.050 | 63 | #tol = 0.050 |
| 64 | tol = 0.048 | 64 | tol = 0.048 |
| 65 | # default mode is onset | ||
| 66 | mode = 'onset' | ||
| 65 | 67 | ||
| 66 | while len(sys.argv) >=2: | 68 | while len(sys.argv) >=2: |
| 67 | option = sys.argv[1]; del sys.argv[1] | 69 | option = sys.argv[1]; del sys.argv[1] |
| @@ -72,6 +74,7 @@ while len(sys.argv) >=2: · 4 unmodified lines | |||
| 72 | if option == '-d': dmode = 'debug' | 74 | if option == '-d': dmode = 'debug' |
| 73 | if option == '-D': delay = float(sys.argv[1]); del sys.argv[1] | 75 | if option == '-D': delay = float(sys.argv[1]); del sys.argv[1] |
| 74 | if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1] | 76 | if option == '-tol': tol = float(sys.argv[1]); del sys.argv[1] |
| 77 | if option == '-l': mode = 'localisation' | ||
| 75 | 78 | ||
| 76 | # arguments required | 79 | # arguments required |
| 77 | if (not fileo) or (not filec): | 80 | if (not fileo) or (not filec): |
| @@ -86,15 +89,18 @@ if delay: · 8 unmodified lines | |||
| 86 | for i in range(len(lres)): | 89 | for i in range(len(lres)): |
| 87 | lres[i] = lres[i] + delay | 90 | lres[i] = lres[i] + delay |
| 88 | # compute errors types | 91 | # compute errors types |
| 89 | orig, missed, merged, expc, bad, doubled = \ | 92 | if mode == 'localisation': |
| 90 | onset_roc(ltru,lres,tol) | 93 | l = onset_diffs(ltru,lres,tol) |
| 91 | 94 | for i in l: print i | |
| 92 | # print results | ||
| 93 | #print "orig, missed, merged, expc, bad, doubled:" | ||
| 94 | if vmode=='verbose': | ||
| 95 | print "GD %2.8f\t" % (100*float(orig-missed-merged)/(orig)), | ||
| 96 | print "FP %2.8f\t" % (100*float(bad+doubled)/(orig)) , | ||
| 97 | print "GD-merged %2.8f\t" % (100*float(orig-missed)/(orig)) , | ||
| 98 | print "FP-pruned %2.8f\t" % (100*float(bad)/(orig)) | ||
| 99 | else: | 95 | else: |
| 100 | print orig, missed, merged, expc, bad, doubled | 96 | orig, missed, merged, expc, bad, doubled = onset_roc(ltru,lres,tol) |
| 97 | |||
| 98 | # print results | ||
| 99 | #print "orig, missed, merged, expc, bad, doubled:" | ||
| 100 | if vmode=='verbose': | ||
| 101 | print "GD %2.8f\t" % (100*float(orig-missed-merged)/(orig)), | ||
| 102 | print "FP %2.8f\t" % (100*float(bad+doubled)/(orig)) , | ||
| 103 | print "GD-merged %2.8f\t" % (100*float(orig-missed)/(orig)) , | ||
| 104 | print "FP-pruned %2.8f\t" % (100*float(bad)/(orig)) | ||
| 105 | else: | ||
| 106 | print orig, missed, merged, expc, bad, doubled | ||