Changeset d9101a5 for python/aubiopitch
- Timestamp:
- Feb 15, 2006, 11:36:09 AM (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:
- 660c1d82
- Parents:
- e8d0c06
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubiopitch
re8d0c06 rd9101a5 17 17 action="store", dest="filename", 18 18 help="input sound file") 19 parser.add_option("-m","--mode", action="callback", 20 callback=check_pitch_mode, dest="mode", 21 default=[aubio_pitch_mcomb], 19 parser.add_option("-m","--mode", 20 action="store", dest="mode", default='mcomb', 22 21 help="pitch detection mode [default=mcomb] \ 23 22 mcomb|yin|fcomb|schmitt") … … 86 85 87 86 filename = options.filename 88 samplerate = float(sndfile(filename).samplerate())89 hopsize = int(options.hopsize)90 bufsize = int(options.bufsize)91 step = float(samplerate)/float(hopsize)92 threshold = float(options.threshold)93 silence = float(options.silence)94 mode = options.mode 87 params = taskparams() 88 #params.samplerate = float(sndfile(filename).samplerate()) 89 params.hopsize = int(options.hopsize) 90 params.bufsize = int(options.bufsize) 91 #params.step = float(samplerate)/float(hopsize) 92 params.threshold = float(options.threshold) 93 params.silence = float(options.silence) 95 94 #mintol = float(options.mintol)*step 96 95 # default take back system delay 97 96 if options.delay: delay = float(options.delay) 98 else: delay = 2./ step97 else: delay = 2./params.step 99 98 100 99 if options.note: 101 100 exit("not implemented yet") 102 else:103 pitch = []104 for i in range(len(mode)):105 pitch.append(getpitch(filename, #threshold,106 mode=mode[i],107 omode=options.omode,108 bufsize=bufsize,hopsize=hopsize,109 silence=silence))110 for j in range(len(pitch[i])):111 if pitch[i][j] > 1500 or pitch[i][j] < 40:112 pitch[i][j] = 0.;113 101 114 ## take back system delay115 #if delay != 0:116 # for i in range(len(onsets)):117 # onsets[i] -= delay*step118 #119 ## prune doubled120 #if mintol > 0:121 # last = -2*mintol122 # newonsets = []123 # for new in onsets:124 # if (new - last > mintol):125 # newonsets.append(new)126 # last = new127 # onsets = newonsets128 102 129 # print times in second 130 if options.verbose: 131 for j in range(len(pitch[0])): 132 print "%f\t" % (j/step), 133 for i in range(len(pitch)): 134 print "%f\t" % pitch[i][j], 135 print 103 pitch = [] 104 modes = options.mode.split(',') 105 for i in range(len(modes)): 106 params.pitchmode = modes[i] 107 dotask = taskpitch 108 #pitch.append(getpitch(filename, #threshold, 109 # mode=mode[i], 110 # omode=options.omode, 111 # bufsize=bufsize,hopsize=hopsize, 112 # silence=silence)) 113 filetask = dotask(filename,params=params) 114 pitch.append(filetask.compute_all()) 115 for j in range(len(pitch[i])): 116 if pitch[i][j] > 10000 or pitch[i][j] < 40: 117 pitch[i][j] = 0.; 136 118 137 if options.plot: 138 from aubio.gnuplot import plot_pitch 139 plot_pitch(filename, pitch, 140 samplerate=samplerate, hopsize=hopsize, outplot=options.outplot) 119 if options.verbose: 120 for j in range(len(pitch[i])): 121 print "%f\t" % (j/params.step), 122 print "%f\t" % pitch[i][j], 123 print 124 125 if options.plot: 126 filetask.plot(pitch,outplot=options.outplot)
Note: See TracChangeset
for help on using the changeset viewer.