view dsp/mk_mfcc.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents c3b0cd708782
children
line wrap: on
line source
% mk_mfcc - Function factory, makes MFCC functions
%
% mk_mfcc :: 
%    I:[[M]->[N]]  ~'selects which rows of DCT to compute',
%    N:natural     ~'size of input', 
%    nonneg        ~'sampling rate'
% -> ([[N]]->[[M]]).

function f = mk_mfcc(M,N,fs)
	Nfft = 2^nextpow2(N+1);
	Nspec= dftbins(Nfft);

	wndw = spdiag(hamming(N,'periodic'));
	melW = tri_filterbank(melspace(400/3,min(7000,fs/2),42),fs*(0:Nspec-1)/Nfft);
	dctW = row(dct(eye(size(melW,1))),M);
	f=@mfcc;

	function y=mfcc(x)
		ft = fft(wndw*x,Nfft);
		y  = dctW*log(melW*abs(ft(1:Nspec,:)).^2);
	end
end