Oh, and yes, octave is astonishingly slow, even when you only do the histogram stuff. In fact, the SFM stuff adds surprisingly little to the run time, which is bizzare.
Even without bounds checking it's slow, slow, slow. No idea why.
Matlab is quite a bit faster, but I don't have it here.
Seems that array creation is main break here. I tried to speed up histogram and this code:
def histo(fn):
import scikits.audiolab as au
(sp, sf, b) = au.wavread(fn)
sp = sp.transpose()
his=zeros((65536,), dtype=numpy.int)
for i in range(len(sp[0])):
his[int(sp[0, i] * 32768) + 32768] += 1
his[int(sp[1, i] * 32768) + 32768] += 1
his = maximum(his / float(sum(his)), 10e-12)
x = arange(-32768, 32768)
semilogy(x, his)
is ~15 times faster then Octave or ~3 times faster then previously posted.
This is bare bone NumPy - simple numpy array processing, so other then Python and NumPy nothing more is required (except SciPy or audiolab for reading WAV data; edit: and matplotlib for graphs).
MKL build isn't noticeable here, as there are no linalg functions. However this can of course further be optimized by various approaches, i.e.: http://www.scipy.org/PerformancePython Example here is totally different, (scheme on grid and testing it convergence) but provides examples how NumPy/SciPy can be dissected further. I just thought to link to that, as I'm not aware how many users here are familiar with this Python approach for numerical problems
I'm wondering also about Matlab performance. My main PC PSU went down and I can't test Matlab 2009b these days. Can someone compare performance between Octave and Matlab, just for histogram code:
fname='some.wav';
x=wavread(fname);
x=x';
len=length(x)
his(1:65536)=0;
for ii=1:len
for jj=1:2
t=x(jj,ii);
t=round(t*32768+32769);
his(t)=his(t)+1;
end
end