- Timestamp:
- Dec 22, 2005, 5:54:29 PM (19 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- ada5baf
- Parents:
- 1dae4eb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/tasks.py
r1dae4eb rc32976a5 196 196 197 197 198 class taskparams :198 class taskparams(object): 199 199 """ default parameters for task classes """ 200 200 def __init__(self,input=None,output=None): … … 289 289 def gettruth(self): 290 290 """ big hack to extract midi note from /path/to/file.<midinote>.wav """ 291 return float(self.input.split('.')[-2]) 292 291 floatpit = self.input.split('.')[-2] 292 try: 293 return float(floatpit) 294 except ValueError: 295 print "ERR: no truth file found" 296 return 0 293 297 294 298 def eval(self,results): … … 340 344 self.maxofunc = 0 341 345 if self.params.localmin: 342 ovalist = [0., 0., 0., 0., 0.]346 self.ovalist = [0., 0., 0., 0., 0.] 343 347 344 348 def __call__(self): … … 350 354 self.ofunc.append(val) 351 355 if self.params.localmin: 352 if val > 0: ovalist.append(val)353 else: ovalist.append(0)354 ovalist.pop(0)356 if val > 0: self.ovalist.append(val) 357 else: self.ovalist.append(0) 358 self.ovalist.pop(0) 355 359 if (isonset == 1): 356 360 if self.params.localmin: … … 366 370 return now, val 367 371 372 def gettruth(self): 373 from os.path import isfile 374 ftru = '.'.join(self.input.split('.')[:-1]) 375 ftru = '.'.join((ftru,'txt')) 376 if isfile(ftru): return ftru 377 else: return 378 368 379 def eval(self,lres): 369 380 from txtfile import read_datafile … … 372 383 vmode = 'verbose' 373 384 vmode = '' 385 ftru = self.gettruth() 386 if not ftru: 387 print "ERR: no truth file found" 388 return 389 ltru = read_datafile(ftru,depth=0) 374 390 for i in range(len(lres)): lres[i] = lres[i][0]*self.params.step 375 ltru = read_datafile(self.input.replace('.wav','.txt'),depth=0)376 391 if vmode=='verbose': 377 392 print "Running with mode %s" % self.params.mode, … … 503 518 else: 504 519 writesize = self.fileo.write(self.readsize,self.myvec) 520 521 class taskbeat(taskonset): 522 def __init__(self,input,params=None,output=None): 523 """ open the input file and initialize arguments 524 parameters should be set *before* calling this method. 525 """ 526 taskonset.__init__(self,input,output=None,params=params) 527 self.btwinlen = 512**2/self.params.hopsize 528 self.btstep = self.btwinlen/4 529 self.btoutput = fvec(self.btstep,self.channels) 530 self.dfframe = fvec(self.btwinlen,self.channels) 531 self.bt = beattracking(self.btwinlen,self.channels) 532 self.pos2 = 0 533 534 def __call__(self): 535 taskonset.__call__(self) 536 # write to current file 537 if self.pos2 == self.btstep - 1 : 538 self.bt.do(self.dfframe,self.btoutput) 539 for i in range (self.btwinlen - self.btstep): 540 self.dfframe.set(self.dfframe.get(i+self.btstep,0),i,0) 541 for i in range(self.btwinlen - self.btstep, self.btwinlen): 542 self.dfframe.set(0,i,0) 543 self.pos2 = -1; 544 self.pos2 += 1 545 val = self.opick.pp.getval() 546 self.dfframe.set(val,self.btwinlen - self.btstep + self.pos2,0) 547 i=0 548 for i in range(1,int( self.btoutput.get(0,0) ) ): 549 if self.pos2 == self.btoutput.get(i,0) and \ 550 aubio_silence_detection(self.myvec(), 551 self.params.silence)!=1: 552 return self.frameread, 0 553 554 def eval(self,results): 555 pass
Note: See TracChangeset
for help on using the changeset viewer.