Changeset 0ab19df for python


Ignore:
Timestamp:
Aug 2, 2006, 5:25:09 PM (18 years ago)
Author:
Paul Brossier <piem@altern.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
33cf541
Parents:
32fa8e8
Message:

factorise gnuplot_create options, update aubioplot-spec/audio
factorise gnuplot_create options, update aubioplot-spec/audio

Location:
python
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/gnuplot.py

    r32fa8e8 r0ab19df  
    163163  return Gnuplot.Data(x,y,with='lines')
    164164
    165 def gnuplot_create(outplot='',extension='',debug=0,persist=1, xsize=1., ysize=1.):
    166         import Gnuplot
    167         g = Gnuplot.Gnuplot(debug=debug, persist=persist)
    168         if not extension or not outplot: return g
    169         if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
    170         elif extension == 'eps': ext, extension = '.eps' , 'postscript enhanced'
    171         elif extension == 'epsc': ext, extension = '.eps' , 'postscript enhanced color'
    172         elif extension == 'png': ext, extension = '.png', 'png'
    173         elif extension == 'svg': ext, extension = '.svg', 'svg'
    174         else: exit("ERR: unknown plot extension")
    175         g('set terminal %s' % extension)
    176         if outplot != "stdout":
    177                 g('set output \'%s%s\'' % (outplot,ext))
    178         g('set size %f,%f' % (xsize, ysize))
    179         return g
     165def gnuplot_addargs(parser):
     166  """ add common gnuplot argument to OptParser object """
     167  parser.add_option("-x","--xsize",
     168          action="store", dest="xsize", default=1.,
     169          type='float',help="define xsize for plot")
     170  parser.add_option("-y","--ysize",
     171          action="store", dest="ysize", default=1.,
     172          type='float',help="define ysize for plot")
     173  parser.add_option("-d","--debug",
     174          action="store_true", dest="debug", default=False,
     175          help="use gnuplot debug mode")
     176  parser.add_option("-p","--persist",
     177          action="store_false", dest="persist", default=True,
     178          help="do not use gnuplot persistant mode")
     179  parser.add_option("-O","--outplot",
     180          action="store", dest="outplot", default=None,
     181          help="save plot to output.{ps,png}")
     182
     183def gnuplot_create(outplot='',extension='', options=None):
     184  import Gnuplot
     185  g = Gnuplot.Gnuplot(debug=options.debug, persist=options.persist)
     186  if not extension or not outplot: return g
     187  if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
     188  elif extension == 'eps': ext, extension = '.eps' , 'postscript enhanced'
     189  elif extension == 'epsc': ext, extension = '.eps' , 'postscript enhanced color'
     190  elif extension == 'png': ext, extension = '.png', 'png'
     191  elif extension == 'svg': ext, extension = '.svg', 'svg'
     192  else: exit("ERR: unknown plot extension")
     193  g('set terminal %s' % extension)
     194  if outplot != "stdout":
     195    g('set output \'%s%s\'' % (outplot,ext))
     196  g('set size %f,%f' % (options.xsize, options.ysize))
     197  return g
  • python/aubioplot-audio

    r32fa8e8 r0ab19df  
    11#!/usr/bin/python
    22
    3 import aubio.gnuplot, sys
     3import sys
     4from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_audio
    45
    56usage = "usage: %s [options] -i soundfile" % sys.argv[0]
     
    1112                          action="store", dest="filename",
    1213                          help="input sound file")
    13         parser.add_option("-x","--xsize",
    14                           action="store", dest="xsize", default=1.,
    15                           type='float',help="define xsize for plot")
    16         parser.add_option("-y","--ysize",
    17                           action="store", dest="ysize", default=1.,
    18                           type='float',help="define ysize for plot")
    19         parser.add_option("-O","--outplot",
    20                           action="store", dest="outplot", default=None,
    21                           help="save plot to output.{ps,png}")
     14        gnuplot_addargs(parser)
    2215        (options, args) = parser.parse_args()
    2316        if not options.filename:
     
    3528  outplot = None
    3629
    37 g = aubio.gnuplot.gnuplot_create(outplot,extension,xsize=options.xsize, ysize=options.xsize)
    38 aubio.gnuplot.plot_audio(options.filename.split(','), g,
     30g = gnuplot_create(outplot,extension,options)
     31plot_audio(options.filename.split(','), g,
    3932  xsize=options.xsize,
    4033  ysize=options.ysize)
  • python/aubioplot-spec

    r32fa8e8 r0ab19df  
    66
    77import sys
    8 from aubio.gnuplot import *
     8from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_spec
    99
    1010usage = "usage: %s [options] -i soundfile" % sys.argv[0]
     
    2222                          action="store", dest="minf", default=0.,
    2323                          type='float',help="lower frequency limit")
    24         parser.add_option("-x","--xsize",
    25                           action="store", dest="xsize", default=1.,
    26                           type='float',help="define xsize for plot")
    27         parser.add_option("-y","--ysize",
    28                           action="store", dest="ysize", default=1.,
    29                           type='float',help="define ysize for plot")
    3024        parser.add_option("-l","--log",
    3125                          action="store_true", dest="log", default=False,
    3226                          help="plot on a logarithmic scale")
    33         parser.add_option("-O","--outplot",
    34                           action="store", dest="outplot", default=None,
    35                           help="save plot to output.{ps,png}")
    3627        parser.add_option("-B","--bufsize", type='int',
    3728                          action="store", dest="bufsize", default=8192,
     
    4031                          action="store", dest="hopsize", default=1024,
    4132                          help="overlap size [default=1024]")
     33        gnuplot_addargs(parser)
    4234        (options, args) = parser.parse_args()
    4335        if not options.filename:
     
    5648  outplot = None
    5749
    58 g = gnuplot_create(outplot,extension,xsize=options.xsize, ysize=options.ysize)
     50g = gnuplot_create(outplot,extension,options)
    5951plot_spec(filename, g, log=options.log,
    6052  maxf = options.maxf, minf = options.minf,
Note: See TracChangeset for help on using the changeset viewer.