comparison dsp/segmentation/cluster_segmenter.c @ 283:5e125f030287

* Fixes to problems shown up by vamp-plugin-tester. Still not all plugins pass all tests, though
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 23 Mar 2009 16:28:53 +0000
parents 7d3e12411596
children e5907ae6de17
comparison
equal deleted inserted replaced
282:2703b3437aee 283:5e125f030287
159 /* create a model */ 159 /* create a model */
160 model_t* model = hmm_init(features, frames_read, feature_length, nHMM_states); 160 model_t* model = hmm_init(features, frames_read, feature_length, nHMM_states);
161 161
162 /* train the model */ 162 /* train the model */
163 hmm_train(features, frames_read, model); 163 hmm_train(features, frames_read, model);
164 164 /*
165 printf("\n\nafter training:\n"); 165 printf("\n\nafter training:\n");
166 hmm_print(model); 166 hmm_print(model);
167 167 */
168 /* decode the hidden state sequence */ 168 /* decode the hidden state sequence */
169 viterbi_decode(features, frames_read, model, q); 169 viterbi_decode(features, frames_read, model, q);
170 hmm_close(model); 170 hmm_close(model);
171 171
172 /*****************************/ 172 /*****************************/
173 } 173 }
174 /*****************************/ 174 /*****************************/
175 175
176 176
177 /*
177 fprintf(stderr, "HMM state sequence:\n"); 178 fprintf(stderr, "HMM state sequence:\n");
178 for (i = 0; i < frames_read; i++) 179 for (i = 0; i < frames_read; i++)
179 fprintf(stderr, "%d ", q[i]); 180 fprintf(stderr, "%d ", q[i]);
180 fprintf(stderr, "\n\n"); 181 fprintf(stderr, "\n\n");
182 */
181 183
182 /* create histograms of states */ 184 /* create histograms of states */
183 double* h = (double*) malloc(frames_read*nHMM_states*sizeof(double)); /* vector in row major order */ 185 double* h = (double*) malloc(frames_read*nHMM_states*sizeof(double)); /* vector in row major order */
184 create_histograms(q, frames_read, nHMM_states, histogram_length, h); 186 create_histograms(q, frames_read, nHMM_states, histogram_length, h);
185 187
207 double** chroma; 209 double** chroma;
208 int i; 210 int i;
209 211
210 if (feature_type == FEATURE_TYPE_CONSTQ) 212 if (feature_type == FEATURE_TYPE_CONSTQ)
211 { 213 {
212 fprintf(stderr, "Converting to dB and normalising...\n"); 214 /* fprintf(stderr, "Converting to dB and normalising...\n");
213 215 */
214 mpeg7_constq(features, frames_read, ncoeff); 216 mpeg7_constq(features, frames_read, ncoeff);
215 217 /*
216 fprintf(stderr, "Running PCA...\n"); 218 fprintf(stderr, "Running PCA...\n");
217 219 */
218 /* do PCA on the features (but not the envelope) */ 220 /* do PCA on the features (but not the envelope) */
219 int ncomponents = 20; 221 int ncomponents = 20;
220 pca_project(features, frames_read, ncoeff, ncomponents); 222 pca_project(features, frames_read, ncoeff, ncomponents);
221 223
222 /* copy the envelope so that it immediatly follows the chosen components */ 224 /* copy the envelope so that it immediatly follows the chosen components */
253 cluster_segment(q, features, frames_read, feature_length, nHMM_states, histogram_length, nclusters, neighbour_limit); 255 cluster_segment(q, features, frames_read, feature_length, nHMM_states, histogram_length, nclusters, neighbour_limit);
254 } 256 }
255 257
256 if (feature_type == FEATURE_TYPE_CHROMA) 258 if (feature_type == FEATURE_TYPE_CHROMA)
257 { 259 {
260 /*
258 fprintf(stderr, "Converting to chroma features...\n"); 261 fprintf(stderr, "Converting to chroma features...\n");
259 262 */
260 /* convert constant-Q to normalised chroma features */ 263 /* convert constant-Q to normalised chroma features */
261 chroma = (double**) malloc(frames_read*sizeof(double*)); 264 chroma = (double**) malloc(frames_read*sizeof(double*));
262 for (i = 0; i < frames_read; i++) 265 for (i = 0; i < frames_read; i++)
263 chroma[i] = (double*) malloc(bins*sizeof(double)); 266 chroma[i] = (double*) malloc(bins*sizeof(double));
264 cq2chroma(features, frames_read, ncoeff, bins, chroma); 267 cq2chroma(features, frames_read, ncoeff, bins, chroma);