History

moved out old python interface

Paul Brossier committed 13 years ago

Commit b554e411 parent a1da37f42 files · +0 −0Browse files

Showing the changes to python.old/aubionotes (1 of 42 files). Show all

Unified · Split

python.old/aubionotes+79−0
@@ -0,0 +1,79 @@
1+#!/usr/bin/python
2+
3+def do(filein,threshold):
4+
5+ import aubio.aubioclass
6+ import aubio.median
7+ from math import floor
8+ hopsize = 512
9+ bufsize = 4096
10+ channels = 1
11+ frameread = 0
12+ silthres = -80.
13+ filei = aubio.aubioclass.sndfile(filein)
14+ srate = filei.samplerate()
15+ myvec = aubio.aubioclass.fvec(hopsize,channels)
16+ readsize = filei.read(hopsize,myvec)
17+ ppick = aubio.aubioclass.pitchpick(bufsize,hopsize,channels,myvec,srate)
18+ opick = aubio.aubioclass.onsetpick(bufsize,hopsize,channels,myvec,threshold)
19+ mylist = list()
20+
21+ wassilence = 0
22+ lastpitch = 0
23+ starttime = 0
24+ while(readsize==hopsize):
25+ readsize = filei.read(hopsize,myvec)
26+ val = ppick.do(myvec)
27+ midival = aubio.aubioclass.bintomidi(val,srate,bufsize)
28+ isonset,onset = opick.do(myvec)
29+ now = (frameread)*hopsize/(srate+0.)
30+ issilence = aubio.aubioclass.aubio_silence_detection(myvec.vec,silthres)
31+
32+ estmidival = 0
33+ if (issilence == 1):
34+ if (wassilence == 0):
35+ #outputnow
36+ endtime = (frameread-3)*hopsize/(srate+0.)
37+ if len(mylist) > 5 :
38+ estmidival = aubio.median.percental(mylist,len(mylist)/2)
39+ print "sil", starttime, endtime, estmidival
40+ #resetnow
41+ mylist = list()
42+ else:
43+ wassilence = 1
44+ else:
45+ if isonset == 1:
46+ if (wassilence == 0):
47+ #outputnow
48+ endtime = (frameread-3)*hopsize/(srate+0.)
49+ #estmidival = aubio.median.percental(around(array(mylist)),len(mylist)//2)
50+ if len(mylist) > 5 :
51+ estmidival = aubio.median.percental(mylist,len(mylist)/2)
52+ print starttime, endtime, estmidival
53+ #resetnow
54+ mylist = list()
55+ #store start time
56+ starttime = (frameread-3)*hopsize/(srate+0.)
57+ else:
58+ """
59+ if(listfull):
60+ #outputnow
61+ endtime = (frameread-3)*hopsize/(srate+0.)
62+ print starttime, endtime, estimmidival
63+ else:
64+ """
65+ #bufferize
66+ if midival > 50 and midival < 75:
67+ mylist.append(floor(midival))
68+ wassilence = 0
69+
70+
71+ #elif( midival > 45 ):
72+ # mylist.append(( now , midival+12 ))
73+ #mylist.append(toappend)
74+ frameread += 1
75+
76+
77+if __name__ == "__main__":
78+ import sys
79+ do(sys.argv[1],sys.argv[2])

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