Changeset e81c045 for python


Ignore:
Timestamp:
Sep 5, 2006, 6:32:20 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:
c2f3981
Parents:
dbd19ea
Message:

fix gnuplot_create without options, add envelope draft, remove useless list
fix gnuplot_create without options, add envelope draft, remove useless list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/gnuplot.py

    rdbd19ea re81c045  
    4444
    4545def plot_audio(filenames, g, options):
    46         d = []
    4746        todraw = len(filenames)
    4847        xorig = 0.
     
    5857                                g.xlabel('Time (s)')
    5958                        g.ylabel('Amplitude')
    60                 d.append(make_audio_plot(time,data))
     59                curplot = make_audio_plot(time,data)
    6160                g('set size %f,%f;' % (options.xsize*xratio,options.ysize) )
    6261                g('set origin %f,0.;' % (xorig) )
     
    6463                        set yrange [-1.:1.]; \
    6564                        set xrange [0:%f]' % time[-1])
    66                 g.plot(d.pop(0))
     65                g.plot(curplot)
    6766                xorig += options.xsize*xratio
    6867        g('unset multiplot;')
     
    159158  return Gnuplot.Data(x,y,with='lines')
    160159
     160def make_audio_envelope(time,data,maxpoints=10000):
     161  """ create gnuplot plot from an audio file """
     162  import numarray
     163  import Gnuplot, Gnuplot.funcutils
     164  bufsize = 500
     165  x = [i.mean() for i in numarray.array(time).resize(len(time)/bufsize,bufsize)]
     166  y = [i.mean() for i in numarray.array(data).resize(len(time)/bufsize,bufsize)]
     167  x,y = downsample_audio(x,y,maxpoints=maxpoints)
     168  return Gnuplot.Data(x,y,with='lines')
     169
    161170def gnuplot_addargs(parser):
    162171  """ add common gnuplot argument to OptParser object """
     
    191200def gnuplot_create(outplot='',extension='', options=None):
    192201  import Gnuplot
    193   g = Gnuplot.Gnuplot(debug=options.debug, persist=options.persist)
     202  if options:
     203    g = Gnuplot.Gnuplot(debug=options.debug, persist=options.persist)
     204  else:
     205    g = Gnuplot.Gnuplot(persist=1)
    194206  if not extension or not outplot: return g
    195207  if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
     
    200212  else: exit("ERR: unknown plot extension")
    201213  g('set terminal %s' % extension)
    202   if options.lmargin: g('set lmargin %i' % options.lmargin)
    203   if options.rmargin: g('set rmargin %i' % options.rmargin)
    204   if options.bmargin: g('set bmargin %i' % options.bmargin)
    205   if options.tmargin: g('set tmargin %i' % options.tmargin)
     214  if options and options.lmargin: g('set lmargin %i' % options.lmargin)
     215  if options and options.rmargin: g('set rmargin %i' % options.rmargin)
     216  if options and options.bmargin: g('set bmargin %i' % options.bmargin)
     217  if options and options.tmargin: g('set tmargin %i' % options.tmargin)
    206218  if outplot != "stdout":
    207219    g('set output \'%s%s\'' % (outplot,ext))
    208   g('set size %f,%f' % (options.xsize, options.ysize))
     220  if options: g('set size %f,%f' % (options.xsize, options.ysize))
    209221  return g
Note: See TracChangeset for help on using the changeset viewer.