I'm currently implementing a beat detection algorithm with python and numpy/scipy. I basically need to read a .wav file and process it. Here is the code:
sampling_rate, wave_data = scipy.io.wavfile.read(argv[1])
wave_data is a 1-D numpy array with about 441 000 elements (10 seconds of sound with 44.1 kHz sampling rate). Now, I need to do some basic math on every two elements in this array. This is how I do it now:
wave_data = [sampling_rate * (wave_data[i+1] - wave_data[i])
for i in xrange(len(wave_data)-1)]
This opreation takes too much time (noticeable without profiling). I need to map the array pairwise "in-place", without creating a new python list. I know there is numpy.vectorize, but I don't know how can I do the mapping pairwise (map every two elements of the array).