view arrows/dsp/amelspec.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents beb8a3f4a345
children
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=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