Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个,
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()
但是绘图很慢并且冻结了电脑,我可以减少点数或者如何提高代码的性能?
在将数据添加到绘图之前,使用 NumPy 之类的东西将数据重新采样到较低的频率。
您可以通过这种方式从数据中获取(大约)1000 个均匀分布的点:
n = len(data) pyplot.plot(data[::n/1000])