Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -147,25 +147,20 @@ def plot_spec(filename, g, start=0, end=None, noaxis=None,log=1, minf=0, maxf= 0 · 146 unmodified lines | |||
| 147 | #xorig += 1./todraw | 147 | #xorig += 1./todraw |
| 148 | 148 | ||
| 149 | def downsample_audio(time,data,maxpoints=10000): | 149 | def downsample_audio(time,data,maxpoints=10000): |
| 150 | """ resample audio data to last only maxpoints """ | 150 | """ resample audio data to last only maxpoints """ |
| 151 | import numarray | 151 | import numarray |
| 152 | length = len(time) | 152 | length = len(time) |
| 153 | downsample = length/maxpoints | 153 | downsample = length/maxpoints |
| 154 | if downsample == 0: downsample = 1 | 154 | if downsample == 0: downsample = 1 |
| 155 | x = numarray.array(time).resize(length)[0:-1:downsample] | 155 | x = numarray.array(time).resize(length)[0:-1:downsample] |
| 156 | y = numarray.array(data).resize(length)[0:-1:downsample] | 156 | y = numarray.array(data).resize(length)[0:-1:downsample] |
| 157 | return x,y | 157 | return x,y |
| 158 | 158 | ||
| 159 | def make_audio_plot(time,data,maxpoints=10000): | 159 | def make_audio_plot(time,data,maxpoints=10000): |
| 160 | """ create gnuplot plot from an audio file """ | 160 | """ create gnuplot plot from an audio file """ |
| 161 | import numarray | 161 | import Gnuplot, Gnuplot.funcutils |
| 162 | import Gnuplot, Gnuplot.funcutils | 162 | x,y = downsample_audio(time,data,maxpoints=maxpoints) |
| 163 | length = len(time) | 163 | return Gnuplot.Data(x,y,with='lines') |
| 164 | downsample = length/maxpoints | ||
| 165 | if downsample == 0: downsample = 1 | ||
| 166 | x = numarray.array(time).resize(length)[0:-1:downsample] | ||
| 167 | y = numarray.array(data).resize(length)[0:-1:downsample] | ||
| 168 | return Gnuplot.Data(x,y,with='lines') | ||
| 169 | 164 | ||
| 170 | def gnuplot_create(outplot='',extension='',debug=0,persist=1, xsize=1., ysize=1.): | 165 | def gnuplot_create(outplot='',extension='',debug=0,persist=1, xsize=1., ysize=1.): |
| 171 | import Gnuplot | 166 | import Gnuplot |