Changeset d53e4df for python/aubio


Ignore:
Timestamp:
Jun 3, 2005, 2:48:01 AM (20 years ago)
Author:
Paul Brossier <piem@altern.org>
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:
d4a0cc4
Parents:
b16c017
Message:

add getsilences function, moves pitchpick class to pitchdetection/getpitch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/aubioclass.py

    rb16c017 rd53e4df  
    184184
    185185
    186 class pitchpick:
    187     def __init__(self,bufsize,hopsize,channels,myvec,srate):
    188         self.myfft    = cvec(bufsize,channels)
    189         self.pv       = pvoc(bufsize,hopsize,channels)
    190         self.pitchp   = new_aubio_pitchmcomb(bufsize,channels)
    191         self.filt     = filter(srate,"adsgn")
    192 
    193     def do(self,myvec):
    194         #self.filt.do(myvec)
    195         #self.filt.do(myvec)
    196         self.pv.do(myvec,self.myfft)
    197         return aubio_pitchmcomb_detect(self.pitchp,self.myfft())
     186def getsilences(filein,hopsize=512,silence=-70):
     187    frameread = 0
     188    filei     = sndfile(filein)
     189    srate     = filei.samplerate()
     190    channels  = filei.channels()
     191    myvec     = fvec(hopsize,channels)
     192    readsize  = filei.read(hopsize,myvec)
     193    mylist    = []
     194    wassilence = 0
     195    while(readsize==hopsize):
     196        readsize = filei.read(hopsize,myvec)
     197        if (aubio_silence_detection(myvec(),silence)==1):
     198            if wassilence == 0:
     199                mylist.append(frameread)
     200                wassilence == 1
     201        else: wassilence = 0
     202        frameread += 1
     203    return mylist
     204
     205def getpitch(filein,mode=aubio_mcomb,bufsize=1024,hopsize=512,omode=aubio_freq,
     206        samplerate=44100.):
     207    frameread = 0
     208    filei     = sndfile(filein)
     209    srate     = filei.samplerate()
     210    channels  = filei.channels()
     211    myvec     = fvec(hopsize,channels)
     212    readsize  = filei.read(hopsize,myvec)
     213    pitchdet  = pitchdetection(mode=mode,bufsize=bufsize,hopsize=hopsize,
     214                         channels=channels,samplerate=srate,omode=omode)
     215    mylist    = []
     216    while(readsize==hopsize):
     217        readsize = filei.read(hopsize,myvec)
     218        freq = pitchdet(myvec)
     219        #print "%.3f     %.2f" % (now,freq)
     220        mylist.append(freq)
     221        frameread += 1
     222    return mylist
     223
     224class pitchdetection:
     225    def __init__(self,mode=aubio_mcomb,bufsize=2048,hopsize=1024,
     226        channels=1,samplerate=44100.,omode=aubio_freq):
     227        self.pitchp = new_aubio_pitchdetection(bufsize,hopsize,channels,
     228                samplerate,mode,omode)
     229        #self.filt     = filter(srate,"adsgn")
     230    def __del__(self):
     231        del_aubio_pitchdetection(self.pitchp)
     232    def __call__(self,myvec):
     233        #self.filt(myvec)
     234        return aubio_pitchdetection(self.pitchp,myvec())
    198235
    199236class filter:
     
    204241        #del_aubio_filter(self.filter)
    205242        pass
    206     def do(self,myvec):
     243    def __call__(self,myvec):
    207244        aubio_filter_do(self.filter,myvec())
Note: See TracChangeset for help on using the changeset viewer.