Changeset 470a772 for python/aubio/task/pitch.py
- Timestamp:
- Jul 13, 2006, 3:48:24 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:
- bf8e134
- Parents:
- 9c54265
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/task/pitch.py
r9c54265 r470a772 162 162 163 163 164 def plotplot(self,wplot,oplots,titles,outplot=None, multiplot = 1, midi = 1, truth = 1):165 from aubio.gnuplot import gnuplot_ init, audio_to_array, make_audio_plot164 def plotplot(self,wplot,oplots,titles,outplot=None,extension=None,xsize=1.,ysize=1.,multiplot = 1, midi = 1, truth = 1): 165 from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot 166 166 import re 167 167 import Gnuplot 168 # audio data169 time,data = audio_to_array(self.input)170 f = make_audio_plot(time,data)171 168 172 169 # check if ground truth exists … … 177 174 title='ground truth')] + oplots 178 175 179 t = Gnuplot.Data(0,0,with='impulses') 180 181 g = gnuplot_init(outplot) 176 g = gnuplot_create(outplot=outplot, extension=extension) 182 177 g('set title \'%s\'' % (re.sub('.*/','',self.input))) 178 g('set size %f,%f' % (xsize,ysize) ) 183 179 g('set multiplot') 184 180 # hack to align left axis 185 181 g('set lmargin 4') 186 182 g('set rmargin 4') 187 # plot waveform and onsets 188 g('set size 1,0.3') 189 g('set ytics 10') 190 g('set origin 0,0.7') 183 # plot waveform 184 time,data = audio_to_array(self.input) 185 wplot = [make_audio_plot(time,data)] 186 g('set origin 0,%f' % (0.7*ysize) ) 187 g('set size %f,%f' % (xsize,0.3*ysize)) 188 #g('set format y "%1f"') 191 189 g('set xrange [0:%f]' % max(time)) 192 190 g('set yrange [-1:1]') 193 191 g('set noytics') 194 192 g('set y2tics -1,1') 195 g.xlabel('time (s)',offset=(0,0. 8))193 g.xlabel('time (s)',offset=(0,0.7)) 196 194 g.ylabel('amplitude') 197 g.plot(f) 195 g.plot(*wplot) 196 197 # default settings for next plots 198 198 g('unset title') 199 # plot onset detection function200 201 202 g ('set size 1,0.7')203 g('set origin 0,0')204 g('set xrange [0:%f]' % max(time)) 199 g('set format x ""') 200 g('set format y "%3e"') 201 g('set tmargin 0') 202 g.xlabel('') 203 g('set noclip one') 204 205 205 if not midi: 206 206 g('set log y') … … 212 212 g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax))) 213 213 g('set y2tics %f,%f' % (round(aubio_freqtomidi(self.params.pitchmin)+.5),12)) 214 g('set key right top') 215 g('set noclip one') 216 g('set format x ""') 214 217 215 if multiplot: 218 g('set tmargin 0') 219 for i in range(len(oplots)): 220 # plot onset detection functions 221 g('set size 1,%f' % (0.7/(len(oplots)))) 222 g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7/(len(oplots)))) 216 N = len(oplots) 217 y = 0.7*ysize # the vertical proportion of the plot taken by onset functions 218 delta = 0.035 # the constant part of y taken by last plot label and data 219 for i in range(N): 220 # plot pitch detection functions 221 g('set size %f,%f' % ( xsize, (y-delta)/N)) 222 g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta )) 223 g('set nokey') 223 224 g('set xrange [0:%f]' % max(time)) 224 g('set nokey')225 225 g.ylabel(titles[i]) 226 g.xlabel('') 226 if i == N-1: 227 g('set size %f,%f' % (xsize, (y-delta)/N + delta ) ) 228 g('set origin 0,0') 229 g.xlabel('time (s)', offset=(0,0.7)) 230 g('set format x') 227 231 g.plot(oplots[i]) 228 232 else: 233 g('set key right top') 229 234 g.plot(*oplots) 230 235 g('unset multiplot')
Note: See TracChangeset
for help on using the changeset viewer.