Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -0,0 +1,54 @@ | |||
| 1 | #! /usr/bin/python | ||
| 2 | |||
| 3 | """ this file was written by Paul Brossier | ||
| 4 | it is released under the GNU/GPL license. | ||
| 5 | """ | ||
| 6 | |||
| 7 | import sys | ||
| 8 | from aubio.gnuplot import * | ||
| 9 | |||
| 10 | usage = "usage: %s [options] -i soundfile" % sys.argv[0] | ||
| 11 | |||
| 12 | def parse_args(): | ||
| 13 | from optparse import OptionParser | ||
| 14 | parser = OptionParser(usage=usage) | ||
| 15 | parser.add_option("-i","--input", | ||
| 16 | action="store", dest="filename", | ||
| 17 | help="input sound file") | ||
| 18 | parser.add_option("-M","--maxf", | ||
| 19 | action="store", dest="maxf", default=0., | ||
| 20 | type='float',help="higher frequency limit") | ||
| 21 | parser.add_option("-L","--minf", | ||
| 22 | action="store", dest="minf", default=0., | ||
| 23 | type='float',help="lower frequency limit") | ||
| 24 | parser.add_option("-x","--xsize", | ||
| 25 | action="store", dest="xsize", default=1., | ||
| 26 | type='float',help="define xsize for plot") | ||
| 27 | parser.add_option("-y","--ysize", | ||
| 28 | action="store", dest="ysize", default=1., | ||
| 29 | type='float',help="define ysize for plot") | ||
| 30 | parser.add_option("-l","--log", | ||
| 31 | action="store_true", dest="log", default=False, | ||
| 32 | help="plot on a logarithmic scale") | ||
| 33 | parser.add_option("-O","--outplot", | ||
| 34 | action="store", dest="outplot", default=None, | ||
| 35 | help="save plot to output.{ps,png}") | ||
| 36 | (options, args) = parser.parse_args() | ||
| 37 | if not options.filename: | ||
| 38 | print "no file name given\n", usage | ||
| 39 | sys.exit(1) | ||
| 40 | return options, args | ||
| 41 | |||
| 42 | options, args = parse_args() | ||
| 43 | filename = options.filename | ||
| 44 | |||
| 45 | if options.outplot: | ||
| 46 | extension = options.outplot.split('.')[-1] | ||
| 47 | outplot = '.'.join(options.outplot.split('.')[:-1]) | ||
| 48 | else: | ||
| 49 | extension = '' | ||
| 50 | outplot = None | ||
| 51 | |||
| 52 | plot_spec(filename, outplot=outplot, extension=extension, log=options.log, | ||
| 53 | maxf = options.maxf, minf = options.minf, | ||
| 54 | xsize = options.xsize, ysize = options.ysize) | ||