-
Notifications
You must be signed in to change notification settings - Fork 1
/
invaudspec.m
43 lines (37 loc) · 1.25 KB
/
invaudspec.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function [spec,wts,iwts] = invaudspec(aspectrum, sr, nfft, fbtype, minfreq, maxfreq, sumpower, bwidth)
%pspectrum = invaudspec(aspectrum, sr, nfft, fbtype, minfreq, maxfreq, sumpower, bwidth)
%
% Invert (as best we can) the effects of audspec()
%
% 2004-02-04 [email protected]
if nargin < 2; sr = 16000; end
if nargin < 3; nfft = 512; end
if nargin < 4; fbtype = 'bark'; end
if nargin < 5; minfreq = 0; end
if nargin < 6; maxfreq = sr/2; end
if nargin < 7; sumpower = 1; end
if nargin < 8; bwidth = 1.0; end
[nfilts,nframes] = size(aspectrum);
if strcmp(fbtype, 'bark')
wts = fft2barkmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq);
elseif strcmp(fbtype, 'mel')
wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq);
elseif strcmp(fbtype, 'htkmel')
wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq, 1, 1);
elseif strcmp(fbtype, 'fcmel')
wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq, 1);
else
disp(['fbtype ', fbtype, ' not recognized']);
error;
end
% Cut off 2nd half
wts = wts(:,1:((nfft/2)+1));
% Just transpose, fix up
ww = wts'*wts;
iwts = wts'./(repmat(max(mean(diag(ww))/100, sum(ww))',1,nfilts));
% Apply weights
if (sumpower)
spec = iwts * aspectrum;
else
spec = (iwts * sqrt(aspectrum)).^2;
end