Changeset 9b138a8 for python/aubio/task
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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]')
Note: See TracChangeset
for help on using the changeset viewer.