[13c3fba] | 1 | from aubio.aubioclass import * |
---|
| 2 | from onset import taskonset |
---|
| 3 | |
---|
| 4 | class taskbeat(taskonset): |
---|
| 5 | def __init__(self,input,params=None,output=None): |
---|
| 6 | """ open the input file and initialize arguments |
---|
| 7 | parameters should be set *before* calling this method. |
---|
| 8 | """ |
---|
| 9 | taskonset.__init__(self,input,output=None,params=params) |
---|
| 10 | self.btwinlen = 512**2/self.params.hopsize |
---|
| 11 | self.btstep = self.btwinlen/4 |
---|
| 12 | self.btoutput = fvec(self.btstep,self.channels) |
---|
| 13 | self.dfframe = fvec(self.btwinlen,self.channels) |
---|
| 14 | self.bt = beattracking(self.btwinlen,self.channels) |
---|
| 15 | self.pos2 = 0 |
---|
| 16 | |
---|
| 17 | def __call__(self): |
---|
| 18 | taskonset.__call__(self) |
---|
| 19 | # write to current file |
---|
| 20 | if self.pos2 == self.btstep - 1 : |
---|
| 21 | self.bt.do(self.dfframe,self.btoutput) |
---|
| 22 | for i in range (self.btwinlen - self.btstep): |
---|
| 23 | self.dfframe.set(self.dfframe.get(i+self.btstep,0),i,0) |
---|
| 24 | for i in range(self.btwinlen - self.btstep, self.btwinlen): |
---|
| 25 | self.dfframe.set(0,i,0) |
---|
| 26 | self.pos2 = -1; |
---|
| 27 | self.pos2 += 1 |
---|
| 28 | val = self.opick.pp.getval() |
---|
| 29 | self.dfframe.set(val,self.btwinlen - self.btstep + self.pos2,0) |
---|
| 30 | i=0 |
---|
| 31 | for i in range(1,int( self.btoutput.get(0,0) ) ): |
---|
| 32 | if self.pos2 == self.btoutput.get(i,0) and \ |
---|
| 33 | aubio_silence_detection(self.myvec(), |
---|
| 34 | self.params.silence)!=1: |
---|
| 35 | return self.frameread, 0 |
---|
| 36 | |
---|
| 37 | def eval(self,results): |
---|
| 38 | pass |
---|
| 39 | |
---|