add aubioplot-spec
authorPaul Brossier <piem@altern.org>
Thu, 27 Jul 2006 19:27:20 +0000 (19:27 +0000)
committerPaul Brossier <piem@altern.org>
Thu, 27 Jul 2006 19:27:20 +0000 (19:27 +0000)
add aubioplot-spec

python/aubioplot-spec [new file with mode: 0755]

diff --git a/python/aubioplot-spec b/python/aubioplot-spec
new file mode 100755 (executable)
index 0000000..fe5ab53
--- /dev/null
@@ -0,0 +1,54 @@
+#! /usr/bin/python
+
+""" this file was written by Paul Brossier 
+  it is released under the GNU/GPL license.
+"""
+
+import sys
+from aubio.gnuplot import *
+
+usage = "usage: %s [options] -i soundfile" % sys.argv[0]
+
+def parse_args():
+        from optparse import OptionParser
+        parser = OptionParser(usage=usage)
+        parser.add_option("-i","--input",
+                          action="store", dest="filename", 
+                          help="input sound file")
+        parser.add_option("-M","--maxf",
+                          action="store", dest="maxf", default=0., 
+                          type='float',help="higher frequency limit")
+        parser.add_option("-L","--minf",
+                          action="store", dest="minf", default=0., 
+                          type='float',help="lower frequency limit")
+        parser.add_option("-x","--xsize",
+                          action="store", dest="xsize", default=1., 
+                          type='float',help="define xsize for plot")
+        parser.add_option("-y","--ysize",
+                          action="store", dest="ysize", default=1., 
+                          type='float',help="define ysize for plot")
+        parser.add_option("-l","--log",
+                          action="store_true", dest="log", default=False, 
+                          help="plot on a logarithmic scale")
+        parser.add_option("-O","--outplot",
+                          action="store", dest="outplot", default=None, 
+                          help="save plot to output.{ps,png}")
+        (options, args) = parser.parse_args()
+        if not options.filename: 
+                 print "no file name given\n", usage
+                 sys.exit(1)
+        return options, args
+
+options, args = parse_args()
+filename = options.filename
+
+if options.outplot: 
+  extension = options.outplot.split('.')[-1] 
+  outplot = '.'.join(options.outplot.split('.')[:-1])
+else: 
+  extension = ''
+  outplot = None
+
+plot_spec(filename, outplot=outplot, extension=extension, log=options.log,
+  maxf = options.maxf, minf = options.minf, 
+  xsize = options.xsize, ysize = options.ysize)