Mercurial > hg > emotion-detection-top-level
comparison Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_buildMData.m @ 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
author | Dawn Black |
---|---|
date | Wed, 13 Feb 2013 11:02:39 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:e1cfa7765647 | 4:92ca03a8fa99 |
---|---|
1 function mdata = func_buildMData(matfile, smoothwin) | |
2 % mdata = func_buildMData(matfile, smoothwin) | |
3 % Input: mat filename | |
4 % smoothing window size (0 denotes no smoothing) | |
5 % Output: mat data structure | |
6 % Notes: Function tries to construct as many parameters as possible based | |
7 % on the parameters currently in the mat file. Some parameters will have a | |
8 % different variable name to what is originally stored in the mat file: | |
9 % e.g. H1 is actually the uncorrected harmonic (H1u), it is stored this way | |
10 % for compatability reasons. | |
11 % | |
12 % Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA | |
13 % Copyright UCLA SPAPL 2009 | |
14 | |
15 mdata = load(matfile); | |
16 | |
17 % these are for compatibility with VS0 matfiles | |
18 if (~isfield(mdata, 'HF0algorithm')) | |
19 mdata.HF0algorithm = 'F0 (Straight)'; | |
20 end | |
21 | |
22 if (~isfield(mdata, 'AFMTalgorithm')) | |
23 mdata.AFMTalgorithm = 'F1, F2, F3, F4 (Snack)'; | |
24 end | |
25 | |
26 if (~isfield(mdata, 'Fs')) | |
27 mdata.Fs = 16000; | |
28 end | |
29 | |
30 % get the right F0 | |
31 F0 = func_parseF0(mdata, mdata.HF0algorithm); | |
32 [F1, F2, F3] = func_parseFMT(mdata, mdata.AFMTalgorithm); | |
33 | |
34 % can't do much without F0 or FMTs | |
35 if (isempty(F0) || isempty(F1)) | |
36 return; | |
37 end | |
38 | |
39 % get bandwidth mapping | |
40 B1 = func_getBWfromFMT(F1, F0, 'hm'); | |
41 B2 = func_getBWfromFMT(F2, F0, 'hm'); | |
42 B3 = func_getBWfromFMT(F3, F0, 'hm'); | |
43 | |
44 % Hx | |
45 if (isfield(mdata, 'H1')) | |
46 mdata.H1u = mdata.H1; % H1 is actually the uncorrected harmonic | |
47 mdata.H1c = mdata.H1u - func_correct_iseli_z(F0, F1, B1, mdata.Fs); % correct for F1 | |
48 mdata.H1c = mdata.H1c - func_correct_iseli_z(F0, F2, B2, mdata.Fs); % correct for F2 | |
49 if (smoothwin~=0) | |
50 mdata.H1u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1u); | |
51 mdata.H1c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1c); | |
52 end | |
53 %mdata = rmfield(mdata, 'H1'); % remove H1 to remove confusion | |
54 end | |
55 | |
56 if (isfield(mdata, 'H2')) | |
57 mdata.H2u = mdata.H2; % H2 is actually the uncorrected harmonic | |
58 mdata.H2c = mdata.H2u - func_correct_iseli_z(2*F0, F1, B1, mdata.Fs); | |
59 mdata.H2c = mdata.H2c - func_correct_iseli_z(2*F0, F2, B2, mdata.Fs); | |
60 if (smoothwin~=0) | |
61 mdata.H2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2u); | |
62 mdata.H2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2c); | |
63 end | |
64 %mdata = rmfield(mdata, 'H2'); | |
65 end | |
66 | |
67 if (isfield(mdata, 'H4')) | |
68 mdata.H4u = mdata.H4; % H4 is actually the uncorrected harmonic | |
69 mdata.H4c = mdata.H4u - func_correct_iseli_z(4*F0, F1, B1, mdata.Fs); | |
70 mdata.H4c = mdata.H4c - func_correct_iseli_z(4*F0, F2, B2, mdata.Fs); | |
71 if (smoothwin~=0) | |
72 mdata.H4u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H4u); | |
73 mdata.H4c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H4c); | |
74 end | |
75 %mdata = rmfield(mdata, 'H4'); | |
76 end | |
77 | |
78 | |
79 % Ax | |
80 if (isfield(mdata, 'A1')) | |
81 mdata.A1u = mdata.A1; % A1 is actually the uncorrected amplitude | |
82 mdata.A1c = mdata.A1u - func_correct_iseli_z(F1, F1, B1, mdata.Fs); | |
83 mdata.A1c = mdata.A1c - func_correct_iseli_z(F1, F2, B3, mdata.Fs); | |
84 if (smoothwin~=0) | |
85 mdata.A1u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A1u); | |
86 mdata.A1c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A1c); | |
87 end | |
88 %mdata = rmfield(mdata, 'A1'); | |
89 end | |
90 | |
91 if (isfield(mdata, 'A2')) | |
92 mdata.A2u = mdata.A2; % A2 is acutally the uncorrected amplitude | |
93 mdata.A2c = mdata.A2u - func_correct_iseli_z(F2, F1, B1, mdata.Fs); | |
94 mdata.A2c = mdata.A2c - func_correct_iseli_z(F2, F2, B2, mdata.Fs); | |
95 if (smoothwin~=0) | |
96 mdata.A2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A2u); | |
97 mdata.A2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A2c); | |
98 end | |
99 %mdata = rmfield(mdata, 'A2'); | |
100 end | |
101 | |
102 if (isfield(mdata, 'A3')) | |
103 mdata.A3u = mdata.A3; % A3 is actually the uncorrected amplitude | |
104 mdata.A3c = mdata.A3u - func_correct_iseli_z(F3, F1, B1, mdata.Fs); | |
105 mdata.A3c = mdata.A3c - func_correct_iseli_z(F3, F2, B2, mdata.Fs); | |
106 mdata.A3c = mdata.A3c - func_correct_iseli_z(F3, F3, B3, mdata.Fs); | |
107 if (smoothwin~=0) | |
108 mdata.A3u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A3u); | |
109 mdata.A3c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.A3c); | |
110 end | |
111 %mdata = rmfield(mdata, 'A3'); | |
112 end | |
113 | |
114 | |
115 % the uncorrected combo parameters | |
116 if (isfield(mdata, 'H1') && isfield(mdata, 'H2')) | |
117 mdata.H1H2u = mdata.H1 - mdata.H2; | |
118 if (smoothwin ~= 0) | |
119 mdata.H1H2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1H2u); | |
120 end | |
121 end | |
122 | |
123 if (isfield(mdata, 'H2') && isfield(mdata, 'H4')) | |
124 mdata.H2H4u = mdata.H2 - mdata.H4; | |
125 if (smoothwin ~= 0) | |
126 mdata.H2H4u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2H4u); | |
127 end | |
128 end | |
129 | |
130 if (isfield(mdata, 'H1') && isfield(mdata, 'A1')) | |
131 mdata.H1A1u = mdata.H1 - mdata.A1; | |
132 if (smoothwin ~= 0) | |
133 mdata.H1A1u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A1u); | |
134 end | |
135 end | |
136 | |
137 if (isfield(mdata, 'H1') && isfield(mdata, 'A2')) | |
138 mdata.H1A2u = mdata.H1 - mdata.A2; | |
139 if (smoothwin ~= 0) | |
140 mdata.H1A2u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A2u); | |
141 end | |
142 end | |
143 | |
144 if (isfield(mdata, 'H1') && isfield(mdata, 'A3')) | |
145 mdata.H1A3u = mdata.H1 - mdata.A3; | |
146 if (smoothwin ~= 0) | |
147 mdata.H1A3u = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A3u); | |
148 end | |
149 end | |
150 | |
151 % this section is included for old VS compatibility, previously, the | |
152 % corrected versions of HxHx and HxAx were stored as HxHx and HxAx (i.e. | |
153 % without the "c" | |
154 if (isfield(mdata, 'H1H2')) | |
155 mdata.H1H2c = mdata.H1H2; | |
156 end | |
157 | |
158 if (isfield(mdata, 'H2H4')) | |
159 mdata.H2H4c = mdata.H2H4; | |
160 end | |
161 | |
162 if (isfield(mdata, 'H1A1')) | |
163 mdata.H1A1c = mdata.H1A1; | |
164 end | |
165 | |
166 if (isfield(mdata, 'H1A2')) | |
167 mdata.H1A2c = mdata.H1A2; | |
168 end | |
169 | |
170 if (isfield(mdata, 'H1A3')) | |
171 mdata.H1A3c = mdata.H1A3; | |
172 end | |
173 | |
174 | |
175 % check if the others require smoothing | |
176 if (smoothwin ~= 0) | |
177 if (isfield(mdata, 'H1H2c')) | |
178 mdata.H1H2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1H2c); | |
179 end | |
180 | |
181 if (isfield(mdata, 'H2H4c')) | |
182 mdata.H2H4c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H2H4c); | |
183 end | |
184 | |
185 if (isfield(mdata, 'H1A1c')) | |
186 mdata.H1A1c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A1c); | |
187 end | |
188 | |
189 if (isfield(mdata, 'H1A2c')) | |
190 mdata.H1A2c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A2c); | |
191 end | |
192 | |
193 if (isfield(mdata, 'H1A3c')) | |
194 mdata.H1A3c = filter(ones(smoothwin,1)/smoothwin, 1, mdata.H1A3c); | |
195 end | |
196 | |
197 if (isfield(mdata, 'CPP')) | |
198 mdata.CPP = filter(ones(smoothwin,1)/smoothwin, 1, mdata.CPP); | |
199 end | |
200 | |
201 if (isfield(mdata, 'HNR05')) | |
202 mdata.HNR05 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR05); | |
203 end | |
204 | |
205 if (isfield(mdata, 'HNR15')) | |
206 mdata.HNR15 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR15); | |
207 end | |
208 | |
209 if (isfield(mdata, 'HNR25')) | |
210 mdata.HNR25 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR25); | |
211 end | |
212 | |
213 if (isfield(mdata, 'HNR35')) | |
214 mdata.HNR35 = filter(ones(smoothwin,1)/smoothwin, 1, mdata.HNR35); | |
215 end | |
216 | |
217 end |