Changeset 3e29681 for python/aubiopitch
- Timestamp:
- May 4, 2006, 5:03:58 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:
- dfe0d360
- Parents:
- 45fcbb8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubiopitch
r45fcbb8 r3e29681 12 12 13 13 def parse_args(): 14 from optparse import OptionParser 15 parser = OptionParser(usage=usage) 16 parser.add_option("-i","--input", 17 action="store", dest="filename", 18 help="input sound file") 19 parser.add_option("-m","--mode", 20 action="store", dest="mode", default='mcomb', 21 help="pitch detection mode [default=mcomb] \ 22 mcomb|yin|fcomb|schmitt") 23 parser.add_option("-u","--units", action="callback", 24 callback=check_pitchm_mode, dest="omode", 25 default=aubio_pitchm_freq, 26 help="output pitch in units [default=Hz] \ 27 freq|midi|cent|bin") 28 parser.add_option("-B","--bufsize", 29 action="store", dest="bufsize", default=None, 30 help="buffer size [default=1024]") 31 parser.add_option("-H","--hopsize", 32 action="store", dest="hopsize", default=None, 33 help="overlap size [default=512]") 34 parser.add_option("-t","--threshold", 35 action="store", dest="threshold", default=0.1, 36 help="pitch threshold (for yin) [default=0.1]") 37 parser.add_option("-s","--silence", 38 action="store", dest="silence", default=-70, 39 help="silence threshold [default=-70]") 40 parser.add_option("-D","--delay", 41 action="store", dest="delay", 42 help="number of seconds frames to take back [default=0]") 43 parser.add_option("-S","--smoothing", 44 action="store", dest="smoothing", default=False, 45 help="use a median filter of N frames [default=0]") 46 parser.add_option("-M","--maximum", 47 action="store", dest="pitchmax", default=False, 48 help="maximum pitch value to look for (Hz) [default=20000]") 49 parser.add_option("-l","--minimum", 50 action="store", dest="pitchmin", default=False, 51 help="minimum pitch value to look for (Hz) [default=20]") 52 # to be implemented 53 parser.add_option("-n","--note", 54 action="store_true", dest="note", default=False, 55 help="NOT IMPLEMENTED output notes") 56 # plotting functions 57 parser.add_option("-p","--plot", 58 action="store_true", dest="plot", default=False, 59 help="draw plot of the pitch track") 60 parser.add_option("-O","--outplot", 61 action="store", dest="outplot", default=None, 62 help="save the plot to output.{ps,png,svg} instead of displaying it") 63 parser.add_option("-v","--verbose", 64 action="store_true", dest="verbose", default=False, 65 help="make lots of noise") 66 parser.add_option("-q","--quiet", 67 action="store_false", dest="verbose", default=False, 68 help="be quiet") 69 (options, args) = parser.parse_args() 70 if not options.bufsize: 71 if options.mode == aubio_pitch_yin: options.bufsize = 1024 72 if options.mode == aubio_pitch_schmitt: options.bufsize = 2048 73 if options.mode == aubio_pitch_mcomb: options.bufsize = 4096 74 if options.mode == aubio_pitch_fcomb: options.bufsize = 4096 75 else: options.bufsize = 2048 76 if not options.hopsize: 77 options.hopsize = float(options.bufsize) / 2 78 if not options.filename: 79 print "no file name given\n", usage 80 sys.exit(1) 81 return options, args 14 from optparse import OptionParser 15 parser = OptionParser(usage=usage) 16 parser.add_option("-i","--input", 17 action="store", dest="filename", 18 help="input sound file") 19 parser.add_option("-m","--mode", 20 action="store", dest="mode", default='mcomb', 21 help="pitch detection mode [default=mcomb] \ 22 mcomb|yin|fcomb|schmitt") 23 parser.add_option("-u","--units", action="callback", 24 callback=check_pitchm_mode, dest="omode", 25 default=aubio_pitchm_freq, 26 help="output pitch in units [default=Hz] \ 27 freq|midi|cent|bin") 28 parser.add_option("-B","--bufsize", 29 action="store", dest="bufsize", default=None, 30 help="buffer size [default=1024]") 31 parser.add_option("-H","--hopsize", 32 action="store", dest="hopsize", default=None, 33 help="overlap size [default=512]") 34 parser.add_option("-t","--threshold", 35 action="store", dest="threshold", default=0.1, 36 help="pitch threshold (for yin) [default=0.1]") 37 parser.add_option("-s","--silence", 38 action="store", dest="silence", default=-70, 39 help="silence threshold [default=-70]") 40 parser.add_option("-D","--delay", 41 action="store", dest="delay", 42 help="number of seconds frames to take back [default=0]") 43 parser.add_option("-S","--smoothing", 44 action="store", dest="smoothing", default=False, 45 help="use a median filter of N frames [default=0]") 46 parser.add_option("-M","--maximum", 47 action="store", dest="pitchmax", default=False, 48 help="maximum pitch value to look for (Hz) [default=20000]") 49 parser.add_option("-l","--minimum", 50 action="store", dest="pitchmin", default=False, 51 help="minimum pitch value to look for (Hz) [default=20]") 52 # to be implemented 53 parser.add_option("-n","--note", 54 action="store_true", dest="note", default=False, 55 help="NOT IMPLEMENTED output notes") 56 # plotting functions 57 parser.add_option("-T","--plottruth", 58 action="store_true", dest="plottruth", default=False, 59 help="draw plot of the ground truth pitch track") 60 parser.add_option("-p","--plot", 61 action="store_true", dest="plot", default=False, 62 help="draw plot of the pitch track") 63 parser.add_option("-O","--outplot", 64 action="store", dest="outplot", default=None, 65 help="save the plot to output.{ps,png,svg} instead of displaying it") 66 parser.add_option("-v","--verbose", 67 action="store_true", dest="verbose", default=False, 68 help="make lots of noise") 69 parser.add_option("-q","--quiet", 70 action="store_false", dest="verbose", default=False, 71 help="be quiet") 72 (options, args) = parser.parse_args() 73 if not options.bufsize: 74 if options.mode == aubio_pitch_yin: options.bufsize = 1024 75 if options.mode == aubio_pitch_schmitt: options.bufsize = 2048 76 if options.mode == aubio_pitch_mcomb: options.bufsize = 4096 77 if options.mode == aubio_pitch_fcomb: options.bufsize = 4096 78 else: options.bufsize = 2048 79 if not options.hopsize: 80 options.hopsize = float(options.bufsize) / 2 81 if not options.filename: 82 print "no file name given\n", usage 83 sys.exit(1) 84 return options, args 82 85 83 86 options, args = parse_args() … … 104 107 exit("not implemented yet") 105 108 106 wplot,oplots =[],[]109 wplot,oplots,titles = [],[],[] 107 110 modes = options.mode.split(',') 108 111 for i in range(len(modes)): … … 112 115 pitch = filetask.compute_all() 113 116 #print filetask.eval(pitch[i]) 114 if options.plot: filetask.plot(pitch,wplot,oplots )117 if options.plot: filetask.plot(pitch,wplot,oplots,titles) 115 118 116 119 if options.plot: 117 filetask.plotplot(wplot,oplots, outplot=options.outplot)120 filetask.plotplot(wplot,oplots,titles,outplot=options.outplot,truth=options.plottruth)
Note: See TracChangeset
for help on using the changeset viewer.