예제 #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)
예제 #3
0
파일: beat.py 프로젝트: Objzilla/aubio
	def gettruth(self):
		import os.path
		from aubio.txtfile import read_datafile
		datafile = self.input.replace('.wav','.txt')
		if not os.path.isfile(datafile):
			print "no ground truth "
			return False,False
		else:
			values = read_datafile(datafile,depth=0)
			old = -1000
			for i in range(len(values)):
				now = values[i]
				period = 60 / (now - old)
				old = now
				values[i] = [now,period]
		return values
예제 #4
0
	def gettruth(self):
		import os.path
		from aubio.txtfile import read_datafile
		datafile = self.input.replace('.wav','.txt')
		if not os.path.isfile(datafile):
			print "no ground truth "
			return False,False
		else:
			values = read_datafile(datafile,depth=0)
			old = -1000
			for i in range(len(values)):
				now = values[i]
				period = 60 / (now - old)
				old = now
				values[i] = [now,period]
		return values
예제 #5
0
파일: pitch.py 프로젝트: Vad-er/aubio
 def gettruth(self):
     """ extract ground truth array in frequency """
     import os.path
     """ from wavfile.txt """
     datafile = self.input.replace('.wav', '.txt')
     if datafile == self.input: datafile = ""
     """ from file.<midinote>.wav """
     # FIXME very weak check
     floatpit = self.input.split('.')[-2]
     if not os.path.isfile(datafile) and len(self.input.split('.')) < 3:
         print "no ground truth "
         return False, False
     elif floatpit:
         try:
             self.truth = float(floatpit)
             #print "ground truth found in filename:", self.truth
             tasksil = tasksilence(self.input, params=self.params)
             time, pitch = [], []
             while (tasksil.readsize == tasksil.params.hopsize):
                 tasksil()
                 time.append(tasksil.params.step * (tasksil.frameread))
                 if not tasksil.issilence:
                     pitch.append(self.truth)
                 else:
                     pitch.append(-1.)
             return time, pitch
         except ValueError:
             # FIXME very weak check
             if not os.path.isfile(datafile):
                 print "no ground truth found"
                 return 0, 0
             else:
                 from aubio.txtfile import read_datafile
                 values = read_datafile(datafile)
                 time, pitch = [], []
                 for i in range(len(values)):
                     time.append(values[i][0])
                     if values[i][1] == 0.0:
                         pitch.append(-1.)
                     else:
                         pitch.append(aubio_freqtomidi(values[i][1]))
                 return time, pitch
예제 #6
0
	def gettruth(self):
		""" extract ground truth array in frequency """
		import os.path
		""" from wavfile.txt """
		datafile = self.input.replace('.wav','.txt')
		if datafile == self.input: datafile = ""
		""" from file.<midinote>.wav """
		# FIXME very weak check
		floatpit = self.input.split('.')[-2]
		if not os.path.isfile(datafile) and len(self.input.split('.')) < 3:
			print "no ground truth "
			return False,False
		elif floatpit:
			try:
				self.truth = float(floatpit)
				#print "ground truth found in filename:", self.truth
				tasksil = tasksilence(self.input,params=self.params)
				time,pitch =[],[]
				while(tasksil.readsize==tasksil.params.hopsize):
					tasksil()
					time.append(tasksil.params.step*(tasksil.frameread))
					if not tasksil.issilence:
						pitch.append(self.truth)
					else:
						pitch.append(-1.)
				return time,pitch
			except ValueError:
				# FIXME very weak check
				if not os.path.isfile(datafile):
					print "no ground truth found"
					return 0,0
				else:
					from aubio.txtfile import read_datafile
					values = read_datafile(datafile)
					time, pitch = [], []
					for i in range(len(values)):
						time.append(values[i][0])
						if values[i][1] == 0.0:
							pitch.append(-1.)
						else:
							pitch.append(aubio_freqtomidi(values[i][1]))
					return time,pitch