Changeset e81c045
- Timestamp:
- Sep 5, 2006, 6:32:20 PM (18 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/gnuplot.py
rdbd19ea re81c045 44 44 45 45 def plot_audio(filenames, g, options): 46 d = []47 46 todraw = len(filenames) 48 47 xorig = 0. … … 58 57 g.xlabel('Time (s)') 59 58 g.ylabel('Amplitude') 60 d.append(make_audio_plot(time,data))59 curplot = make_audio_plot(time,data) 61 60 g('set size %f,%f;' % (options.xsize*xratio,options.ysize) ) 62 61 g('set origin %f,0.;' % (xorig) ) … … 64 63 set yrange [-1.:1.]; \ 65 64 set xrange [0:%f]' % time[-1]) 66 g.plot( d.pop(0))65 g.plot(curplot) 67 66 xorig += options.xsize*xratio 68 67 g('unset multiplot;') … … 159 158 return Gnuplot.Data(x,y,with='lines') 160 159 160 def 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 161 170 def gnuplot_addargs(parser): 162 171 """ add common gnuplot argument to OptParser object """ … … 191 200 def gnuplot_create(outplot='',extension='', options=None): 192 201 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) 194 206 if not extension or not outplot: return g 195 207 if extension == 'ps': ext, extension = '.ps' , 'postscript' … … 200 212 else: exit("ERR: unknown plot extension") 201 213 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) 206 218 if outplot != "stdout": 207 219 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)) 209 221 return g
Note: See TracChangeset
for help on using the changeset viewer.