[36dfbc6] | 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 |
---|
[0ab19df] | 8 | from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_spec |
---|
[36dfbc6] | 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", |
---|
[e638bcf] | 19 | action="store", dest="maxf", default=10000., |
---|
[36dfbc6] | 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("-l","--log", |
---|
| 25 | action="store_true", dest="log", default=False, |
---|
| 26 | help="plot on a logarithmic scale") |
---|
[e638bcf] | 27 | parser.add_option("-B","--bufsize", type='int', |
---|
| 28 | action="store", dest="bufsize", default=8192, |
---|
| 29 | help="buffer size [default=8192]") |
---|
| 30 | parser.add_option("-H","--hopsize", type='int', |
---|
| 31 | action="store", dest="hopsize", default=1024, |
---|
| 32 | help="overlap size [default=1024]") |
---|
[0ab19df] | 33 | gnuplot_addargs(parser) |
---|
[36dfbc6] | 34 | (options, args) = parser.parse_args() |
---|
| 35 | if not options.filename: |
---|
| 36 | print "no file name given\n", usage |
---|
| 37 | sys.exit(1) |
---|
| 38 | return options, args |
---|
| 39 | |
---|
| 40 | options, args = parse_args() |
---|
| 41 | filename = options.filename |
---|
| 42 | |
---|
| 43 | if options.outplot: |
---|
| 44 | extension = options.outplot.split('.')[-1] |
---|
| 45 | outplot = '.'.join(options.outplot.split('.')[:-1]) |
---|
| 46 | else: |
---|
| 47 | extension = '' |
---|
| 48 | outplot = None |
---|
| 49 | |
---|
[0ab19df] | 50 | g = gnuplot_create(outplot,extension,options) |
---|
[33cf541] | 51 | plot_spec(filename, g, options) |
---|