From: Paul Brossier Date: Wed, 2 Aug 2006 11:21:46 +0000 (+0000) Subject: add buffer and hosize options to aubioplot-spec, use 10000 as default value for maxf X-Git-Tag: bzr2git~578 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e638bcfa611dd8138229acd63793e6edd285fc01;p=aubio.git add buffer and hosize options to aubioplot-spec, use 10000 as default value for maxf add buffer and hosize options to aubioplot-spec, use 10000 as default value for maxf --- diff --git a/python/aubio/gnuplot.py b/python/aubio/gnuplot.py index a48f75bf..3e508865 100644 --- a/python/aubio/gnuplot.py +++ b/python/aubio/gnuplot.py @@ -72,11 +72,10 @@ def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None,xsize=1., xorig += xsize*xratio g.gnuplot('unset multiplot;') -def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = -20.): +def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = -20., + bufsize= 8192, hopsize = 1024): from aubioclass import fvec,cvec,pvoc,sndfile from math import log10 - bufsize = 8192 - hopsize = bufsize/8 # could depend on filelength filei = sndfile(filename) srate = float(filei.samplerate()) framestep = hopsize/srate @@ -117,10 +116,10 @@ def audio_to_spec(filename,minf = 0, maxf = 0, lowthres = -20.): assert len(data[0]) == len(freq) return data,time,freq -def plot_spec(filename, outplot='',extension='', fileout=None, start=0, end=None, noaxis=None,log=1, minf=0, maxf= 0, xsize = 1., ysize = 1.): +def plot_spec(filename, outplot='',extension='', fileout=None, start=0, end=None, noaxis=None,log=1, minf=0, maxf= 0, xsize = 1., ysize = 1.,bufsize=8192, hopsize=1024): import Gnuplot g = gnuplot_create(outplot,extension) - data,time,freq = audio_to_spec(filename,minf=minf,maxf=maxf) + data,time,freq = audio_to_spec(filename,minf=minf,maxf=maxf,bufsize=bufsize,hopsize=hopsize) xorig = 0. if not noaxis: g.xlabel('Time (s)') diff --git a/python/aubioplot-spec b/python/aubioplot-spec index fe5ab531..c0bef89d 100755 --- a/python/aubioplot-spec +++ b/python/aubioplot-spec @@ -16,7 +16,7 @@ def parse_args(): action="store", dest="filename", help="input sound file") parser.add_option("-M","--maxf", - action="store", dest="maxf", default=0., + action="store", dest="maxf", default=10000., type='float',help="higher frequency limit") parser.add_option("-L","--minf", action="store", dest="minf", default=0., @@ -33,6 +33,12 @@ def parse_args(): parser.add_option("-O","--outplot", action="store", dest="outplot", default=None, help="save plot to output.{ps,png}") + parser.add_option("-B","--bufsize", type='int', + action="store", dest="bufsize", default=8192, + help="buffer size [default=8192]") + parser.add_option("-H","--hopsize", type='int', + action="store", dest="hopsize", default=1024, + help="overlap size [default=1024]") (options, args) = parser.parse_args() if not options.filename: print "no file name given\n", usage @@ -51,4 +57,5 @@ else: plot_spec(filename, outplot=outplot, extension=extension, log=options.log, maxf = options.maxf, minf = options.minf, - xsize = options.xsize, ysize = options.ysize) + xsize = options.xsize, ysize = options.ysize, + bufsize = options.bufsize, hopsize = options.hopsize)