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
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)')
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.,
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
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)