Question

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?

Was it helpful?

Solution

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

n = len(data)
pyplot.plot(data[::n/1000])

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top