function [s,f,t] = chunkspectrogram_ISMIR2010(filename,d_windo,d_nOverlap,d_nFFT, maxf)
%%
% d_ are the downsampled things
% o_ are the original things


d_fs = 11025;

[filesize, o_fs] = wavread(filename,'size');



if mod(o_fs/d_fs,1) ~= 0
    error('The sample frequency of the wave file has to be an integer multiple of %1.0f.',d_fs);
end
downsample = o_fs/d_fs;

o_windo = d_windo * downsample;
o_nOverlap = d_nOverlap * downsample;
o_hopSize = o_windo-o_nOverlap;
nFrame = floor((filesize(1) - o_windo) / o_hopSize);

s = zeros(d_nFFT/2, nFrame);
f = (0:d_nFFT/2-1)/d_fs;
t = zeros(nFrame,1);

wind = hamming(d_windo);
wind = wind/sum(wind);

for iLine = 1:round(nFrame/200)
    fprintf(1,'_');
end
fprintf(1,'\n');

for iFrame = 1:nFrame
    if mod(iFrame,200) == 0
        fprintf(1,'.');
    end
    ind = [1,o_windo] + (iFrame-1) * (o_hopSize);
    wave = sum(wavread(filename, ind),2) / 2;
    temp = fft(resample(wave,d_fs,o_fs) .* wind);
    s(:, iFrame) = temp(1:d_nFFT/2);
    t(iFrame) = (ind(1) + ind(2)) / 2 / o_fs;
end
fprintf(1,'\n');
