reuse downsample_audio in make_audio_plot
authorPaul Brossier <piem@altern.org>
Wed, 2 Aug 2006 14:55:29 +0000 (14:55 +0000)
committerPaul Brossier <piem@altern.org>
Wed, 2 Aug 2006 14:55:29 +0000 (14:55 +0000)
reuse downsample_audio in make_audio_plot

python/aubio/gnuplot.py

index 29f2edd950db3539a98a3f99920d21cb4a5eb79a..c1e7307d5af04033a37b0aacca3e5fdfd7d84fa5 100644 (file)
@@ -147,25 +147,20 @@ def plot_spec(filename, g, start=0, end=None, noaxis=None,log=1, minf=0, maxf= 0
        #xorig += 1./todraw
 
 def downsample_audio(time,data,maxpoints=10000):
-       """ resample audio data to last only maxpoints """
-       import numarray
-        length = len(time)
-       downsample = length/maxpoints
-        if downsample == 0: downsample = 1
-        x = numarray.array(time).resize(length)[0:-1:downsample]
-        y = numarray.array(data).resize(length)[0:-1:downsample]
-       return x,y
+  """ resample audio data to last only maxpoints """
+  import numarray
+  length = len(time)
+  downsample = length/maxpoints
+  if downsample == 0: downsample = 1
+  x = numarray.array(time).resize(length)[0:-1:downsample]
+  y = numarray.array(data).resize(length)[0:-1:downsample]
+  return x,y
 
 def make_audio_plot(time,data,maxpoints=10000):
-       """ create gnuplot plot from an audio file """
-       import numarray
-       import Gnuplot, Gnuplot.funcutils
-        length = len(time)
-       downsample = length/maxpoints
-        if downsample == 0: downsample = 1
-        x = numarray.array(time).resize(length)[0:-1:downsample]
-        y = numarray.array(data).resize(length)[0:-1:downsample]
-       return Gnuplot.Data(x,y,with='lines')
+  """ create gnuplot plot from an audio file """
+  import Gnuplot, Gnuplot.funcutils
+  x,y = downsample_audio(time,data,maxpoints=maxpoints)
+  return Gnuplot.Data(x,y,with='lines')
 
 def gnuplot_create(outplot='',extension='',debug=0,persist=1, xsize=1., ysize=1.):
        import Gnuplot