Changeset 19b56b0 for python/aubiocut


Ignore:
Timestamp:
Mar 29, 2005, 5:51:44 PM (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:
9499a546
Parents:
7445aea
Message:

updated python/aubio/aubioclass.py and python/aubiocut

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubiocut

    r7445aea r19b56b0  
    1111hopsize   = bufsize/2
    1212
    13 def getonsets(filein,threshold):
    14         frameread = 0
    15         filei     = sndfile(filein)
    16         srate     = filei.samplerate()
    17         channels  = filei.channels()
    18         myvec     = fvec(hopsize,channels)
    19         readsize  = filei.read(hopsize,myvec)
    20         opick     = onsetpick(bufsize,hopsize,channels,myvec,threshold)
    21         #newname   = "%s%.8f%s" % ("/tmp/",0.0000000,filein[-4:])
    22         #fileo     = sndfile(newname,model=filei)
    23         mylist    = list()
    24         ovalist   = [0., 0., 0., 0., 0., 0.]
    25         while(readsize==hopsize):
    26                 readsize = filei.read(hopsize,myvec)
    27                 isonset,val = opick.do(myvec)
    28                 ovalist.append(val)
    29                 ovalist.pop(0)
    30                 if (isonset == 1):
    31                         i=len(ovalist)-1
    32                         # find local minima
    33                         while ovalist[i-1] < ovalist[i] and i > 0:
    34                                 i -= 1
    35                         now = (frameread+1-i)*hopsize/(srate+0.)
    36                         mylist.append(now)
    37                 frameread += 1
    38         return mylist
    3913
    4014def cutfile(filein,onsets):
    4115        frameread = 0
     16        zerothres = 0.002
    4217        readsize  = hopsize
    4318        filei     = sndfile(filein)
    44         srate     = filei.samplerate()
     19        framestep = hopsize/(filei.samplerate()+0.)
    4520        channels  = filei.channels()
    4621        newname   = "%s%f%s" % ("/tmp/",0.0000000,filein[-4:])
     
    5025        while(readsize==hopsize):
    5126                readsize = filei.read(hopsize,myvec)
    52                 now = (frameread)*hopsize/(srate+0.)
    5327                # write to current file
    54                 if len(onsets) and now >= onsets[0]:
     28                if len(onsets) and frameread >= onsets[0]:
    5529                    onsets.pop(0)
    5630                    # write up to 1st zero crossing
    5731                    zerocross = 0
    58                     while ( abs( myvec.get(zerocross,0) ) > 0.002 ):
     32                    while ( abs( myvec.get(zerocross,0) ) > zerothres ):
    5933                        zerocross += 1
    6034                    writesize = fileo.write(zerocross,myvec)
     
    6741                    del fileo
    6842                    fileo = sndfile("%s%s%f%s%s" %
    69                         (filein.split(".")[0].split("/")[-1],".",now,".",filein.split(".")[-1]),model=filei)
    70                     # write after 1st zero crossing to new file
     43                        (filein.split(".")[0].split("/")[-1],".",
     44                        frameread*framestep,".",filein.split(".")[-1]),model=filei)
    7145                    writesize = fileo.write(fromcross,mycopy)
    7246                else:
Note: See TracChangeset for help on using the changeset viewer.