% 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=options('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
