view arrows/dsp/amelspec.m @ 6:0ce3c2070089

Removed duplicate code and fixed doc in timed_action.
author samer
date Mon, 14 Jan 2013 14:33:37 +0000
parents 672052bd81f8
children beb8a3f4a345
line wrap: on
line source
% amelspec - arrow from audio to log mel spectra
%
% amelspec :: 
%    N:natural      ~'size of FFT used to compute spectra',
%    M:natural      ~'number of mel bands to compute' 
%    nonneg         ~'sampling frequency',
%    options {
%       windowfn :: N:natural->[[N]] / @hanning ~'window function';
%       lowf     :: nonneg / 100                ~'filter bank low frequency in Hz'
%    }
% -> arrow( {[[dftbins(N)]]}, {[[L]]}, empty).
%
% Uses antialiased triangular filterbank from lowf to fs/2.

function o=amelspec(N,M,fs,varargin)
	opts=prefs('windowfn',@hanning,'lowf',100,'floor',5e-9,varargin{:});
	melW = lin2mel(N,fs,[opts.lowf,fs/2],M);
	noise_floor=opts.floor;
	o = apowspec(opts.windowfn(N))*arr(@cc);
	function y=cc(x), y=log(melW*x+noise_floor); end
end