add buffer and hosize options to aubioplot-spec, use 10000 as default value for maxf
authorPaul Brossier <piem@altern.org>
Wed, 2 Aug 2006 11:21:46 +0000 (11:21 +0000)
committerPaul Brossier <piem@altern.org>
Wed, 2 Aug 2006 11:21:46 +0000 (11:21 +0000)
add buffer and hosize options to aubioplot-spec, use 10000 as default value for maxf

python/aubio/gnuplot.py
python/aubioplot-spec

index a48f75bf392d63b26960839ed31ec7b96e464b98..3e508865cf694395f0652b17e3d6dbff0f184522 100644 (file)
@@ -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)')
index fe5ab531a85cbdcf9cffcac9ca167196eb33694b..c0bef89d02d205c521efa4593d997181a77e08c4 100755 (executable)
@@ -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)