- Timestamp:
- Apr 14, 2010, 5:36:49 PM (15 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 0efce0d
- Parents:
- 16bd78a
- Location:
- python/aubio
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/aubioclass.py
r16bd78a r8d1323b 2 2 3 3 class fvec: 4 def __init__(self,size ,chan):5 self.vec = new_fvec(size ,chan)4 def __init__(self,size): 5 self.vec = new_fvec(size) 6 6 def __call__(self): 7 7 return self.vec 8 8 def __del__(self): 9 9 del_fvec(self()) 10 def get(self,pos,chan): 11 return fvec_read_sample(self(),chan,pos) 12 def set(self,value,pos,chan): 13 return fvec_write_sample(self(),value,chan,pos) 14 def channel(self,chan): 15 return fvec_get_channel(self(),chan) 10 def get(self,pos): 11 return fvec_read_sample(self(),pos) 12 def set(self,value,pos): 13 return fvec_write_sample(self(),value,pos) 16 14 def data(self): 17 15 return fvec_get_data(self()) 18 16 19 17 class cvec: 20 def __init__(self,size ,chan):21 self.vec = new_cvec(size ,chan)18 def __init__(self,size): 19 self.vec = new_cvec(size) 22 20 def __call__(self): 23 21 return self.vec 24 22 def __del__(self): 25 23 del_cvec(self()) 26 def get(self,pos ,chan):27 return self.get_norm(pos ,chan)28 def set(self,val,pos ,chan):29 self.set_norm(val, chan,pos)30 def get_norm(self,pos ,chan):31 return cvec_read_norm(self(), chan,pos)32 def set_norm(self,val,pos ,chan):33 cvec_write_norm(self(),val, chan,pos)34 def get_phas(self,pos ,chan):35 return cvec_read_phas(self(), chan,pos)36 def set_phas(self,val,pos ,chan):37 cvec_write_phas(self(),val, chan,pos)24 def get(self,pos): 25 return self.get_norm(pos) 26 def set(self,val,pos): 27 self.set_norm(val,pos) 28 def get_norm(self,pos): 29 return cvec_read_norm(self(),pos) 30 def set_norm(self,val,pos): 31 cvec_write_norm(self(),val,pos) 32 def get_phas(self,pos): 33 return cvec_read_phas(self(),pos) 34 def set_phas(self,val,pos): 35 cvec_write_phas(self(),val,pos) 38 36 39 37 class sndfile: … … 54 52 return aubio_sndfile_channels(self.file) 55 53 def read(self,nfram,vecread): 56 return aubio_sndfile_read (self.file,nfram,vecread())54 return aubio_sndfile_read_mono(self.file,nfram,vecread()) 57 55 def write(self,nfram,vecwrite): 58 56 return aubio_sndfile_write(self.file,nfram,vecwrite()) 59 57 60 58 class pvoc: 61 def __init__(self,buf,hop ,chan):62 self.pv = new_aubio_pvoc(buf,hop ,chan)59 def __init__(self,buf,hop): 60 self.pv = new_aubio_pvoc(buf,hop) 63 61 def __del__(self): 64 62 del_aubio_pvoc(self.pv) … … 70 68 class onsetdetection: 71 69 """ class for aubio_specdesc """ 72 def __init__(self,mode,buf ,chan):73 self.od = new_aubio_specdesc(mode,buf ,chan)70 def __init__(self,mode,buf): 71 self.od = new_aubio_specdesc(mode,buf) 74 72 def do(self,tc,tf): 75 73 aubio_specdesc_do(self.od,tc(),tf()) … … 80 78 """ class for aubio_peakpicker """ 81 79 def __init__(self,threshold=0.1): 82 self.pp = new_aubio_peakpicker( 1)83 self.out = new_fvec(1 , 1)80 self.pp = new_aubio_peakpicker() 81 self.out = new_fvec(1) 84 82 aubio_peakpicker_set_threshold (self.pp, threshold) 85 83 def do(self,fv): 86 84 aubio_peakpicker_do(self.pp, fv(), self.out) 87 return fvec_read_sample(self.out, 0 , 0)85 return fvec_read_sample(self.out, 0) 88 86 def getval(self): 89 87 return aubio_peakpicker_get_adaptive_threshold(self.pp) … … 93 91 class onsetpick: 94 92 """ superclass for aubio_pvoc + aubio_specdesc + aubio_peakpicker """ 95 def __init__(self,bufsize,hopsize, channels,myvec,threshold,mode='dual',derivate=False,dcthreshold=0):96 self.myfft = cvec(bufsize ,channels)97 self.pv = pvoc(bufsize,hopsize ,channels)93 def __init__(self,bufsize,hopsize,myvec,threshold,mode='dual',derivate=False,dcthreshold=0): 94 self.myfft = cvec(bufsize) 95 self.pv = pvoc(bufsize,hopsize) 98 96 if mode in ['dual'] : 99 self.myod = onsetdetection("hfc",bufsize ,channels)100 self.myod2 = onsetdetection("mkl",bufsize ,channels)101 self.myonset = fvec(1 ,channels)102 self.myonset2 = fvec(1 ,channels)97 self.myod = onsetdetection("hfc",bufsize) 98 self.myod2 = onsetdetection("mkl",bufsize) 99 self.myonset = fvec(1) 100 self.myonset2 = fvec(1) 103 101 else: 104 self.myod = onsetdetection(mode,bufsize ,channels)105 self.myonset = fvec(1 ,channels)102 self.myod = onsetdetection(mode,bufsize) 103 self.myonset = fvec(1) 106 104 self.mode = mode 107 105 self.pp = peakpick(float(threshold)) … … 115 113 if self.mode == 'dual': 116 114 self.myod2.do(self.myfft,self.myonset2) 117 self.myonset.set(self.myonset.get(0 ,0)*self.myonset2.get(0,0),0,0)115 self.myonset.set(self.myonset.get(0)*self.myonset2.get(0),0) 118 116 if self.derivate: 119 val = self.myonset.get(0 ,0)117 val = self.myonset.get(0) 120 118 dval = val - self.oldval 121 119 self.oldval = val 122 if dval > 0: self.myonset.set(dval,0 ,0)120 if dval > 0: self.myonset.set(dval,0) 123 121 else: self.myonset.set(0.,0,0) 124 isonset, dval = self.pp.do(self.myonset),self.myonset.get(0 ,0)122 isonset, dval = self.pp.do(self.myonset),self.myonset.get(0) 125 123 if self.dcthreshold: 126 124 if dval < self.dcthreshold: isonset = 0 … … 129 127 class pitch: 130 128 def __init__(self,mode="mcomb",bufsize=2048,hopsize=1024, 131 channels=1,samplerate=44100.,omode="freq",tolerance=0.1):132 self.pitchp = new_aubio_pitch(mode,bufsize,hopsize, channels,129 samplerate=44100.,omode="freq",tolerance=0.1): 130 self.pitchp = new_aubio_pitch(mode,bufsize,hopsize, 133 131 samplerate) 134 self.mypitch = fvec(1 , channels)132 self.mypitch = fvec(1) 135 133 aubio_pitch_set_unit(self.pitchp,omode) 136 134 aubio_pitch_set_tolerance(self.pitchp,tolerance) … … 140 138 def __call__(self,myvec): 141 139 aubio_pitch_do(self.pitchp,myvec(), self.mypitch()) 142 return self.mypitch.get(0 ,0)140 return self.mypitch.get(0) 143 141 144 142 class filter: -
python/aubio/task/onset.py
r16bd78a r8d1323b 10 10 self.opick = onsetpick(self.params.bufsize, 11 11 self.params.hopsize, 12 self.channels,13 12 self.myvec, 14 13 self.params.threshold, -
python/aubio/task/pitch.py
r16bd78a r8d1323b 16 16 bufsize=self.params.bufsize, 17 17 hopsize=self.params.hopsize, 18 channels=self.channels,19 18 samplerate=self.srate, 20 19 omode=self.params.omode, -
python/aubio/task/task.py
r16bd78a r8d1323b 17 17 self.filei = sndfile(self.input) 18 18 self.srate = self.filei.samplerate() 19 self.channels = self.filei.channels()20 19 self.params.step = float(self.params.hopsize)/float(self.srate) 21 self.myvec = fvec(self.params.hopsize ,self.channels)20 self.myvec = fvec(self.params.hopsize) 22 21 self.output = output 23 22
Note: See TracChangeset
for help on using the changeset viewer.