From: Paul Brossier Date: Tue, 30 Nov 2004 22:17:19 +0000 (+0000) Subject: updated aubiocut X-Git-Tag: 0.4.0-beta1~1483 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=65f1edc7adf261ce6a3cf8715a2b658cb2b8440e updated aubiocut aubiocut now seeks local minima before the peak, to cut at the beginning of the attack rather than at an arbitrary three frames ahead of the peak. --- diff --git a/python/aubiocut b/python/aubiocut index c9d98d0d..5853fd86 100755 --- a/python/aubiocut +++ b/python/aubiocut @@ -7,9 +7,10 @@ from aubio.aubioclass import * import sys +bufsize = 1024 +hopsize = bufsize/2 + def getonsets(filein,threshold): - bufsize = 1024 - hopsize = bufsize/2 frameread = 0 filei = sndfile(filein) srate = filei.samplerate() @@ -20,20 +21,27 @@ def getonsets(filein,threshold): #newname = "%s%.8f%s" % ("/tmp/",0.0000000,filein[-4:]) #fileo = sndfile(newname,model=filei) mylist = list() + ovalist = [0., 0., 0., 0., 0., 0.] while(readsize==hopsize): readsize = filei.read(hopsize,myvec) isonset,val = opick.do(myvec) + ovalist.append(val) + ovalist.pop(0) if (isonset == 1): - now = (frameread-4)*hopsize/(srate+0.) - #del fileo - #fileo = sndfile("%s%f%s" % ("/tmp/",now,filein[-4:]),model=filei) - mylist.append(now) + print frameread + i=len(ovalist)-1 + # find local minima + while ovalist[i-1] < ovalist[i] and i > 0: + i -= 1 + now = (frameread-i+1)*hopsize/(srate+0.) + #del fileo + #fileo = sndfile("%s%f%s" % ("/tmp/",now,filein[-4:]),model=filei) + mylist.append(now) #writesize = fileo.write(readsize,myoldvec) frameread += 1 return mylist def cutfile(filein,onsets): - hopsize = 512 frameread = 0 readsize = hopsize filei = sndfile(filein)