Mercurial > hg > ishara
diff dsp/formants.m @ 32:c3b0cd708782
Imported core dsp tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 13:48:47 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dsp/formants.m Sun Jan 20 13:48:47 2013 +0000 @@ -0,0 +1,18 @@ +% formants - Compute formants from LPC coefficients +function F=formants(a,M,fs) + +const=fs/(2*pi); +if all(isfinite(a)) + rts=roots(a); + + fx = const*angle(rts); + bw = -2*const*log(abs(rts)); + + F = log(sort(fx(fx>90 & fx<4000 & bw<700))); + N = length(F); + if N<M, F=[F;nan(M-N,1)]; + else F=F(1:M); end +else + F=nan(M,1); +end +% only first 3?