- Timestamp:
- Aug 2, 2006, 5:55:02 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:
- dbd19ea
- Parents:
- 0ab19df
- Location:
- python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/gnuplot.py
r0ab19df r33cf541 20 20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 21 """ 22 23 24 __notesheight = 0.2525 22 26 23 … … 46 43 return time,data 47 44 48 def plot_audio(filenames, g, start=0, end=None, noaxis=None,xsize=1.,ysize=1.):45 def plot_audio(filenames, g, options): 49 46 d = [] 50 47 todraw = len(filenames) 51 48 xorig = 0. 52 49 xratio = 1./todraw 53 #g('set rmargin 7')54 50 g('set multiplot;') 55 51 while (len(filenames)): 56 52 time,data = audio_to_array(filenames.pop(0)) 57 if not noaxis andtodraw==1:53 if todraw==1: 58 54 if max(time) < 1.: 59 55 time = [t*1000. for t in time] … … 63 59 g.ylabel('Amplitude') 64 60 d.append(make_audio_plot(time,data)) 65 g('set size %f,%f;' % ( xsize*xratio,ysize) )61 g('set size %f,%f;' % (options.xsize*xratio,options.ysize) ) 66 62 g('set origin %f,0.;' % (xorig) ) 67 63 g('set style data lines; \ … … 69 65 set xrange [0:%f]' % time[-1]) 70 66 g.plot(d.pop(0)) 71 xorig += xsize*xratio67 xorig += options.xsize*xratio 72 68 g('unset multiplot;') 73 69 … … 116 112 return data,time,freq 117 113 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):114 def plot_spec(filename, g, options): 119 115 import Gnuplot 120 data,time,freq = audio_to_spec(filename,minf=minf,maxf=maxf,bufsize=bufsize,hopsize=hopsize) 116 data,time,freq = audio_to_spec(filename, 117 minf=options.minf,maxf=options.maxf, 118 bufsize=options.bufsize,hopsize=options.hopsize) 121 119 xorig = 0. 122 if not noaxis: 123 if max(time) < 1.: 124 time = [t*1000. for t in time] 125 g.xlabel('Time (ms)') 126 else: 127 g.xlabel('Time (s)') 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)') 120 if max(time) < 1.: 121 time = [t*1000. for t in time] 122 g.xlabel('Time (ms)') 123 else: 124 g.xlabel('Time (s)') 125 if options.xsize < 0.5 and not options.log and max(time) > 1.: 126 freq = [f/1000. for f in freq] 127 options.minf /= 1000. 128 options.maxf /= 1000. 129 g.ylabel('Frequency (kHz)') 130 else: 131 g.ylabel('Frequency (Hz)') 135 132 g('set pm3d map') 136 133 g('set palette rgbformulae -25,-24,-32') 137 #g('set lmargin 4')138 134 g('set cbtics 20') 139 135 #g('set colorbox horizontal') 140 136 g('set xrange [0.:%f]' % time[-1]) 141 if log:137 if options.log: 142 138 g('set log y') 143 g('set yrange [%f:%f]' % (max(10, minf),maxf))139 g('set yrange [%f:%f]' % (max(10,options.minf),options.maxf)) 144 140 else: 145 g('set yrange [%f:%f]' % ( minf,maxf))141 g('set yrange [%f:%f]' % (options.minf,options.maxf)) 146 142 g.splot(Gnuplot.GridData(data,time,freq, binary=1)) 147 143 #xorig += 1./todraw … … 171 167 action="store", dest="ysize", default=1., 172 168 type='float',help="define ysize for plot") 173 parser.add_option("- d","--debug",169 parser.add_option("--debug", 174 170 action="store_true", dest="debug", default=False, 175 171 help="use gnuplot debug mode") 176 parser.add_option("- p","--persist",172 parser.add_option("--persist", 177 173 action="store_false", dest="persist", default=True, 178 174 help="do not use gnuplot persistant mode") 175 parser.add_option("--lmargin", 176 action="store", dest="lmargin", default=None, 177 type='int',help="define left margin for plot") 178 parser.add_option("--rmargin", 179 action="store", dest="rmargin", default=None, 180 type='int',help="define right margin for plot") 181 parser.add_option("--bmargin", 182 action="store", dest="bmargin", default=None, 183 type='int',help="define bottom margin for plot") 184 parser.add_option("--tmargin", 185 action="store", dest="tmargin", default=None, 186 type='int',help="define top margin for plot") 179 187 parser.add_option("-O","--outplot", 180 188 action="store", dest="outplot", default=None, … … 192 200 else: exit("ERR: unknown plot extension") 193 201 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) 194 206 if outplot != "stdout": 195 207 g('set output \'%s%s\'' % (outplot,ext)) -
python/aubioplot-audio
r0ab19df r33cf541 29 29 30 30 g = gnuplot_create(outplot,extension,options) 31 plot_audio(options.filename.split(','), g, 32 xsize=options.xsize, 33 ysize=options.ysize) 31 plot_audio(options.filename.split(','), g, options) -
python/aubioplot-spec
r0ab19df r33cf541 49 49 50 50 g = gnuplot_create(outplot,extension,options) 51 plot_spec(filename, g, log=options.log, 52 maxf = options.maxf, minf = options.minf, 53 xsize = options.xsize, ysize = options.ysize, 54 bufsize = options.bufsize, hopsize = options.hopsize) 51 plot_spec(filename, g, options)
Note: See TracChangeset
for help on using the changeset viewer.