comparison dsp/segmentation/ClusterMeltSegmenter.cpp @ 189:e4a57215ddee

Fix compiler warnings with -Wall -Wextra
author Chris Cannam
date Mon, 28 Sep 2015 12:33:17 +0100
parents f6ccde089491
children 175e51ae78eb
comparison
equal deleted inserted replaced
188:224f400410ef 189:e4a57215ddee
327 delete mfcc; 327 delete mfcc;
328 mfcc = 0; 328 mfcc = 0;
329 delete decimator; 329 delete decimator;
330 decimator = 0; 330 decimator = 0;
331 331
332 if (features.size() < histogramLength) return; 332 int sz = features.size();
333
334 if (sz < histogramLength) return;
333 /* 335 /*
334 std::cerr << "ClusterMeltSegmenter::segment: have " << features.size() 336 std::cerr << "ClusterMeltSegmenter::segment: have " << features.size()
335 << " features with " << features[0].size() << " coefficients (ncoeff = " << ncoeff << ", ncomponents = " << ncomponents << ")" << std::endl; 337 << " features with " << features[0].size() << " coefficients (ncoeff = " << ncoeff << ", ncomponents = " << ncomponents << ")" << std::endl;
336 */ 338 */
337 // copy the features to a native array and use the existing C segmenter... 339 // copy the features to a native array and use the existing C segmenter...
338 double** arrFeatures = new double*[features.size()]; 340 double** arrFeatures = new double*[features.size()];
339 for (int i = 0; i < features.size(); i++) 341 for (int i = 0; i < sz; i++)
340 { 342 {
341 if (featureType == FEATURE_TYPE_UNKNOWN) { 343 if (featureType == FEATURE_TYPE_UNKNOWN) {
342 arrFeatures[i] = new double[features[0].size()]; 344 arrFeatures[i] = new double[features[0].size()];
343 for (int j = 0; j < features[0].size(); j++) 345 for (int j = 0; j < int(features[0].size()); j++) {
344 arrFeatures[i][j] = features[i][j]; 346 arrFeatures[i][j] = features[i][j];
347 }
345 } else { 348 } else {
346 arrFeatures[i] = new double[ncoeff+1]; // allow space for the normalised envelope 349 arrFeatures[i] = new double[ncoeff+1]; // allow space for the normalised envelope
347 for (int j = 0; j < ncoeff; j++) 350 for (int j = 0; j < ncoeff; j++) {
348 arrFeatures[i][j] = features[i][j]; 351 arrFeatures[i][j] = features[i][j];
352 }
349 } 353 }
350 } 354 }
351 355
352 q = new int[features.size()]; 356 q = new int[features.size()];
353 357
362 // convert the cluster assignment sequence to a segmentation 366 // convert the cluster assignment sequence to a segmentation
363 makeSegmentation(q, features.size()); 367 makeSegmentation(q, features.size());
364 368
365 // de-allocate arrays 369 // de-allocate arrays
366 delete [] q; 370 delete [] q;
367 for (int i = 0; i < features.size(); i++) 371 for (int i = 0; i < int(features.size()); i++) delete [] arrFeatures[i];
368 delete [] arrFeatures[i];
369 delete [] arrFeatures; 372 delete [] arrFeatures;
370 373
371 // clear the features 374 // clear the features
372 clear(); 375 clear();
373 } 376 }