-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathitLegendreSynth.m
More file actions
69 lines (56 loc) · 1.45 KB
/
Copy pathitLegendreSynth.m
File metadata and controls
69 lines (56 loc) · 1.45 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function y = itLegendreSynth(c, npoints)
% function y = itLegendreSynth(c, npoints)
%
% Synthetize the contour from vector of Legendre polynomials 'c' in 'npoints' equidistant points.
% Returns row vector of values of synthetized contour.
%
% c ... Row vector of Legendre polynomials coefficients
% npoints ... [optional] Number of points of PitchTier interpolation (default: 1000)
%
% v1.0, Tomas Boril, borilt@gmail.com
%
% Example
% it = itRead('demo/maminka.IntensityTier');
% it = itCut(it, 0.2, 0.4); % cut IntensityTier and preserve time
% c = itLegendre(it)
% leg = itLegendreSynth(c);
% itLeg = it;
% itLeg.t = linspace(itLeg.tmin, itLeg.tmax, length(leg));
% itLeg.i = leg;
% plot(it.t, it.i, 'ko')
% xlabel('Time (sec)'); ylabel('Intensity (dB)')
% hold on; plot(itLeg.t, itLeg.i, 'b')
if nargin < 1 || nargin > 2
error('Wrong number of arguments.')
end
if nargin == 1
npoints = 1000;
end
if ~isInt(npoints) || npoints < 0
error('npoints must be integer >= 0.')
end
if size(c, 1) ~= 1
error('c must be a row vector.');
end
lP = npoints; % poèet vzorkù polynomu
nP = length(c);
B = zeros(nP, lP); % báze
if (lP == 1)
x = -1;
else
x = linspace(-1, 1, lP);
end
for I = 1: nP
n = I - 1;
p = zeros(1, lP);
for k = 0: n
p = p + x.^k*binomcoeff2(n, k)*binomcoeff2((n+k-1)/2, n);
end
p = p*2.^n;
B(I, :) = p;
end
if nP > 0
y = c * B;
else
y = NaN*ones(1, npoints);
end