ref: 55ed67a6dbdddc1a12912db6aac3534be698e25f
parent: 707c30e7249c82887fdbf83f6a3add5bc927a60f
author: Paul Brossier <piem@piem.org>
date: Fri Sep 25 21:40:44 EDT 2009
python/aubio/gnuplot.py: use numpy, not numarray (debian #478438)
--- a/python/aubio/gnuplot.py
+++ b/python/aubio/gnuplot.py
@@ -23,7 +23,7 @@
def audio_to_array(filename):
import aubio.aubioclass
- import numarray
+ from numpy import arange
hopsize = 2048
filei = aubio.aubioclass.sndfile(filename)
framestep = 1/(filei.samplerate()+0.)
@@ -39,7 +39,7 @@
while (curpos < readsize):
data.append(myvec.get(curpos,i))
curpos+=1
- time = numarray.arange(len(data))*framestep
+ time = arange(len(data))*framestep
return time,data
def plot_audio(filenames, g, options):
@@ -143,12 +143,12 @@
def downsample_audio(time,data,maxpoints=10000):
""" resample audio data to last only maxpoints """
- import numarray
+ from numpy import array, resize
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]
+ x = resize(array(time),length)[0:-1:downsample]
+ y = resize(array(data),length)[0:-1:downsample]
return x,y
def make_audio_plot(time,data,maxpoints=10000):
@@ -155,17 +155,17 @@
""" 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')
+ return Gnuplot.Data(x,y,with_='lines')
def make_audio_envelope(time,data,maxpoints=10000):
""" create gnuplot plot from an audio file """
- import numarray
+ from numpy import array
import Gnuplot, Gnuplot.funcutils
bufsize = 500
- x = [i.mean() for i in numarray.array(time).resize(len(time)/bufsize,bufsize)]
- y = [i.mean() for i in numarray.array(data).resize(len(time)/bufsize,bufsize)]
+ x = [i.mean() for i in resize(array(time), (len(time)/bufsize,bufsize))]
+ y = [i.mean() for i in resize(array(data), (len(time)/bufsize,bufsize))]
x,y = downsample_audio(x,y,maxpoints=maxpoints)
- return Gnuplot.Data(x,y,with='lines')
+ return Gnuplot.Data(x,y,with_='lines')
def gnuplot_addargs(parser):
""" add common gnuplot argument to OptParser object """