source: python/aubio/task/task.py @ 3cd2434

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 3cd2434 was 8d1323b, checked in by Paul Brossier <piem@piem.org>, 15 years ago

python/aubio: more changes for mono

  • Property mode set to 100644
File size: 1.4 KB
Line 
1from aubio.aubioclass import * 
2from params import taskparams
3
4class task(taskparams):
5        """ default template class to apply tasks on a stream """
6        def __init__(self,input,output=None,params=None):
7                """ open the input file and initialize default argument
8                parameters should be set *before* calling this method.
9                """
10                import time
11                self.tic = time.time()
12                if params == None: self.params = taskparams()
13                else: self.params = params
14                self.frameread = 0
15                self.readsize  = self.params.hopsize
16                self.input     = input
17                self.filei     = sndfile(self.input)
18                self.srate     = self.filei.samplerate()
19                self.params.step = float(self.params.hopsize)/float(self.srate)
20                self.myvec     = fvec(self.params.hopsize)
21                self.output    = output
22
23        def __call__(self):
24                self.readsize = self.filei.read(self.params.hopsize,self.myvec)
25                self.frameread += 1
26               
27        def compute_all(self):
28                """ Compute data """
29                mylist    = []
30                while(self.readsize==self.params.hopsize):
31                        tmp = self()
32                        if tmp: 
33                                mylist.append(tmp)
34                                if self.params.verbose:
35                                        self.fprint(tmp)
36                return mylist
37       
38        def fprint(self,foo):
39                print foo
40
41        def eval(self,results):
42                """ Eval data """
43                pass
44
45        def plot(self):
46                """ Plot data """
47                pass
48
49        def time(self):
50                import time
51                #print "CPU time is now %f seconds," % time.clock(),
52                #print "task execution took %f seconds" % (time.time() - self.tic)
53                return time.time() - self.tic
Note: See TracBrowser for help on using the repository browser.