Changeset 4f4a8a4 for python/aubiocut
- Timestamp:
- Dec 19, 2005, 10:25:51 PM (19 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:
- f2adb86
- Parents:
- 7c9ad74
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubiocut
r7c9ad74 r4f4a8a4 16 16 action="store", dest="filename", 17 17 help="input sound file") 18 parser.add_option("-m","--mode", action="callback",19 callback=check_onset_mode, dest="mode", default=['dual'],18 parser.add_option("-m","--mode", 19 action="store", dest="mode", default=['dual'], 20 20 help="onset detection mode [default=dual] \ 21 21 complexdomain|hfc|phase|specdiff|energy|kl|mkl|dual") … … 81 81 82 82 filename = options.filename 83 samplerate = float(sndfile(filename).samplerate()) 84 hopsize = int(options.hopsize) 85 bufsize = int(options.bufsize) 86 step = float(samplerate)/float(hopsize) 87 threshold = float(options.threshold) 88 zerothres = float(options.zerothres) 89 silence = float(options.silence) 90 mintol = float(options.mintol)*step 91 mode = options.mode 83 params = taskparams() 84 params.hopsize = int(options.hopsize) 85 params.bufsize = int(options.bufsize) 86 params.threshold = float(options.threshold) 87 params.zerothres = float(options.zerothres) 88 params.silence = float(options.silence) 89 params.mintol = float(options.mintol) 92 90 # default take back system delay 93 91 if options.delay: delay = float(options.delay) 94 else: delay = 3./ step92 else: delay = 3./params.step 95 93 96 94 if options.beat: … … 99 97 elif options.silencecut: 100 98 onsets = getsilences(filename,hopsize=hopsize,silence=silence) 101 elif options.plot: storefunc=True102 else: storefunc=False99 elif options.plot: params.storefunc=True 100 else: params.storefunc=False 103 101 104 102 lonsets, lofunc = [], [] 105 for i in range(len(mode)): 106 onsets, ofunc = getonsets(filename,threshold,silence, 107 mode=mode[i],localmin=options.localmin, 108 derivate=options.derivate, 109 bufsize=bufsize,hopsize=hopsize,storefunc=True) 103 modes = options.mode.split(',') 104 for i in range(len(modes)): 105 106 params.onsetmode = modes[i] 107 filetask = taskonset(filename,params=params) 108 onsets = filetask.compute_all() 109 ofunc = filetask.ofunc 110 #onsets, ofunc = getonsets(filename,threshold,silence, 111 # mode=mode[i],localmin=options.localmin, 112 # derivate=options.derivate, 113 # bufsize=bufsize,hopsize=hopsize,storefunc=True) 110 114 111 115 # take back system delay 112 116 if delay != 0: 113 for iin range(len(onsets)):114 onsets[i] -= delay*step117 for each in range(len(onsets)): 118 onsets[each] = onsets[each][0] - delay*params.step 115 119 116 120 # prune doubled 117 if mintol > 0: 118 last = -2*mintol 121 params.mintol *= params.step 122 if params.mintol > 0: 123 last = -2*params.mintol 119 124 newonsets = [] 120 125 for new in onsets: 121 if (new - last > mintol):126 if (new - last > params.mintol): 122 127 newonsets.append(new) 123 128 last = new … … 127 132 lofunc.append(ofunc) 128 133 129 # print times in second130 if options.verbose:131 maxonset = 0 132 for j in range(len(mode)): 133 for i in range(len(lonsets[j])):134 print lonsets[j][i]/step134 # print times in second 135 if options.verbose: 136 print modes[i] 137 maxonset = 0 138 for i in range(len(onsets)): 139 print onsets[i]*params.step 135 140 136 if options.plot: 137 from aubio.gnuplot import plot_onsets 138 plot_onsets(filename, lonsets, lofunc, 139 samplerate=samplerate, hopsize=hopsize, outplot=options.outplot) 141 if options.plot: 142 filetask.plot(onsets, ofunc) 143 filetask.plotplot(outplot=options.outplot) 140 144 141 145 if options.cut: 142 cutfile(filename,onsets,zerothres=zerothres,bufsize=bufsize,hopsize=hopsize) 146 a = taskcut(filename,onsets,params=params) 147 a.compute_all()
Note: See TracChangeset
for help on using the changeset viewer.