shithub: aubio

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