shithub: aubio

ref: fce58d9e922e2ffdc979531af4302583f16ae2b4
dir: /python/aubioplot-audio/

View raw version
#!/usr/bin/python

import sys
from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_audio

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")
        gnuplot_addargs(parser)
        (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()

if options.outplot: 
  extension = options.outplot.split('.')[-1] 
  outplot = '.'.join(options.outplot.split('.')[:-1])
else: 
  extension = ''
  outplot = None

g = gnuplot_create(outplot,extension,options)
plot_audio(options.filename.split(','), g, options)