Changeset 55ed67a
- Timestamp:
- Sep 26, 2009, 1:40:44 AM (15 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 5f23f66
- Parents:
- 707c30e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/aubio/gnuplot.py
r707c30e r55ed67a 24 24 def audio_to_array(filename): 25 25 import aubio.aubioclass 26 import numarray 26 from numpy import arange 27 27 hopsize = 2048 28 28 filei = aubio.aubioclass.sndfile(filename) … … 40 40 data.append(myvec.get(curpos,i)) 41 41 curpos+=1 42 time = numarray.arange(len(data))*framestep42 time = arange(len(data))*framestep 43 43 return time,data 44 44 … … 144 144 def downsample_audio(time,data,maxpoints=10000): 145 145 """ resample audio data to last only maxpoints """ 146 import numarray146 from numpy import array, resize 147 147 length = len(time) 148 148 downsample = length/maxpoints 149 149 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] 152 152 return x,y 153 153 … … 156 156 import Gnuplot, Gnuplot.funcutils 157 157 x,y = downsample_audio(time,data,maxpoints=maxpoints) 158 return Gnuplot.Data(x,y,with ='lines')158 return Gnuplot.Data(x,y,with_='lines') 159 159 160 160 def make_audio_envelope(time,data,maxpoints=10000): 161 161 """ create gnuplot plot from an audio file """ 162 import numarray162 from numpy import array 163 163 import Gnuplot, Gnuplot.funcutils 164 164 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))] 167 167 x,y = downsample_audio(x,y,maxpoints=maxpoints) 168 return Gnuplot.Data(x,y,with ='lines')168 return Gnuplot.Data(x,y,with_='lines') 169 169 170 170 def gnuplot_addargs(parser):
Note: See TracChangeset
for help on using the changeset viewer.