Changeset 19b56b0 for python/aubiocut
- Timestamp:
- Mar 29, 2005, 5:51:44 PM (20 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:
- 9499a546
- Parents:
- 7445aea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubiocut
r7445aea r19b56b0 11 11 hopsize = bufsize/2 12 12 13 def getonsets(filein,threshold):14 frameread = 015 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)-132 # find local minima33 while ovalist[i-1] < ovalist[i] and i > 0:34 i -= 135 now = (frameread+1-i)*hopsize/(srate+0.)36 mylist.append(now)37 frameread += 138 return mylist39 13 40 14 def cutfile(filein,onsets): 41 15 frameread = 0 16 zerothres = 0.002 42 17 readsize = hopsize 43 18 filei = sndfile(filein) 44 srate = filei.samplerate()19 framestep = hopsize/(filei.samplerate()+0.) 45 20 channels = filei.channels() 46 21 newname = "%s%f%s" % ("/tmp/",0.0000000,filein[-4:]) … … 50 25 while(readsize==hopsize): 51 26 readsize = filei.read(hopsize,myvec) 52 now = (frameread)*hopsize/(srate+0.)53 27 # write to current file 54 if len(onsets) and now>= onsets[0]:28 if len(onsets) and frameread >= onsets[0]: 55 29 onsets.pop(0) 56 30 # write up to 1st zero crossing 57 31 zerocross = 0 58 while ( abs( myvec.get(zerocross,0) ) > 0.002):32 while ( abs( myvec.get(zerocross,0) ) > zerothres ): 59 33 zerocross += 1 60 34 writesize = fileo.write(zerocross,myvec) … … 67 41 del fileo 68 42 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 file43 (filein.split(".")[0].split("/")[-1],".", 44 frameread*framestep,".",filein.split(".")[-1]),model=filei) 71 45 writesize = fileo.write(fromcross,mycopy) 72 46 else:
Note: See TracChangeset
for help on using the changeset viewer.