Changeset 9b138a8
- Timestamp:
- May 17, 2006, 11:18:56 AM (19 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:
- ba11e53
- Parents:
- 7cded32
- Location:
- python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/gnuplot.py
r7cded32 r9b138a8 73 73 g.gnuplot('unset multiplot;') 74 74 75 def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = 0.):75 def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = -20.): 76 76 from aubioclass import fvec,cvec,pvoc,sndfile 77 77 from math import log10 … … 135 135 g('set yrange [%f:%f]' % (max(10,minf),maxf)) 136 136 g('set log y') 137 g.splot(Gnuplot.GridData(data,time,freq, binary=1 , title='mag. (dB)'))137 g.splot(Gnuplot.GridData(data,time,freq, binary=1)) 138 138 #xorig += 1./todraw 139 139 -
python/aubio/task/onset.py
r7cded32 r9b138a8 140 140 141 141 142 def plotplot(self,wplot,oplots,outplot=None ):143 from aubio.gnuplot import gnuplot_ init, audio_to_array, make_audio_plot142 def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False): 143 from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot, audio_to_spec 144 144 import re 145 # audio data146 time,data = audio_to_array(self.input)147 wplot = [make_audio_plot(time,data)] + wplot148 145 # prepare the plot 149 g = gnuplot_init(outplot) 150 146 g = gnuplot_create(outplot=outplot, extension=extension) 147 148 if spectro: 149 g('set size %f,%f' % (xsize,1.3*ysize) ) 150 else: 151 g('set size %f,%f' % (xsize,ysize) ) 151 152 g('set multiplot') 152 153 … … 161 162 for i in range(len(oplots)): 162 163 # plot onset detection functions 163 g('set size 1,%f' % (0.7/(len(oplots))))164 g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7 /(len(oplots))))164 g('set size %f,%f' % (xsize,0.7*ysize/(len(oplots)))) 165 g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7*ysize/(len(oplots)))) 165 166 g('set xrange [0:%f]' % (self.lenofunc*self.params.step)) 166 167 g('set nokey') … … 172 173 g.plot(*oplots[i][0]) 173 174 175 if spectro: 176 import Gnuplot 177 minf = 50 178 maxf = 500 179 data,time,freq = audio_to_spec(self.input,minf=minf,maxf=maxf) 180 g('set size %f,%f' % (1.24*xsize , 0.34*ysize) ) 181 g('set origin %f,%f' % (-0.12,0.65*ysize)) 182 g('set xrange [0.:%f]' % time[-1]) 183 g('set yrange [%f:%f]' % (minf,maxf)) 184 g('set pm3d map') 185 g('unset colorbox') 186 g('set lmargin 0') 187 g('set rmargin 0') 188 g('set tmargin 0') 189 g('set palette rgbformulae -25,-24,-32') 190 g.xlabel('') 191 g.ylabel('freq (Hz)') 192 #if log: 193 # g('set yrange [%f:%f]' % (max(10,minf),maxf)) 194 # g('set log y') 195 g.splot(Gnuplot.GridData(data,time,freq, binary=1, title='')) 196 g('set lmargin 3') 197 g('set rmargin 6') 198 g('set origin 0,%f' % (1.0*ysize) ) 199 g('set format x "%1.1f"') 200 g.xlabel('time (s)',offset=(0,1.)) 201 else: 202 # plot waveform and onsets 203 g('set origin 0,%f' % (0.7*ysize) ) 204 g.xlabel('time (s)',offset=(0,0.7)) 205 g('set format y "%1f"') 206 207 g('set size %f,%f' % (1.*xsize, 0.3*ysize)) 208 g('set title \'%s %s\'' % (re.sub('.*/','',self.input),self.title)) 174 209 g('set tmargin 2') 175 g.xlabel('time (s)',offset=(0,0.7))176 g('set format x "%1.1f"')177 g('set format y "%1f"')210 # audio data 211 time,data = audio_to_array(self.input) 212 wplot = [make_audio_plot(time,data)] + wplot 178 213 g('set y2tics -1,1') 179 214 180 181 g('set title \'%s %s\'' % (re.sub('.*/','',self.input),self.title))182 183 # plot waveform and onsets184 g('set size 1,0.3')185 g('set origin 0,0.7')186 215 g('set xrange [0:%f]' % max(time)) 187 216 g('set yrange [-1:1]') -
python/aubiocut
r7cded32 r9b138a8 62 62 action="store_true", dest="plot", default=False, 63 63 help="draw plot") 64 parser.add_option("-f","--function", 65 action="store_true", dest="func", default=False, 66 help="print detection function") 64 parser.add_option("-x","--xsize", 65 action="store", dest="xsize", default=1., 66 type='float', help="define xsize for plot") 67 parser.add_option("-y","--ysize", 68 action="store", dest="ysize", default=1., 69 type='float', help="define ysize for plot") 70 parser.add_option("-f","--function", 71 action="store_true", dest="func", default=False, 72 help="print detection function") 67 73 parser.add_option("-n","--no-onsets", 68 74 action="store_true", dest="nplot", default=False, 69 help=" plot only detection functions")75 help="do not plot detected onsets") 70 76 parser.add_option("-O","--outplot", 71 77 action="store", dest="outplot", default=None, 72 78 help="save plot to output.{ps,png}") 79 parser.add_option("-F","--spectrogram", 80 action="store_true", dest="spectro", default=False, 81 help="add spectrogram to the plot") 73 82 parser.add_option("-v","--verbose", 74 83 action="store_true", dest="verbose", default=False, … … 131 140 print i 132 141 133 if options.plot: filetask.plotplot(wplot, oplots, outplot=options.outplot) 142 if options.outplot: 143 extension = options.outplot.split('.')[-1] 144 outplot = '.'.join(options.outplot.split('.')[:-1]) 145 else: 146 extension,outplot = None,None 147 if options.plot: filetask.plotplot(wplot, oplots, outplot=outplot, extension=extension, 148 xsize=options.xsize,ysize=options.ysize,spectro=options.spectro) 134 149 135 150 if options.cut:
Note: See TracChangeset
for help on using the changeset viewer.