Changeset e5cc1ea
- Timestamp:
- Aug 2, 2006, 4:46:50 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:
- 5ed9133
- Parents:
- 90bcdaa
- Location:
- python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/gnuplot.py
r90bcdaa re5cc1ea 46 46 return time,data 47 47 48 def plot_audio(filenames, outplot='', extension='', start=0, end=None, noaxis=None,xsize=1.,ysize=1.): 49 g = gnuplot_create(outplot, extension) 48 def plot_audio(filenames, g, start=0, end=None, noaxis=None,xsize=1.,ysize=1.): 50 49 d = [] 51 50 todraw = len(filenames) 52 51 xorig = 0. 53 52 xratio = 1./todraw 54 g.gnuplot('set size %f,%f;' % (xsize,ysize))55 g .gnuplot('set multiplot;')53 #g('set rmargin 7') 54 g('set multiplot;') 56 55 while (len(filenames)): 57 56 time,data = audio_to_array(filenames.pop(0)) … … 64 63 g.ylabel('Amplitude') 65 64 d.append(make_audio_plot(time,data)) 66 g .gnuplot('set size %f,%f;' % (xsize*xratio,ysize) )67 g .gnuplot('set origin %f,0.;' % (xorig) )68 g .gnuplot('set style data lines; \65 g('set size %f,%f;' % (xsize*xratio,ysize) ) 66 g('set origin %f,0.;' % (xorig) ) 67 g('set style data lines; \ 69 68 set yrange [-1.:1.]; \ 70 69 set xrange [0:%f]' % time[-1]) 71 70 g.plot(d.pop(0)) 72 71 xorig += xsize*xratio 73 g .gnuplot('unset multiplot;')72 g('unset multiplot;') 74 73 75 74 def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = -20., … … 117 116 return data,time,freq 118 117 119 def plot_spec(filename, outplot='',extension='', fileout=None, start=0, end=None, noaxis=None,log=1, minf=0, maxf= 0, xsize = 1., ysize = 1.,bufsize=8192, hopsize=1024):118 def plot_spec(filename, g, start=0, end=None, noaxis=None,log=1, minf=0, maxf= 0, xsize = 1., ysize = 1.,bufsize=8192, hopsize=1024): 120 119 import Gnuplot 121 g = gnuplot_create(outplot,extension)122 120 data,time,freq = audio_to_spec(filename,minf=minf,maxf=maxf,bufsize=bufsize,hopsize=hopsize) 123 121 xorig = 0. … … 128 126 else: 129 127 g.xlabel('Time (s)') 130 g.ylabel('Frequency (Hz)') 131 g('set size %f,%f' % (xsize, ysize)) 128 if xsize < 0.5 and not log and max(time) > 1.: 129 freq = [f/1000. for f in freq] 130 minf /= 1000. 131 maxf /= 1000. 132 g.ylabel('Frequency (kHz)') 133 else: 134 g.ylabel('Frequency (Hz)') 132 135 g('set pm3d map') 133 136 g('set palette rgbformulae -25,-24,-32') 137 #g('set lmargin 4') 138 g('set cbtics 20') 134 139 #g('set colorbox horizontal') 135 140 g('set xrange [0.:%f]' % time[-1]) 136 g('set yrange [%f:%f]' % (minf,maxf))137 141 if log: 142 g('set log y') 138 143 g('set yrange [%f:%f]' % (max(10,minf),maxf)) 139 g('set log y') 144 else: 145 g('set yrange [%f:%f]' % (minf,maxf)) 140 146 g.splot(Gnuplot.GridData(data,time,freq, binary=1)) 141 147 #xorig += 1./todraw … … 176 182 return g 177 183 178 def gnuplot_create(outplot='',extension='',debug=0,persist=1 ):184 def gnuplot_create(outplot='',extension='',debug=0,persist=1, xsize=1., ysize=1.): 179 185 import Gnuplot 180 186 g = Gnuplot.Gnuplot(debug=debug, persist=persist) … … 189 195 if outplot != "stdout": 190 196 g('set output \'%s%s\'' % (outplot,ext)) 197 g('set size %f,%f' % (xsize, ysize)) 191 198 return g -
python/aubioplot-audio
r90bcdaa re5cc1ea 35 35 outplot = None 36 36 37 aubio.gnuplot.plot_audio(options.filename.split(','), 38 extension = extension, 39 outplot = outplot, 40 g, 37 g = aubio.gnuplot.gnuplot_create(outplot,extension,xsize=options.xsize, ysize=options.xsize) 38 aubio.gnuplot.plot_audio(options.filename.split(','), g, 41 39 xsize=options.xsize, 42 40 ysize=options.ysize) -
python/aubioplot-spec
r90bcdaa re5cc1ea 56 56 outplot = None 57 57 58 plot_spec(filename, outplot=outplot, extension=extension, log=options.log, 58 g = gnuplot_create(outplot,extension,xsize=options.xsize, ysize=options.ysize) 59 plot_spec(filename, g, log=options.log, 59 60 maxf = options.maxf, minf = options.minf, 60 61 xsize = options.xsize, ysize = options.ysize,
Note: See TracChangeset
for help on using the changeset viewer.