Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -23,6 +23,8 @@ class cvec: · 22 unmodified lines | ||
| 23 | 23 | return self.vec |
| 24 | 24 | def __del__(self): |
| 25 | 25 | del_cvec(self()) |
| 26 | + def get(self,pos,chan): | |
| 27 | + return fvec_read_sample(self(),chan,pos) | |
| 26 | 28 | |
| 27 | 29 | class sndfile: |
| 28 | 30 | def __init__(self,filename,model=None): |
| @@ -203,7 +205,7 @@ def getsilences(filein,hopsize=512,silence=-70): · 174 unmodified lines | ||
| 203 | 205 | return mylist |
| 204 | 206 | |
| 205 | 207 | def getpitch(filein,mode=aubio_mcomb,bufsize=1024,hopsize=512,omode=aubio_freq, |
| 206 | − samplerate=44100.): | |
| 208 | + samplerate=44100.,silence=-70): | |
| 207 | 209 | frameread = 0 |
| 208 | 210 | filei = sndfile(filein) |
| 209 | 211 | srate = filei.samplerate() |
| @@ -217,7 +219,10 @@ def getpitch(filein,mode=aubio_mcomb,bufsize=1024,hopsize=512,omode=aubio_freq, · 7 unmodified lines | ||
| 217 | 219 | readsize = filei.read(hopsize,myvec) |
| 218 | 220 | freq = pitchdet(myvec) |
| 219 | 221 | #print "%.3f %.2f" % (now,freq) |
| 220 | − mylist.append(freq) | |
| 222 | + if (aubio_silence_detection(myvec(),silence)!=1): | |
| 223 | + mylist.append(freq) | |
| 224 | + else: | |
| 225 | + mylist.append(0) | |
| 221 | 226 | frameread += 1 |
| 222 | 227 | return mylist |
| 223 | 228 | |