History

merge aubionotes and aubionotesmedian add make_audio_plot to gnuplot.py adds autocorrelation to mathutils adds Makefile.in to junk files

Paul Brossier committed 21 years ago

Commit a0fd4e41 parent e50b6957 files · +111 −348Browse files

Showing the changes to python (1 of 7 files). Show all

Unified · Split

python/aubio/gnuplot.py+11−8
@@ -108,15 +108,10 @@ def audio_to_array(filename): · 107 unmodified lines
108108 while (curpos < readsize):
109109 data.append(myvec.get(curpos,i))
110110 curpos+=1
111− # FIXME again for the last frame
112− curpos = 0
113− while (curpos < readsize):
114− data.append(myvec.get(curpos,i))
115− curpos+=1
116111 time = arange(len(data))*framestep
117112 return time,data
118113
119−def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None, task=audio_to_array):
114+def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None):
120115 g = Gnuplot.Gnuplot(debug=1, persist=1)
121116 d = []
122117 todraw = len(filenames)
@@ -124,8 +119,7 @@ def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None, task=aud · 1 unmodified line
124119 xsize = 1./todraw
125120 g.gnuplot('set multiplot;')
126121 while (len(filenames)):
127− b,a = task(filenames.pop(0))
128− d.append(Gnuplot.Data(b,a))
122+ d.append(plot_audio_make(filenames.pop(0)))
129123 if not noaxis and todraw==1:
130124 g.xlabel('Time (s)')
131125 g.ylabel('Amplitude')
@@ -140,3 +134,12 @@ def plot_audio(filenames, fileout=None, start=0, end=None, noaxis=None, task=aud · 8 unmodified lines
140134 if fileout != None:
141135 g.hardcopy(fileout, enhanced=1, color=0)
142136
137+def make_audio_plot(time,data,maxpoints=10000):
138+ """ create gnuplot plot from an audio file """
139+ import numarray
140+ length = len(time)
141+ downsample = length/maxpoints
142+ if downsample == 0: downsample = 1
143+ x = numarray.array(time).resize(length)[0:-1:downsample]
144+ y = numarray.array(data).resize(length)[0:-1:downsample]
145+ return Gnuplot.Data(x,y,with='lines')

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