def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False): import Gnuplot from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot import re # audio data #time,data = audio_to_array(self.input) #f = make_audio_plot(time,data) g = gnuplot_create(outplot=outplot, extension=extension) oplots = [Gnuplot.Data(self.gettruth(),with_='linespoints',title="orig")] + oplots g.plot(*oplots)
def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False): import Gnuplot from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot import re # audio data #time,data = audio_to_array(self.input) #f = make_audio_plot(time,data) g = gnuplot_create(outplot=outplot, extension=extension) oplots = [Gnuplot.Data(self.gettruth(),with='linespoints',title="orig")] + oplots g.plot(*oplots)
def plotplot(self, wplot, oplots, outplot=None, extension=None, xsize=1.0, ysize=1.0, spectro=False): from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot, audio_to_spec import re # prepare the plot g = gnuplot_create(outplot=outplot, extension=extension) g("set title '%s'" % (re.sub(".*/", "", self.input))) if spectro: g("set size %f,%f" % (xsize, 1.3 * ysize)) else: g("set size %f,%f" % (xsize, ysize)) g("set multiplot") # hack to align left axis g("set lmargin 3") g("set rmargin 6") if spectro: import Gnuplot minf = 50 maxf = 500 data, time, freq = audio_to_spec(self.input, minf=minf, maxf=maxf) g("set size %f,%f" % (1.24 * xsize, 0.34 * ysize)) g("set origin %f,%f" % (-0.12, 0.65 * ysize)) g("set xrange [0.:%f]" % time[-1]) g("set yrange [%f:%f]" % (minf, maxf)) g("set pm3d map") g("unset colorbox") g("set lmargin 0") g("set rmargin 0") g("set tmargin 0") g("set palette rgbformulae -25,-24,-32") g.xlabel("time (s)", offset=(0, 1.0)) g.ylabel("freq (Hz)") g("set origin 0,%f" % (1.0 * ysize)) g('set format x "%1.1f"') # if log: # g('set yrange [%f:%f]' % (max(10,minf),maxf)) # g('set log y') g.splot(Gnuplot.GridData(data, time, freq, binary=1, title="")) else: # plot waveform and onsets time, data = audio_to_array(self.input) wplot = [make_audio_plot(time, data)] + wplot g("set origin 0,%f" % (0.7 * ysize)) g("set size %f,%f" % (xsize, 0.3 * ysize)) g('set format y "%1f"') g("set xrange [0:%f]" % max(time)) g("set yrange [-1:1]") g("set noytics") g("set y2tics -1,1") g.xlabel("time (s)", offset=(0, 0.7)) g.ylabel("amplitude") g.plot(*wplot) # default settings for next plots g("unset title") g('set format x ""') g('set format y "%3e"') g("set tmargin 0") g.xlabel("") N = len(oplots) y = 0.7 * ysize # the vertical proportion of the plot taken by onset functions delta = 0.035 # the constant part of y taken by last plot label and data for i in range(N): # plot onset detection functions g("set size %f,%f" % (xsize, (y - delta) / N)) g("set origin 0,%f" % ((N - i - 1) * (y - delta) / N + delta)) g("set nokey") g("set xrange [0:%f]" % (self.lenofunc * self.params.step)) g("set yrange [0:%f]" % (1.1 * oplots[i][2])) g('set y2tics ("0" 0, "%d" %d)' % (round(oplots[i][2]), round(oplots[i][2]))) g.ylabel(oplots[i][1]) if i == N - 1: g("set size %f,%f" % (xsize, (y - delta) / N + delta)) g("set origin 0,0") g.xlabel("time (s)", offset=(0, 0.7)) g("set format x") g.plot(*oplots[i][0]) g("unset multiplot")
if curnote > firstnote-1 and curnote < lastnote+1: xb = xb + [curnote] for octave in range(octaves-1): for i in xw_temp: curnote = i+12*octave if curnote > firstnote-1 and curnote < lastnote+1: xw = xw + [curnote] xwdelta = [1/2. * scalew for i in range(len(xw))] yw = [y0+(y1-y0)*1/2. for i in range(len(xw))] ywdelta = [(y1-y0)*1/2. for i in range(len(xw))] xbdelta = [2/3. * scaleb for i in range(len(xb))] yb = [y0+(y1-y0)*2/3. for i in range(len(xb))] ybdelta = [(y1-y0)*1/3. for i in range(len(xb))] whites = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with_ = 'boxxyerrorbars') blacks = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with_ = 'boxxyerrorbars fill solid') return blacks,whites if __name__ == '__main__': from aubio.gnuplot import gnuplot_create blacks,whites = draw_keyboard(firstnote = 21, lastnote = 108) g = gnuplot_create('','') #g('set style fill solid .5') #g('set xrange [60-.5:72+.5]') #g('set yrange [-0.1:1.1]') g.plot(whites,blacks)
if curnote > firstnote-1 and curnote < lastnote+1: xb = xb + [curnote] for octave in range(octaves-1): for i in xw_temp: curnote = i+12*octave if curnote > firstnote-1 and curnote < lastnote+1: xw = xw + [curnote] xwdelta = [1/2. * scalew for i in range(len(xw))] yw = [y0+(y1-y0)*1/2. for i in range(len(xw))] ywdelta = [(y1-y0)*1/2. for i in range(len(xw))] xbdelta = [2/3. * scaleb for i in range(len(xb))] yb = [y0+(y1-y0)*2/3. for i in range(len(xb))] ybdelta = [(y1-y0)*1/3. for i in range(len(xb))] whites = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with = 'boxxyerrorbars') blacks = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with = 'boxxyerrorbars fill solid') return blacks,whites if __name__ == '__main__': from aubio.gnuplot import gnuplot_create blacks,whites = draw_keyboard(firstnote = 21, lastnote = 108) g = gnuplot_create('','') #g('set style fill solid .5') #g('set xrange [60-.5:72+.5]') #g('set yrange [-0.1:1.1]') g.plot(whites,blacks)
def plotplot(self, wplot, oplots, titles, outplot=None, extension=None, xsize=1., ysize=1., multiplot=1, midi=1, truth=1): from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot import re import Gnuplot # check if ground truth exists if truth: timet, pitcht = self.gettruth() if timet and pitcht: oplots = [ Gnuplot.Data( timet, pitcht, with_='lines', title='ground truth') ] + oplots g = gnuplot_create(outplot=outplot, extension=extension) g('set title \'%s\'' % (re.sub('.*/', '', self.input))) g('set size %f,%f' % (xsize, ysize)) g('set multiplot') # hack to align left axis g('set lmargin 4') g('set rmargin 4') # plot waveform time, data = audio_to_array(self.input) wplot = [make_audio_plot(time, data)] g('set origin 0,%f' % (0.7 * ysize)) g('set size %f,%f' % (xsize, 0.3 * ysize)) #g('set format y "%1f"') g('set xrange [0:%f]' % max(time)) g('set yrange [-1:1]') g('set noytics') g('set y2tics -1,1') g.xlabel('time (s)', offset=(0, 0.7)) g.ylabel('amplitude') g.plot(*wplot) # default settings for next plots g('unset title') g('set format x ""') g('set format y "%3e"') g('set tmargin 0') g.xlabel('') g('set noclip one') if not midi: g('set log y') #g.xlabel('time (s)') g.ylabel('f0 (Hz)') g('set yrange [100:%f]' % self.params.pitchmax) else: g.ylabel('midi') g('set yrange [%f:%f]' % (aubio_freqtomidi( self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax))) g('set y2tics %f,%f' % (round(aubio_freqtomidi(self.params.pitchmin) + .5), 12)) if multiplot: N = len(oplots) y = 0.7 * ysize # the vertical proportion of the plot taken by onset functions delta = 0.035 # the constant part of y taken by last plot label and data for i in range(N): # plot pitch detection functions g('set size %f,%f' % (xsize, (y - delta) / N)) g('set origin 0,%f' % ((N - i - 1) * (y - delta) / N + delta)) g('set nokey') g('set xrange [0:%f]' % max(time)) g.ylabel(titles[i]) if i == N - 1: g('set size %f,%f' % (xsize, (y - delta) / N + delta)) g('set origin 0,0') g.xlabel('time (s)', offset=(0, 0.7)) g('set format x') g.plot(oplots[i]) else: g('set key right top') g.plot(*oplots) g('unset multiplot')
def plotplot(self,wplot,oplots,outplot=None,extension=None,xsize=1.,ysize=1.,spectro=False): from aubio.gnuplot import gnuplot_create, audio_to_array, make_audio_plot, audio_to_spec import re # prepare the plot g = gnuplot_create(outplot=outplot, extension=extension) g('set title \'%s\'' % (re.sub('.*/','',self.input))) if spectro: g('set size %f,%f' % (xsize,1.3*ysize) ) else: g('set size %f,%f' % (xsize,ysize) ) g('set multiplot') # hack to align left axis g('set lmargin 3') g('set rmargin 6') if spectro: import Gnuplot minf = 50 maxf = 500 data,time,freq = audio_to_spec(self.input,minf=minf,maxf=maxf) g('set size %f,%f' % (1.24*xsize , 0.34*ysize) ) g('set origin %f,%f' % (-0.12,0.65*ysize)) g('set xrange [0.:%f]' % time[-1]) g('set yrange [%f:%f]' % (minf,maxf)) g('set pm3d map') g('unset colorbox') g('set lmargin 0') g('set rmargin 0') g('set tmargin 0') g('set palette rgbformulae -25,-24,-32') g.xlabel('time (s)',offset=(0,1.)) g.ylabel('freq (Hz)') g('set origin 0,%f' % (1.0*ysize) ) g('set format x "%1.1f"') #if log: # g('set yrange [%f:%f]' % (max(10,minf),maxf)) # g('set log y') g.splot(Gnuplot.GridData(data,time,freq, binary=1, title='')) else: # plot waveform and onsets time,data = audio_to_array(self.input) wplot = [make_audio_plot(time,data)] + wplot g('set origin 0,%f' % (0.7*ysize) ) g('set size %f,%f' % (xsize,0.3*ysize)) g('set format y "%1f"') g('set xrange [0:%f]' % max(time)) g('set yrange [-1:1]') g('set noytics') g('set y2tics -1,1') g.xlabel('time (s)',offset=(0,0.7)) g.ylabel('amplitude') g.plot(*wplot) # default settings for next plots g('unset title') g('set format x ""') g('set format y "%3e"') g('set tmargin 0') g.xlabel('') N = len(oplots) y = 0.7*ysize # the vertical proportion of the plot taken by onset functions delta = 0.035 # the constant part of y taken by last plot label and data for i in range(N): # plot onset detection functions g('set size %f,%f' % ( xsize, (y-delta)/N)) g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta )) g('set nokey') g('set xrange [0:%f]' % (self.lenofunc*self.params.step)) g('set yrange [0:%f]' % (1.1*oplots[i][2])) g('set y2tics ("0" 0, "%d" %d)' % (round(oplots[i][2]),round(oplots[i][2]))) g.ylabel(oplots[i][1]) if i == N-1: g('set size %f,%f' % ( xsize, (y-delta)/N + delta ) ) g('set origin 0,0') g.xlabel('time (s)', offset=(0,0.7)) g('set format x') g.plot(*oplots[i][0]) g('unset multiplot')
def plotplot(self,wplot,oplots,titles,outplot=None,extension=None,xsize=1.,ysize=1.,multiplot = 1, midi = 1, truth = 1): from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot import re import Gnuplot # check if ground truth exists if truth: timet,pitcht = self.gettruth() if timet and pitcht: oplots = [Gnuplot.Data(timet,pitcht,with='lines', title='ground truth')] + oplots g = gnuplot_create(outplot=outplot, extension=extension) g('set title \'%s\'' % (re.sub('.*/','',self.input))) g('set size %f,%f' % (xsize,ysize) ) g('set multiplot') # hack to align left axis g('set lmargin 4') g('set rmargin 4') # plot waveform time,data = audio_to_array(self.input) wplot = [make_audio_plot(time,data)] g('set origin 0,%f' % (0.7*ysize) ) g('set size %f,%f' % (xsize,0.3*ysize)) #g('set format y "%1f"') g('set xrange [0:%f]' % max(time)) g('set yrange [-1:1]') g('set noytics') g('set y2tics -1,1') g.xlabel('time (s)',offset=(0,0.7)) g.ylabel('amplitude') g.plot(*wplot) # default settings for next plots g('unset title') g('set format x ""') g('set format y "%3e"') g('set tmargin 0') g.xlabel('') g('set noclip one') if not midi: g('set log y') #g.xlabel('time (s)') g.ylabel('f0 (Hz)') g('set yrange [100:%f]' % self.params.pitchmax) else: g.ylabel('midi') g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax))) g('set y2tics %f,%f' % (round(aubio_freqtomidi(self.params.pitchmin)+.5),12)) if multiplot: N = len(oplots) y = 0.7*ysize # the vertical proportion of the plot taken by onset functions delta = 0.035 # the constant part of y taken by last plot label and data for i in range(N): # plot pitch detection functions g('set size %f,%f' % ( xsize, (y-delta)/N)) g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta )) g('set nokey') g('set xrange [0:%f]' % max(time)) g.ylabel(titles[i]) if i == N-1: g('set size %f,%f' % (xsize, (y-delta)/N + delta ) ) g('set origin 0,0') g.xlabel('time (s)', offset=(0,0.7)) g('set format x') g.plot(oplots[i]) else: g('set key right top') g.plot(*oplots) g('unset multiplot')