matthiasm@8: function [s,f,t] = chunkspectrogram_ISMIR2010(filename,d_windo,d_nOverlap,d_nFFT, maxf) matthiasm@8: %% matthiasm@8: % d_ are the downsampled things matthiasm@8: % o_ are the original things matthiasm@8: matthiasm@8: matthiasm@8: d_fs = 11025; matthiasm@8: matthiasm@8: [filesize, o_fs] = wavread(filename,'size'); matthiasm@8: matthiasm@8: matthiasm@8: matthiasm@8: if mod(o_fs/d_fs,1) ~= 0 matthiasm@8: error('The sample frequency of the wave file has to be an integer multiple of %1.0f.',d_fs); matthiasm@8: end matthiasm@8: downsample = o_fs/d_fs; matthiasm@8: matthiasm@8: o_windo = d_windo * downsample; matthiasm@8: o_nOverlap = d_nOverlap * downsample; matthiasm@8: o_hopSize = o_windo-o_nOverlap; matthiasm@8: nFrame = floor((filesize(1) - o_windo) / o_hopSize); matthiasm@8: matthiasm@8: s = zeros(d_nFFT/2, nFrame); matthiasm@8: f = (0:d_nFFT/2-1)/d_fs; matthiasm@8: t = zeros(nFrame,1); matthiasm@8: matthiasm@8: wind = hamming(d_windo); matthiasm@8: wind = wind/sum(wind); matthiasm@8: matthiasm@8: for iLine = 1:round(nFrame/200) matthiasm@8: fprintf(1,'_'); matthiasm@8: end matthiasm@8: fprintf(1,'\n'); matthiasm@8: matthiasm@8: for iFrame = 1:nFrame matthiasm@8: if mod(iFrame,200) == 0 matthiasm@8: fprintf(1,'.'); matthiasm@8: end matthiasm@8: ind = [1,o_windo] + (iFrame-1) * (o_hopSize); matthiasm@8: wave = sum(wavread(filename, ind),2) / 2; matthiasm@8: temp = fft(resample(wave,d_fs,o_fs) .* wind); matthiasm@8: s(:, iFrame) = temp(1:d_nFFT/2); matthiasm@8: t(iFrame) = (ind(1) + ind(2)) / 2 / o_fs; matthiasm@8: end matthiasm@8: fprintf(1,'\n');