-
Notifications
You must be signed in to change notification settings - Fork 2
/
lpc2spec.m
39 lines (31 loc) · 910 Bytes
/
lpc2spec.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
function [features,F,M] = lpc2spec(lpcas, nbands)
% [features,F,M] = lpc2spec(lpcas,nbands)
% Convert LPC coeffs back into spectra
% nbands is number of freq channels, default 17 (i.e. for 8 kHz)
if nargin < 2
nbands = 17;
end
[rows, cols] = size(lpcas);
order = rows - 1;
gg = lpcas(1,:);
aa = lpcas./repmat(gg,rows,1);
% Calculate the actual z-plane polyvals: nbands points around unit circle
zz = exp((-j*[0:(nbands-1)]'*pi/(nbands-1))*[0:order]);
% Actual polyvals, in power (mag^2)
features = ((1./abs(zz*aa)).^2)./repmat(gg,nbands,1);
F = zeros(cols, floor(rows/2));
M = F;
for c = 1:cols;
aaa = aa(:,c);
rr = roots(aaa');
ff = angle(rr');
% size(ff)
% size(aaa)
zz = exp(j*ff'*[0:(length(aaa)-1)]);
mags = sqrt(((1./abs(zz*aaa)).^2)/gg(c))';
[dummy, ix] = sort(ff);
keep = ff(ix) > 0;
ix = ix(keep);
F(c,1:length(ix)) = ff(ix);
M(c,1:length(ix)) = mags(ix);
end