Dawn@4
|
1 function [] = kmeans_Formants_Singing( varargin )
|
Dawn@4
|
2
|
Dawn@4
|
3 cd 'C:\Users\dawn\Dropbox\TestResults'
|
Dawn@4
|
4
|
Dawn@4
|
5 DEBUG = 0;
|
Dawn@4
|
6 % output results file name
|
Dawn@4
|
7 masterFileOutputID = fopen( 'kmeans_paper_SingingFormantsStats.txt', 'a' );
|
Dawn@4
|
8 % input results file name
|
Dawn@4
|
9 % inputFileName = 'paper_singingFormantsStats_ZhangShuo.txt';
|
Dawn@4
|
10 % inputFileName = 'paper_singingFormantsStats_WangXinnong.txt';
|
Dawn@4
|
11 inputFileName = 'paper_singingFormantsStats.txt';
|
Dawn@4
|
12
|
Dawn@4
|
13 % This function allows the user to stipulate which Singing voice LLD's they
|
Dawn@4
|
14 % wish to forward to a k-means classifier and produces a file of
|
Dawn@4
|
15 % performance characteristics. Input arguments stipulate the LLD's and
|
Dawn@4
|
16 % there is a choice of:-
|
Dawn@4
|
17 %
|
Dawn@4
|
18 % ---- PRAAT FORMANT MEASUREMENTS ----
|
Dawn@4
|
19 % '_Formant_Burg'
|
Dawn@4
|
20 % '_Formant_all'
|
Dawn@4
|
21 % '_Formant_robust'
|
Dawn@4
|
22 %
|
Dawn@4
|
23 % A text file entitled kmeans_Singing_LLD1name_LLD2name_ ... LLDNname.txt
|
Dawn@4
|
24 % is produced that contains the results of the k-mean classification for
|
Dawn@4
|
25 % the LLD's specified and named in the result document title.
|
Dawn@4
|
26
|
Dawn@4
|
27 fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName);
|
Dawn@4
|
28 inputFileID = fopen( inputFileName );
|
Dawn@4
|
29
|
Dawn@4
|
30 % get the column numbers of the results that we want to classify
|
Dawn@4
|
31
|
Dawn@4
|
32 % COLUMN NUMBER : METRIC
|
Dawn@4
|
33 %
|
Dawn@4
|
34 % ------------- BURG FORMANTS ---------------
|
Dawn@4
|
35 % 11 : Number of BURG formants listed = nBF
|
Dawn@4
|
36 %
|
Dawn@4
|
37 % THERE ARE CURRENTLY 24 MEASUREMENTS TAKEN FOR EACH FORMANT
|
Dawn@4
|
38 nMetrics = 24;
|
Dawn@4
|
39 %
|
Dawn@4
|
40 % 12 : mean frequency of the first BURG formant
|
Dawn@4
|
41 % 13 : variance of the first BURG formant
|
Dawn@4
|
42 % 14 : minimum frequency of the first BURG formant
|
Dawn@4
|
43 % 15 : maximum frequency of the first BURG formant
|
Dawn@4
|
44 % 16 : mean Frequency Derivative of the first BURG formant
|
Dawn@4
|
45 % 17 : varience of the Frequency Derivative of the first BURG formant
|
Dawn@4
|
46 % 18 : min of the Frequency Derivative of the first BURG formant
|
Dawn@4
|
47 % 19 : max of the Frequency Derivative of the first BURG formant
|
Dawn@4
|
48 % 20 : mean of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
49 % 21 : varience of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
50 % 22 : min of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
51 % 23 : max of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
52 % 24 : mean of the Bandwidth of the first BURG formant
|
Dawn@4
|
53 % 25 : varience of the Bandwidth of the first BURG formant
|
Dawn@4
|
54 % 26 : min of the Bandwidth of the first BURG formant
|
Dawn@4
|
55 % 27 : max of the Bandwidth of the first BURG formant
|
Dawn@4
|
56 % 28 : mean of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
57 % 29 : varience of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
58 % 30 : min of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
59 % 31 : max of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
60 % 32 : mean of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
61 % 33 : var of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
62 % 34 : min of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
63 % 35 : max of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
64 %
|
Dawn@4
|
65 % ....... there are nMetrics for each formant in nBF formants, so cycle
|
Dawn@4
|
66 % through until the last is reached ......
|
Dawn@4
|
67 %
|
Dawn@4
|
68 % 36 + ((nBF-1)*nMetrics) : mean frequency of the nBF BURG formant
|
Dawn@4
|
69 % 36 + ((nBF-1)*nMetrics) + 1 : variance of the nBF BURG formant
|
Dawn@4
|
70 % 36 + ((nBF-1)*nMetrics) + 2 : minimum frequency of the nBF BURG formant
|
Dawn@4
|
71 % 36 + ((nBF-1)*nMetrics) + 3 : maximum frequency of the nBF BURG formant
|
Dawn@4
|
72 % 36 + ((nBF-1)*nMetrics) + 4 : mean Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
73 % 36 + ((nBF-1)*nMetrics) + 5 : varience of the Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
74 % 36 + ((nBF-1)*nMetrics) + 6 : min of the Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
75 % 36 + ((nBF-1)*nMetrics) + 7 : max of the Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
76 % 36 + ((nBF-1)*nMetrics) + 8 : mean of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
77 % 36 + ((nBF-1)*nMetrics) + 9 : varience of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
78 % 36 + ((nBF-1)*nMetrics) + 10 : min of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
79 % 36 + ((nBF-1)*nMetrics) + 11 : max of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
80 % 36 + ((nBF-1)*nMetrics) + 12 : mean of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
81 % 36 + ((nBF-1)*nMetrics) + 13 : varience of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
82 % 36 + ((nBF-1)*nMetrics) + 14 : min of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
83 % 36 + ((nBF-1)*nMetrics) + 15 : max of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
84 % 36 + ((nBF-1)*nMetrics) + 16 : mean of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
85 % 36 + ((nBF-1)*nMetrics) + 17 : variece of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
86 % 36 + ((nBF-1)*nMetrics) + 18 : min of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
87 % 36 + ((nBF-1)*nMetrics) + 19 : max of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
88 % 36 + ((nBF-1)*nMetrics) + 20 : mean of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
89 % 36 + ((nBF-1)*nMetrics) + 21 : var of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
90 % 36 + ((nBF-1)*nMetrics) + 22 : min of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
91 % 36 + ((nBF-1)*nMetrics) + 23 : max of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
92 %
|
Dawn@4
|
93 % FOR THE MEAN OF ALL BURG FORMANTS
|
Dawn@4
|
94 % 36 + (nBF*nMetrics) : mean of all formants Frequency
|
Dawn@4
|
95 % 36 + (nBF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
Dawn@4
|
96 % 36 + (nBF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
Dawn@4
|
97 % 36 + (nBF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
Dawn@4
|
98 % 36 + (nBF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
Dawn@4
|
99 % 36 + (nBF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
Dawn@4
|
100 % 36 + (nBF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
Dawn@4
|
101 % 36 + (nBF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
Dawn@4
|
102 % 36 + (nBF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
103 % 36 + (nBF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
104 % 36 + (nBF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
105 % 36 + (nBF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
106 %
|
Dawn@4
|
107 % ------------- ALL FORMANTS ---------------
|
Dawn@4
|
108 %
|
Dawn@4
|
109 % 36 + (nBF*nMetrics) + 12 : Number of ALL formants listed = nAF
|
Dawn@4
|
110 %
|
Dawn@4
|
111 % startOfALLMeasurements = 36 + (nBF*nMetrics) + 13;
|
Dawn@4
|
112 %
|
Dawn@4
|
113 % startOfALLMeasurements : mean frequency of the first ALL formant
|
Dawn@4
|
114 % startOfALLMeasurements + 1 : variance of the first ALL formant
|
Dawn@4
|
115 % startOfALLMeasurements + 2 : minimum frequency of the first ALL formant
|
Dawn@4
|
116 % startOfALLMeasurements + 3 : maximum frequency of the first ALL formant
|
Dawn@4
|
117 % startOfALLMeasurements + 4 : mean Frequency Derivative of the first ALL formant
|
Dawn@4
|
118 % startOfALLMeasurements + 5 : varience of the Frequency Derivative of the first ALL formant
|
Dawn@4
|
119 % startOfALLMeasurements + 6 : min of the Frequency Derivative of the first ALL formant
|
Dawn@4
|
120 % startOfALLMeasurements + 7 : max of the Frequency Derivative of the first ALL formant
|
Dawn@4
|
121 % startOfALLMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
122 % startOfALLMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
123 % startOfALLMeasurements + 10 : min of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
124 % startOfALLMeasurements + 11 : max of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
125 % startOfALLMeasurements + 12 : mean of the Bandwidth of the first ALL formant
|
Dawn@4
|
126 % startOfALLMeasurements + 13 : varience of the Bandwidth of the first ALL formant
|
Dawn@4
|
127 % startOfALLMeasurements + 14 : min of the Bandwidth of the first ALL formant
|
Dawn@4
|
128 % startOfALLMeasurements + 15 : max of the Bandwidth of the first ALL formant
|
Dawn@4
|
129 % startOfALLMeasurements + 16 : mean of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
130 % startOfALLMeasurements + 17 : varience of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
131 % startOfALLMeasurements + 18 : min of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
132 % startOfALLMeasurements + 19 : max of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
133 % startOfALLMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
134 % startOfALLMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
135 % startOfALLMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
136 % startOfALLMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
137 %
|
Dawn@4
|
138 % ....... there are nMetrics for each formant in nAF formants, so cycle
|
Dawn@4
|
139 % through until the last is reached ......
|
Dawn@4
|
140 %
|
Dawn@4
|
141 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean frequency of the nAF ALL formant
|
Dawn@4
|
142 % startOfALLMeasurements + ((nAF-1)*nMetrics) : variance of the nAF ALL formant
|
Dawn@4
|
143 % startOfALLMeasurements + ((nAF-1)*nMetrics) : minimum frequency of the nAF ALL formant
|
Dawn@4
|
144 % startOfALLMeasurements + ((nAF-1)*nMetrics) : maximum frequency of the nAF ALL formant
|
Dawn@4
|
145 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
146 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
147 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
148 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
149 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
150 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
151 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
152 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
153 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
154 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
155 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
156 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
157 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
158 % startOfALLMeasurements + ((nAF-1)*nMetrics) : variece of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
159 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
160 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
161 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
162 % startOfALLMeasurements + ((nAF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
163 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
164 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
165 %
|
Dawn@4
|
166 % FOR THE MEAN OF ALL ALL FORMANTS
|
Dawn@4
|
167 % startOfALLMeasurements + (nAF*nMetrics) : mean of all formants Frequency
|
Dawn@4
|
168 % startOfALLMeasurements + (nAF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
Dawn@4
|
169 % startOfALLMeasurements + (nAF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
Dawn@4
|
170 % startOfALLMeasurements + (nAF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
Dawn@4
|
171 % startOfALLMeasurements + (nAF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
Dawn@4
|
172 % startOfALLMeasurements + (nAF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
Dawn@4
|
173 % startOfALLMeasurements + (nAF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
Dawn@4
|
174 % startOfALLMeasurements + (nAF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
Dawn@4
|
175 % startOfALLMeasurements + (nAF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
176 % startOfALLMeasurements + (nAF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
177 % startOfALLMeasurements + (nAF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
178 % startOfALLMeasurements + (nAF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
179 %
|
Dawn@4
|
180 % ------------- ROBUST FORMANTS ---------------
|
Dawn@4
|
181 %
|
Dawn@4
|
182 % startOfALLMeasurements + (nAF*nMetrics) + 12 : Number of ROBUST formants listed = nRF
|
Dawn@4
|
183 %
|
Dawn@4
|
184 % startOfROBUSTMeasurements = startOfALLMeasurements + (nAF*nMetrics) + 13;
|
Dawn@4
|
185 %
|
Dawn@4
|
186 % startOfROBUSTMeasurements : mean frequency of the first ROBUST formant
|
Dawn@4
|
187 % startOfROBUSTMeasurements + 1 : variance of the first ROBUST formant
|
Dawn@4
|
188 % startOfROBUSTMeasurements + 2 : minimum frequency of the first ROBUST formant
|
Dawn@4
|
189 % startOfROBUSTMeasurements + 3 : maximum frequency of the first ROBUST formant
|
Dawn@4
|
190 % startOfROBUSTMeasurements + 4 : mean Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
191 % startOfROBUSTMeasurements + 5 : varience of the Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
192 % startOfROBUSTMeasurements + 6 : min of the Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
193 % startOfROBUSTMeasurements + 7 : max of the Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
194 % startOfROBUSTMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
195 % startOfROBUSTMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
196 % startOfROBUSTMeasurements + 10 : min of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
197 % startOfROBUSTMeasurements + 11 : max of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
198 % startOfROBUSTMeasurements + 12 : mean of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
199 % startOfROBUSTMeasurements + 13 : varience of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
200 % startOfROBUSTMeasurements + 14 : min of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
201 % startOfROBUSTMeasurements + 15 : max of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
202 % startOfROBUSTMeasurements + 16 : mean of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
203 % startOfROBUSTMeasurements + 17 : varience of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
204 % startOfROBUSTMeasurements + 18 : min of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
205 % startOfROBUSTMeasurements + 19 : max of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
206 % startOfROBUSTMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
207 % startOfROBUSTMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
208 % startOfROBUSTMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
209 % startOfROBUSTMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
210 %
|
Dawn@4
|
211 % ....... there are nMetrics for each formant in nRF formants, so cycle
|
Dawn@4
|
212 % through until the last is reached ......
|
Dawn@4
|
213 %
|
Dawn@4
|
214 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean frequency of the nRF ROBUST formant
|
Dawn@4
|
215 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variance of the nRF ROBUST formant
|
Dawn@4
|
216 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : minimum frequency of the nRF ROBUST formant
|
Dawn@4
|
217 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : maximum frequency of the nRF ROBUST formant
|
Dawn@4
|
218 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
219 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
220 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
221 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
222 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
223 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
224 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
225 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
226 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
227 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
228 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
229 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
230 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
231 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variece of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
232 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
233 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
234 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
235 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
236 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
237 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
238 %
|
Dawn@4
|
239 % FOR THE MEAN OF ALL ROBUST FORMANTS
|
Dawn@4
|
240 % startOfROBUSTMeasurements + (nRF*nMetrics) : mean of all formants Frequency
|
Dawn@4
|
241 % startOfROBUSTMeasurements + (nRF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
Dawn@4
|
242 % startOfROBUSTMeasurements + (nRF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
Dawn@4
|
243 % startOfROBUSTMeasurements + (nRF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
Dawn@4
|
244 % startOfROBUSTMeasurements + (nRF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
Dawn@4
|
245 % startOfROBUSTMeasurements + (nRF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
Dawn@4
|
246 % startOfROBUSTMeasurements + (nRF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
Dawn@4
|
247 % startOfROBUSTMeasurements + (nRF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
Dawn@4
|
248 % startOfROBUSTMeasurements + (nRF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
249 % startOfROBUSTMeasurements + (nRF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
250 % startOfROBUSTMeasurements + (nRF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
251 % startOfROBUSTMeasurements + (nRF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
252 %
|
Dawn@4
|
253
|
Dawn@4
|
254 noOfArguments = length(varargin);
|
Dawn@4
|
255 columnIndices = [];
|
Dawn@4
|
256
|
Dawn@4
|
257 getBURGFormants = 0;
|
Dawn@4
|
258 getAllFormants=0;
|
Dawn@4
|
259 getRobustFormants=0;
|
Dawn@4
|
260
|
Dawn@4
|
261 for i=1 : noOfArguments
|
Dawn@4
|
262 if( strcmp( varargin{i}, 'formant_Burg' ))
|
Dawn@4
|
263 getBURGFormants = 1;
|
Dawn@4
|
264 elseif( strcmp( varargin{i}, 'formant_all' ))
|
Dawn@4
|
265 getAllFormants=1;
|
Dawn@4
|
266 elseif( strcmp( varargin{i}, 'formant_robust' ))
|
Dawn@4
|
267 getRobustFormants=1;
|
Dawn@4
|
268 end
|
Dawn@4
|
269 end
|
Dawn@4
|
270
|
Dawn@4
|
271 titleName = '';
|
Dawn@4
|
272 for i=1 : noOfArguments
|
Dawn@4
|
273 titleName = [ titleName varargin{i} '_'];
|
Dawn@4
|
274 fprintf( masterFileOutputID, '%s_', varargin{i} );
|
Dawn@4
|
275 end
|
Dawn@4
|
276
|
Dawn@4
|
277 fprintf( masterFileOutputID, '\t' );
|
Dawn@4
|
278
|
Dawn@4
|
279 % -------------------- get the data from the results file ---------------
|
Dawn@4
|
280 lineCount = 0;
|
Dawn@4
|
281 fileCount = 0;
|
Dawn@4
|
282 data = [];
|
Dawn@4
|
283 while( ~(feof(inputFileID)) )
|
Dawn@4
|
284
|
Dawn@4
|
285 outputValues = [];
|
Dawn@4
|
286 % sampleEmotion = [];
|
Dawn@4
|
287 % gender = [];
|
Dawn@4
|
288
|
Dawn@4
|
289 thestr = fgetl(inputFileID);
|
Dawn@4
|
290 if( lineCount > 10 ) % skip the file header
|
Dawn@4
|
291 fileCount = fileCount + 1;
|
Dawn@4
|
292
|
Dawn@4
|
293 % determine whether we have a positive or negative sample
|
Dawn@4
|
294 sampleEmotion( fileCount ) = 'U';
|
Dawn@4
|
295 if( ~(isempty(strfind(thestr,'pos'))))
|
Dawn@4
|
296 % sample is positive
|
Dawn@4
|
297 sampleEmotion( fileCount ) = 'P';
|
Dawn@4
|
298 elseif( ~(isempty(strfind(thestr,'neg'))))
|
Dawn@4
|
299 % sample is negative
|
Dawn@4
|
300 sampleEmotion( fileCount ) = 'N';
|
Dawn@4
|
301 else
|
Dawn@4
|
302 disp('EEEK!');
|
Dawn@4
|
303 pause;
|
Dawn@4
|
304 end
|
Dawn@4
|
305
|
Dawn@4
|
306 % % determine whether we have a male, female or trans sample
|
Dawn@4
|
307 % gender( fileCount ) = '?';
|
Dawn@4
|
308 % if( ~(isempty(strfind(thestr,'fem'))))
|
Dawn@4
|
309 % % gender is female
|
Dawn@4
|
310 % gender( fileCount ) = 'F';
|
Dawn@4
|
311 % elseif( ~(isempty(strfind(thestr,'male'))))
|
Dawn@4
|
312 % % gender is male
|
Dawn@4
|
313 % gender( fileCount ) = 'M';
|
Dawn@4
|
314 % elseif( ~(isempty(strfind(thestr,'trans'))))
|
Dawn@4
|
315 % % gender is trans
|
Dawn@4
|
316 % gender( fileCount ) = 'T';
|
Dawn@4
|
317 % else
|
Dawn@4
|
318 % disp('EEEK!');
|
Dawn@4
|
319 % pause;
|
Dawn@4
|
320 % end
|
Dawn@4
|
321
|
Dawn@4
|
322 %how many values are in the string?
|
Dawn@4
|
323 spaces = strfind( thestr, ' ' );
|
Dawn@4
|
324 numberstr = thestr( spaces(1) : end ); % chop off the file name
|
Dawn@4
|
325 frmtpos = strfind( numberstr, 'maxNoOfFormants'); % find the position of the label for number of formants
|
Dawn@4
|
326
|
Dawn@4
|
327 % str1 = numberstr( 1 : frmtpos(1)-1 ); % string contains jitter and shimmer values
|
Dawn@4
|
328 str2 = numberstr( frmtpos(1) : frmtpos(2)-1 ); % string contains all BURG formant information
|
Dawn@4
|
329 str3 = numberstr( frmtpos(2) : frmtpos(3)-1 ); % string contains all ALL formant information
|
Dawn@4
|
330 str4 = numberstr( frmtpos(3) : end ); % string contains all ROBUST formant information
|
Dawn@4
|
331
|
Dawn@4
|
332
|
Dawn@4
|
333 % vars = sscanf( str1, '%f', inf );
|
Dawn@4
|
334 % % extract the shimmer and jitter values
|
Dawn@4
|
335 % outputValues = [ outputValues vars( columnIndices )'];
|
Dawn@4
|
336
|
Dawn@4
|
337 if( getBURGFormants )
|
Dawn@4
|
338 spaces = strfind( str2, ' ' ); % remove the string 'maxNoOfFormants'
|
Dawn@4
|
339 vars = sscanf( str2( spaces(1) : end ), '%f', inf );
|
Dawn@4
|
340 outputValues = stripOutFormantValues( vars, outputValues );
|
Dawn@4
|
341 end
|
Dawn@4
|
342
|
Dawn@4
|
343 if( getAllFormants )
|
Dawn@4
|
344 spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants'
|
Dawn@4
|
345 vars = sscanf( str3( spaces(1) : end ), '%f', inf );
|
Dawn@4
|
346 outputValues = stripOutFormantValues( vars, outputValues );
|
Dawn@4
|
347 end
|
Dawn@4
|
348
|
Dawn@4
|
349 if( getRobustFormants )
|
Dawn@4
|
350 spaces = strfind( str4, ' ' ); % remove the string 'maxNoOfFormants'
|
Dawn@4
|
351 vars = sscanf( str4( spaces(1) : end ), '%f', inf );
|
Dawn@4
|
352 outputValues = stripOutFormantValues( vars, outputValues );
|
Dawn@4
|
353 end
|
Dawn@4
|
354
|
Dawn@4
|
355 [m n] = size( data );
|
Dawn@4
|
356 % sometimes the 'all' formants command gives us fewer formants than
|
Dawn@4
|
357 % usual. If this is the case,then we will have to pad with zeros
|
Dawn@4
|
358 % for now.
|
Dawn@4
|
359 if( n > length( outputValues ) )
|
Dawn@4
|
360 lenDiff = n - length( outputValues );
|
Dawn@4
|
361 outputValues = [ outputValues zeros( 1, lenDiff ) ];
|
Dawn@4
|
362 elseif( n < length( outputValues ) )
|
Dawn@4
|
363 lenDiff = length( outputValues ) - n;
|
Dawn@4
|
364 outputValues = [ outputValues zeros( 1, lenDiff ) ];
|
Dawn@4
|
365 end
|
Dawn@4
|
366
|
Dawn@4
|
367 data( fileCount, : ) = outputValues;
|
Dawn@4
|
368
|
Dawn@4
|
369 end
|
Dawn@4
|
370 lineCount = lineCount + 1;
|
Dawn@4
|
371
|
Dawn@4
|
372 end
|
Dawn@4
|
373 fclose(inputFileID);
|
Dawn@4
|
374
|
Dawn@4
|
375 % ------------ apply the k-means classifier ------------------------
|
Dawn@4
|
376
|
Dawn@4
|
377 noOfClusters = 2; % we are only trying to identify positive and negative emotions
|
Dawn@4
|
378
|
Dawn@4
|
379
|
Dawn@4
|
380 [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
381 'start', 'sample', 'Distance', 'cityblock');
|
Dawn@4
|
382
|
Dawn@4
|
383 %display results grouped by emotion
|
Dawn@4
|
384 fprintf( masterFileOutputID, '\n Emotion grouping \n');
|
Dawn@4
|
385 fprintf( masterFileOutputID, 'cityblock \n');
|
Dawn@4
|
386 [ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
387 [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'cityblock' );
|
Dawn@4
|
388
|
Dawn@4
|
389
|
Dawn@4
|
390 fprintf( masterFileOutputID, 'sqEuclidean \n');
|
Dawn@4
|
391 [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
392 'start', 'sample', 'Distance', 'sqEuclidean');
|
Dawn@4
|
393
|
Dawn@4
|
394 [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
395 [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'sqEuclidean' );
|
Dawn@4
|
396
|
Dawn@4
|
397
|
Dawn@4
|
398 fprintf( masterFileOutputID, 'cosine \n');
|
Dawn@4
|
399 [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
400 'start', 'sample', 'Distance', 'cosine');
|
Dawn@4
|
401
|
Dawn@4
|
402 [ groupStats, groupNames ] = processKMeansResults( 'cosine', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
403 [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID,'cosine' );
|
Dawn@4
|
404
|
Dawn@4
|
405
|
Dawn@4
|
406 fprintf( masterFileOutputID, 'correlation \n');
|
Dawn@4
|
407 [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
408 'start', 'sample', 'Distance', 'correlation');
|
Dawn@4
|
409
|
Dawn@4
|
410 [ groupStats, groupNames ] = processKMeansResults( 'correlation', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
411 [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'correlation' );
|
Dawn@4
|
412
|
Dawn@4
|
413
|
Dawn@4
|
414 fprintf( masterFileOutputID, '\n' );
|
Dawn@4
|
415 fclose( masterFileOutputID );
|
Dawn@4
|
416
|
Dawn@4
|
417 end
|
Dawn@4
|
418
|
Dawn@4
|
419 %------------------------------------------------------------------
|
Dawn@4
|
420
|
Dawn@4
|
421 function [ outputValues ] = stripOutFormantValues( vars, outputValues )
|
Dawn@4
|
422
|
Dawn@4
|
423 noOfFormantValues = length( vars ) - 1; % gives the number of formant arguments only
|
Dawn@4
|
424 noOfFormants = vars(1);
|
Dawn@4
|
425 % there are 12 measurements for the mean of all formants (so the number
|
Dawn@4
|
426 % of formants is not important) for each formant measurement.
|
Dawn@4
|
427 if( noOfFormants ~= (noOfFormantValues-12)/24 )
|
Dawn@4
|
428 disp('EEK!');
|
Dawn@4
|
429 pause;
|
Dawn@4
|
430 else
|
Dawn@4
|
431 outputValues = [ outputValues vars( 2:end )' ];
|
Dawn@4
|
432 end
|
Dawn@4
|
433
|
Dawn@4
|
434 end
|
Dawn@4
|
435
|
Dawn@4
|
436 %-------------------------------------------------------------------
|