annotate 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
rev   line source
samer@0 1 % amelspec - arrow from audio to log mel spectra
samer@0 2 %
samer@0 3 % amelspec ::
samer@0 4 % N:natural ~'size of FFT used to compute spectra',
samer@0 5 % M:natural ~'number of mel bands to compute'
samer@0 6 % nonneg ~'sampling frequency',
samer@0 7 % options {
samer@0 8 % windowfn :: N:natural->[[N]] / @hanning ~'window function';
samer@0 9 % lowf :: nonneg / 100 ~'filter bank low frequency in Hz'
samer@0 10 % }
samer@0 11 % -> arrow( {[[dftbins(N)]]}, {[[L]]}, empty).
samer@0 12 %
samer@0 13 % Uses antialiased triangular filterbank from lowf to fs/2.
samer@0 14
samer@0 15 function o=amelspec(N,M,fs,varargin)
samer@37 16 opts=options('windowfn',@hanning,'lowf',100,'floor',5e-9,varargin{:});
samer@0 17 melW = lin2mel(N,fs,[opts.lowf,fs/2],M);
samer@0 18 noise_floor=opts.floor;
samer@0 19 o = apowspec(opts.windowfn(N))*arr(@cc);
samer@0 20 function y=cc(x), y=log(melW*x+noise_floor); end
samer@0 21 end