shithub: aubio

ref: 892c36931e1ee7d478457119c30237b2e249673b
dir: /python.old/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)