History

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.

Paul Brossier committed 21 years ago

Commit 65f1edc1 parent 00e46591 file · +15 −7Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/aubiocut+15−7
@@ -7,9 +7,10 @@ · 6 unmodified lines
77 from aubio.aubioclass import *
88 import sys
99
10+bufsize = 1024
11+hopsize = bufsize/2
12+
1013 def getonsets(filein,threshold):
11− bufsize = 1024
12− hopsize = bufsize/2
1314 frameread = 0
1415 filei = sndfile(filein)
1516 srate = filei.samplerate()
@@ -20,20 +21,27 @@ def getonsets(filein,threshold): · 4 unmodified lines
2021 #newname = "%s%.8f%s" % ("/tmp/",0.0000000,filein[-4:])
2122 #fileo = sndfile(newname,model=filei)
2223 mylist = list()
24+ ovalist = [0., 0., 0., 0., 0., 0.]
2325 while(readsize==hopsize):
2426 readsize = filei.read(hopsize,myvec)
2527 isonset,val = opick.do(myvec)
28+ ovalist.append(val)
29+ ovalist.pop(0)
2630 if (isonset == 1):
27− now = (frameread-4)*hopsize/(srate+0.)
28− #del fileo
29− #fileo = sndfile("%s%f%s" % ("/tmp/",now,filein[-4:]),model=filei)
30− mylist.append(now)
31+ print frameread
32+ i=len(ovalist)-1
33+ # find local minima
34+ while ovalist[i-1] < ovalist[i] and i > 0:
35+ i -= 1
36+ now = (frameread-i+1)*hopsize/(srate+0.)
37+ #del fileo
38+ #fileo = sndfile("%s%f%s" % ("/tmp/",now,filein[-4:]),model=filei)
39+ mylist.append(now)
3140 #writesize = fileo.write(readsize,myoldvec)
3241 frameread += 1
3342 return mylist
3443
3544 def cutfile(filein,onsets):
36− hopsize = 512
3745 frameread = 0
3846 readsize = hopsize
3947 filei = sndfile(filein)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t