From: Paul Brossier Date: Wed, 2 Aug 2006 14:55:29 +0000 (+0000) Subject: reuse downsample_audio in make_audio_plot X-Git-Tag: bzr2git~572 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=32fa8e816aaf24cce0c79dd1cab463fbbf0b9e26;p=aubio.git reuse downsample_audio in make_audio_plot reuse downsample_audio in make_audio_plot --- diff --git a/python/aubio/gnuplot.py b/python/aubio/gnuplot.py index 29f2edd9..c1e7307d 100644 --- a/python/aubio/gnuplot.py +++ b/python/aubio/gnuplot.py @@ -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