-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathboundmes2.m
80 lines (38 loc) · 933 Bytes
/
boundmes2.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
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
69
70
71
72
73
74
75
76
77
78
79
function bv=boundmes2(apv,dpv,fs,shiftm,intshiftm,mm)
% boundary calculation for MBE model
% bv=boundmes2(apv,dpv,fs,shiftm,intshiftm,mm);
% apv : peak envelope
% dpv : dip envelope
% fs : sampling frequency (Hz)
% shiftm : frame shift of F0 data
% intshiftm : frame shift for envelope data
% mm : number of elements in frequency axis
% 01/Sept./1999
% by Hideki Kawahara
lx=log10((1:mm-1)/(mm-1)/2*fs);
fx=(1:mm-1)/(mm-1)/2*fs;
wwv=10.0.^(apv/20);
lyv=((dpv-apv)/20);
[ll,kk]=size(apv);
bv=zeros(1,kk);
for ii=1:kk
bv(ii)=sum((lyv(2:mm,ii)'-lx).*wwv(2:mm,ii)'./fx)/sum(wwv(2:mm,ii)./fx');
end;
% Assuming shiftm >= 1 ms
if ne(round(shiftm),shiftm)
bv=[];
return;
end;
if ne(round(intshiftm),intshiftm)
bv=[];
return;
end;
if shiftm==intshiftm
return;
end;
if intshiftm>1
bv=interp(bv,intshiftm);
if shiftm>1
bv=bv(1:shiftm:length(bv));
end;
end;