Showing the changes to python/test (2 of 2 files). Show all
Unified · Split
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | import sys,time | 7 | import sys,time |
| 8 | from aubio.task import taskbeat,taskparams | 8 | from aubio.task import taskbeat,taskparams |
| 9 | from aubio.aubioclass import fvec, aubio_autocorr | 9 | from aubio.aubioclass import fvec, aubio_autocorr |
| 10 | from aubio.gnuplot import gnuplot_create | 10 | from aubio.gnuplot import gnuplot_create, gnuplot_addargs |
| 11 | from aubio.aubiowrapper import * | 11 | from aubio.aubiowrapper import * |
| 12 | from math import exp,log | 12 | from math import exp,log |
| 13 | 13 | ||
| @@ -22,15 +22,7 @@ def parse_args(): · 8 unmodified lines | |||
| 22 | parser.add_option("-n","--printframe", | 22 | parser.add_option("-n","--printframe", |
| 23 | action="store", dest="printframe", default=-1, | 23 | action="store", dest="printframe", default=-1, |
| 24 | help="make a plot of the n_th frame") | 24 | help="make a plot of the n_th frame") |
| 25 | parser.add_option("-x","--xsize", | 25 | gnuplot_addargs(parser) |
| 26 | action="store", dest="xsize", default=1., | ||
| 27 | type='float', help="define xsize for plot") | ||
| 28 | parser.add_option("-y","--ysize", | ||
| 29 | action="store", dest="ysize", default=1., | ||
| 30 | type='float', help="define ysize for plot") | ||
| 31 | parser.add_option("-O","--outplot", | ||
| 32 | action="store", dest="outplot", default=None, | ||
| 33 | help="save plot to output.{ps,png}") | ||
| 34 | (options, args) = parser.parse_args() | 26 | (options, args) = parser.parse_args() |
| 35 | if not options.filename: | 27 | if not options.filename: |
| 36 | print "no file name given\n", usage | 28 | print "no file name given\n", usage |
| @@ -54,7 +46,7 @@ if options.outplot and printframe > 0: · 17 unmodified lines | |||
| 54 | else: | 46 | else: |
| 55 | extension = '' | 47 | extension = '' |
| 56 | outplot = None | 48 | outplot = None |
| 57 | f = gnuplot_create(outplot=outplot,extension=extension) | 49 | f = gnuplot_create(outplot=outplot,extension=extension,options=options) |
| 58 | 50 | ||
| 59 | params = taskparams() | 51 | params = taskparams() |
| 60 | params.onsetmode = 'specdiff' | 52 | params.onsetmode = 'specdiff' |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | import sys,time | 7 | import sys,time |
| 8 | from aubio.task import taskbeat,taskparams | 8 | from aubio.task import taskbeat,taskparams |
| 9 | from aubio.aubioclass import fvec, aubio_autocorr | 9 | from aubio.aubioclass import fvec, aubio_autocorr |
| 10 | from aubio.gnuplot import gnuplot_create | 10 | from aubio.gnuplot import gnuplot_create, gnuplot_addargs |
| 11 | from aubio.aubiowrapper import * | 11 | from aubio.aubiowrapper import * |
| 12 | from math import exp,log | 12 | from math import exp,log |
| 13 | 13 | ||
| @@ -22,15 +22,7 @@ def parse_args(): · 8 unmodified lines | |||
| 22 | parser.add_option("-n","--printframe", | 22 | parser.add_option("-n","--printframe", |
| 23 | action="store", dest="printframe", default=-1, | 23 | action="store", dest="printframe", default=-1, |
| 24 | help="make a plot of the n_th frame") | 24 | help="make a plot of the n_th frame") |
| 25 | parser.add_option("-x","--xsize", | 25 | gnuplot_addargs(parser) |
| 26 | action="store", dest="xsize", default=1., | ||
| 27 | type='float', help="define xsize for plot") | ||
| 28 | parser.add_option("-y","--ysize", | ||
| 29 | action="store", dest="ysize", default=1., | ||
| 30 | type='float', help="define ysize for plot") | ||
| 31 | parser.add_option("-O","--outplot", | ||
| 32 | action="store", dest="outplot", default=None, | ||
| 33 | help="save plot to output.{ps,png}") | ||
| 34 | (options, args) = parser.parse_args() | 26 | (options, args) = parser.parse_args() |
| 35 | if not options.filename: | 27 | if not options.filename: |
| 36 | print "no file name given\n", usage | 28 | print "no file name given\n", usage |
| @@ -54,7 +46,7 @@ if options.outplot and printframe > 0: · 17 unmodified lines | |||
| 54 | else: | 46 | else: |
| 55 | extension = '' | 47 | extension = '' |
| 56 | outplot = None | 48 | outplot = None |
| 57 | f = gnuplot_create(outplot=outplot,extension=extension) | 49 | f = gnuplot_create(outplot,extension,options) |
| 58 | 50 | ||
| 59 | params = taskparams() | 51 | params = taskparams() |
| 60 | params.onsetmode = 'specdiff' | 52 | params.onsetmode = 'specdiff' |
| @@ -107,13 +99,6 @@ rwv = [(i+1.)/rayparam**2 * exp(-(i+1.)**2 / (2.*rayparam)**2) · 46 unmodified lines | |||
| 107 | for i in range(0,laglen)] | 99 | for i in range(0,laglen)] |
| 108 | acf = fvec(winlen,1) | 100 | acf = fvec(winlen,1) |
| 109 | 101 | ||
| 110 | if options.outplot and printframe > 0: | ||
| 111 | extension = options.outplot.split('.')[-1] | ||
| 112 | outplot = '.'.join(options.outplot.split('.')[:-1]) | ||
| 113 | else: | ||
| 114 | extension = '' | ||
| 115 | outplot = None | ||
| 116 | f = gnuplot_create(outplot=outplot,extension=extension) | ||
| 117 | nrframe = 0 | 102 | nrframe = 0 |
| 118 | while (task.readsize == params.hopsize): | 103 | while (task.readsize == params.hopsize): |
| 119 | task() | 104 | task() |
| @@ -149,12 +134,14 @@ while (task.readsize == params.hopsize): · 29 unmodified lines | |||
| 149 | f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) | 134 | f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) |
| 150 | f('set orig %f,%f' % (0.0*xsize,0.66*ysize) ) | 135 | f('set orig %f,%f' % (0.0*xsize,0.66*ysize) ) |
| 151 | f('set xrange [%f:%f]' % (0,btstep*hopsize) ) | 136 | f('set xrange [%f:%f]' % (0,btstep*hopsize) ) |
| 137 | f('set yrange [%f:%f]' % (-1.2*max(sig),1.2*max(sig)) ) | ||
| 152 | f.title('Input signal') | 138 | f.title('Input signal') |
| 153 | f.xlabel('time (samples)') | 139 | f.xlabel('time (samples)') |
| 154 | f.plot(*d[0]) | 140 | f.plot(*d[0]) |
| 155 | f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) | 141 | f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) |
| 156 | f('set orig %f,%f' % (0.0*xsize,0.33*ysize) ) | 142 | f('set orig %f,%f' % (0.0*xsize,0.33*ysize) ) |
| 157 | f('set xrange [%f:%f]' % (-winlen,0) ) | 143 | f('set xrange [%f:%f]' % (-winlen,0) ) |
| 144 | f('set autoscale y') | ||
| 158 | f.title('Onset detection function') | 145 | f.title('Onset detection function') |
| 159 | f.xlabel('time (df samples)') | 146 | f.xlabel('time (df samples)') |
| 160 | f.plot(*d[1]) | 147 | f.plot(*d[1]) |