Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -77,7 +77,7 @@ class peakpick: · 76 unmodified lines | |||
| 77 | 77 | ||
| 78 | class onsetpick: | 78 | class onsetpick: |
| 79 | """ superclass for aubio_pvoc + aubio_onsetdetection + aubio_peakpicker """ | 79 | """ superclass for aubio_pvoc + aubio_onsetdetection + aubio_peakpicker """ |
| 80 | def __init__(self,bufsize,hopsize,channels,myvec,threshold,mode='dual',derivate=False): | 80 | def __init__(self,bufsize,hopsize,channels,myvec,threshold,mode='dual',derivate=False,dcthreshold=0): |
| 81 | self.myfft = cvec(bufsize,channels) | 81 | self.myfft = cvec(bufsize,channels) |
| 82 | self.pv = pvoc(bufsize,hopsize,channels) | 82 | self.pv = pvoc(bufsize,hopsize,channels) |
| 83 | if mode in ['dual'] : | 83 | if mode in ['dual'] : |
| @@ -91,6 +91,7 @@ class onsetpick: · 7 unmodified lines | |||
| 91 | self.mode = mode | 91 | self.mode = mode |
| 92 | self.pp = peakpick(float(threshold)) | 92 | self.pp = peakpick(float(threshold)) |
| 93 | self.derivate = derivate | 93 | self.derivate = derivate |
| 94 | self.dcthreshold = dcthreshold | ||
| 94 | self.oldval = 0. | 95 | self.oldval = 0. |
| 95 | 96 | ||
| 96 | def do(self,myvec): | 97 | def do(self,myvec): |
| @@ -105,6 +106,10 @@ class onsetpick: · 8 unmodified lines | |||
| 105 | self.oldval = val | 106 | self.oldval = val |
| 106 | if dval > 0: self.myonset.set(dval,0,0) | 107 | if dval > 0: self.myonset.set(dval,0,0) |
| 107 | else: self.myonset.set(0.,0,0) | 108 | else: self.myonset.set(0.,0,0) |
| 109 | if self.dcthreshold: | ||
| 110 | dval = self.myonset.get(0,0) - self.dcthreshold | ||
| 111 | if dval > 0: self.myonset.set(dval,0,0) | ||
| 112 | else: self.myonset.set(0.,0,0) | ||
| 108 | return self.pp.do(self.myonset),self.myonset.get(0,0) | 113 | return self.pp.do(self.myonset),self.myonset.get(0,0) |
| 109 | 114 | ||
| 110 | class pitchdetection: | 115 | class pitchdetection: |