views:

44

answers:

2

I have this,

f = audiolab.Sndfile('test.wav', 'r')
data = f.read_frames(f.nframes, dtype=numpy.int16)

pyplot.rcParams['figure.figsize'] = 10, 2
pyplot.plot(data)
pyplot.xticks([])
pyplot.yticks([])
pyplot.show()

but the ploting is slow and freeze the pc, hoy I can reduce the numbers of points or how can I increase the performance of the code?

A: 

Use something like NumPy to resample the data to a lower frequency before adding it to the plot.

Ignacio Vazquez-Abrams
A: 

You could take (roughly) 1000 evenly spaced points from your data this way:

n = len(data)
pyplot.plot(data[::n/1000])
unutbu
thanks, good idea
Alquimista