예제 #1
0
파일: onset.py 프로젝트: mishnit/aubio
    def eval(self, inputdata, ftru, mode="roc", vmode=""):
        from aubio.txtfile import read_datafile
        from aubio.onsetcompare import onset_roc, onset_diffs, onset_rocloc

        ltru = read_datafile(ftru, depth=0)
        lres = []
        for i in range(len(inputdata)):
            lres.append(inputdata[i][0] * self.params.step)
        if vmode == "verbose":
            print "Running with mode %s" % self.params.onsetmode,
            print " and threshold %f" % self.params.threshold,
            print " on file", self.input
            # print ltru; print lres
        if mode == "local":
            l = onset_diffs(ltru, lres, self.params.tol)
            mean = 0
            for i in l:
                mean += i
            if len(l):
                mean = "%.3f" % (mean / len(l))
            else:
                mean = "?0"
            return l, mean
        elif mode == "roc":
            self.orig, self.missed, self.merged, self.expc, self.bad, self.doubled = onset_roc(
                ltru, lres, self.params.tol
            )
        elif mode == "rocloc":
            self.v = {}
            self.v["orig"], self.v["missed"], self.v["Tm"], self.v["expc"], self.v["bad"], self.v["Td"], self.v[
                "l"
            ], self.v["labs"] = onset_rocloc(ltru, lres, self.params.tol)
예제 #2
0
	def eval(self,inputdata,ftru,mode='roc',vmode=''):
		from aubio.txtfile import read_datafile 
		from aubio.onsetcompare import onset_roc, onset_diffs, onset_rocloc
		ltru = read_datafile(ftru,depth=0)
		lres = []
		for i in range(len(inputdata)): lres.append(inputdata[i][0]*self.params.step)
		if vmode=='verbose':
			print "Running with mode %s" % self.params.onsetmode, 
			print " and threshold %f" % self.params.threshold, 
			print " on file", self.input
		#print ltru; print lres
		if mode == 'local':
			l = onset_diffs(ltru,lres,self.params.tol)
			mean = 0
			for i in l: mean += i
			if len(l): mean = "%.3f" % (mean/len(l))
			else: mean = "?0"
			return l, mean
		elif mode == 'roc':
			self.orig, self.missed, self.merged, \
				self.expc, self.bad, self.doubled = \
				onset_roc(ltru,lres,self.params.tol)
		elif mode == 'rocloc':
			self.v = {}
			self.v['orig'], self.v['missed'], self.v['Tm'], \
				self.v['expc'], self.v['bad'], self.v['Td'], \
				self.v['l'], self.v['labs'] = \
				onset_rocloc(ltru,lres,self.params.tol)