History

python/aubio/gnuplot.py: use numpy, not numarray (debian #478438)

Paul Brossier committed 17 years ago

Commit 55ed67a1 parent 707c30e1 file · +10 −10Browse files

Showing the changes to python/aubio (1 of 1 file). Show all

Unified · Split

python/aubio/gnuplot.py+10−10
@@ -23,7 +23,7 @@ __LICENSE__ = """\ · 22 unmodified lines
2323
2424 def audio_to_array(filename):
2525 import aubio.aubioclass
26− import numarray
26+ from numpy import arange
2727 hopsize = 2048
2828 filei = aubio.aubioclass.sndfile(filename)
2929 framestep = 1/(filei.samplerate()+0.)
@@ -39,7 +39,7 @@ def audio_to_array(filename): · 9 unmodified lines
3939 while (curpos < readsize):
4040 data.append(myvec.get(curpos,i))
4141 curpos+=1
42− time = numarray.arange(len(data))*framestep
42+ time = arange(len(data))*framestep
4343 return time,data
4444
4545 def plot_audio(filenames, g, options):
@@ -143,29 +143,29 @@ def plot_spec(filename, g, options): · 97 unmodified lines
143143
144144 def downsample_audio(time,data,maxpoints=10000):
145145 """ resample audio data to last only maxpoints """
146− import numarray
146+ from numpy import array, resize
147147 length = len(time)
148148 downsample = length/maxpoints
149149 if downsample == 0: downsample = 1
150− x = numarray.array(time).resize(length)[0:-1:downsample]
151− y = numarray.array(data).resize(length)[0:-1:downsample]
150+ x = resize(array(time),length)[0:-1:downsample]
151+ y = resize(array(data),length)[0:-1:downsample]
152152 return x,y
153153
154154 def make_audio_plot(time,data,maxpoints=10000):
155155 """ create gnuplot plot from an audio file """
156156 import Gnuplot, Gnuplot.funcutils
157157 x,y = downsample_audio(time,data,maxpoints=maxpoints)
158− return Gnuplot.Data(x,y,with='lines')
158+ return Gnuplot.Data(x,y,with_='lines')
159159
160160 def make_audio_envelope(time,data,maxpoints=10000):
161161 """ create gnuplot plot from an audio file """
162− import numarray
162+ from numpy import array
163163 import Gnuplot, Gnuplot.funcutils
164164 bufsize = 500
165− x = [i.mean() for i in numarray.array(time).resize(len(time)/bufsize,bufsize)]
166− y = [i.mean() for i in numarray.array(data).resize(len(time)/bufsize,bufsize)]
165+ x = [i.mean() for i in resize(array(time), (len(time)/bufsize,bufsize))]
166+ y = [i.mean() for i in resize(array(data), (len(time)/bufsize,bufsize))]
167167 x,y = downsample_audio(x,y,maxpoints=maxpoints)
168− return Gnuplot.Data(x,y,with='lines')
168+ return Gnuplot.Data(x,y,with_='lines')
169169
170170 def gnuplot_addargs(parser):
171171 """ add common gnuplot argument to OptParser object """

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t