source: python/aubio/task/cut.py @ 9abd0f3

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 9abd0f3 was 13c3fba, checked in by Paul Brossier <piem@altern.org>, 19 years ago

splitting up tasks in many files
splitting up tasks in many files

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[13c3fba]1from task import task
2from aubio.aubioclass import *
3
4class taskcut(task):
5        def __init__(self,input,slicetimes,params=None,output=None):
6                """ open the input file and initialize arguments
7                parameters should be set *before* calling this method.
8                """
9                task.__init__(self,input,output=None,params=params)
10                self.newname   = "%s%s%09.5f%s%s" % (self.input.split(".")[0].split("/")[-1],".",
11                                        self.frameread*self.params.step,".",self.input.split(".")[-1])
12                self.fileo      = sndfile(self.newname,model=self.filei)
13                self.myvec      = fvec(self.params.hopsize,self.channels)
14                self.mycopy     = fvec(self.params.hopsize,self.channels)
15                self.slicetimes = slicetimes
16
17        def __call__(self):
18                task.__call__(self)
19                # write to current file
20                if len(self.slicetimes) and self.frameread >= self.slicetimes[0][0]:
21                        self.slicetimes.pop(0)
22                        # write up to 1st zero crossing
23                        zerocross = 0
24                        while ( abs( self.myvec.get(zerocross,0) ) > self.params.zerothres ):
25                                zerocross += 1
26                        writesize = self.fileo.write(zerocross,self.myvec)
27                        fromcross = 0
28                        while (zerocross < self.readsize):
29                                for i in range(self.channels):
30                                        self.mycopy.set(self.myvec.get(zerocross,i),fromcross,i)
31                                        fromcross += 1
32                                        zerocross += 1
33                        del self.fileo
34                        self.fileo = sndfile("%s%s%09.5f%s%s" % 
35                                (self.input.split(".")[0].split("/")[-1],".",
36                                self.frameread*self.params.step,".",self.input.split(".")[-1]),model=self.filei)
37                        writesize = self.fileo.write(fromcross,self.mycopy)
38                else:
39                        writesize = self.fileo.write(self.readsize,self.myvec)
40
41
Note: See TracBrowser for help on using the repository browser.