1 | #!/usr/bin/python |
---|
2 | |
---|
3 | import aubio.gnuplot, sys |
---|
4 | |
---|
5 | usage = "usage: %s [options] -i soundfile" % sys.argv[0] |
---|
6 | |
---|
7 | def parse_args(): |
---|
8 | from optparse import OptionParser |
---|
9 | parser = OptionParser(usage=usage) |
---|
10 | parser.add_option("-i","--input", |
---|
11 | action="store", dest="filename", |
---|
12 | help="input sound file") |
---|
13 | parser.add_option("-x","--xsize", |
---|
14 | action="store", dest="xsize", default=1., |
---|
15 | help="define xsize for plot") |
---|
16 | parser.add_option("-y","--ysize", |
---|
17 | action="store", dest="ysize", default=1., |
---|
18 | help="define ysize for plot") |
---|
19 | parser.add_option("-O","--outplot", |
---|
20 | action="store", dest="outplot", default=None, |
---|
21 | help="save plot to output.{ps,png}") |
---|
22 | (options, args) = parser.parse_args() |
---|
23 | if not options.filename: |
---|
24 | print "no file name given\n", usage |
---|
25 | sys.exit(1) |
---|
26 | return options, args |
---|
27 | |
---|
28 | options, args = parse_args() |
---|
29 | |
---|
30 | if options.outplot: |
---|
31 | extension = options.outplot.split('.')[-1] |
---|
32 | outplot = '.'.join(options.outplot.split('.')[:-1]) |
---|
33 | else: |
---|
34 | extension = '' |
---|
35 | outplot = None |
---|
36 | |
---|
37 | aubio.gnuplot.plot_audio(options.filename.split(','), |
---|
38 | extension = extension, |
---|
39 | outplot = outplot, |
---|
40 | xsize=float(options.xsize), |
---|
41 | ysize=float(options.ysize)) |
---|