shithub: aubio

ref: b8c0685e23d0f31c8796ef4958bb167e55552216
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)