source: python/aubioplot-spec @ 32fa8e8

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 32fa8e8 was e5cc1ea, checked in by Paul Brossier <piem@altern.org>, 18 years ago

pass created plot to plot_audio/spec instead of outplot/extension, minor fixes
pass created plot to plot_audio/spec instead of outplot/extension, minor fixes

  • Property mode set to 100755
File size: 2.5 KB
Line 
1#! /usr/bin/python
2
3""" this file was written by Paul Brossier
4  it is released under the GNU/GPL license.
5"""
6
7import sys
8from aubio.gnuplot import *
9
10usage = "usage: %s [options] -i soundfile" % sys.argv[0]
11
12def 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=10000.,
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        parser.add_option("-B","--bufsize", type='int',
37                          action="store", dest="bufsize", default=8192,
38                          help="buffer size [default=8192]")
39        parser.add_option("-H","--hopsize", type='int',
40                          action="store", dest="hopsize", default=1024,
41                          help="overlap size [default=1024]")
42        (options, args) = parser.parse_args()
43        if not options.filename:
44                 print "no file name given\n", usage
45                 sys.exit(1)
46        return options, args
47
48options, args = parse_args()
49filename = options.filename
50
51if options.outplot:
52  extension = options.outplot.split('.')[-1]
53  outplot = '.'.join(options.outplot.split('.')[:-1])
54else:
55  extension = ''
56  outplot = None
57
58g = gnuplot_create(outplot,extension,xsize=options.xsize, ysize=options.ysize)
59plot_spec(filename, g, log=options.log,
60  maxf = options.maxf, minf = options.minf,
61  xsize = options.xsize, ysize = options.ysize,
62  bufsize = options.bufsize, hopsize = options.hopsize)
Note: See TracBrowser for help on using the repository browser.