Mercurial > hg > qm-dsp
diff dsp/segmentation/ClusterMeltSegmenter.cpp @ 480:175e51ae78eb
Untabify, indent, tidy
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Fri, 31 May 2019 10:53:39 +0100 |
parents | 7e8d1f26b098 |
children | bb78ca3fe7de |
line wrap: on
line diff
--- a/dsp/segmentation/ClusterMeltSegmenter.cpp Fri May 31 10:35:08 2019 +0100 +++ b/dsp/segmentation/ClusterMeltSegmenter.cpp Fri May 31 10:53:39 2019 +0100 @@ -36,7 +36,7 @@ fmin(params.fmin), fmax(params.fmax), nbins(params.nbins), - ncomponents(params.ncomponents), // NB currently not passed - no. of PCA components is set in cluser_segmenter.c + ncomponents(params.ncomponents), // NB currently not passed - no. of PCA components is set in cluser_segmenter.c nHMMStates(params.nHMMStates), nclusters(params.nclusters), histogramLength(params.histogramLength), @@ -212,7 +212,7 @@ fft->forward(frame, real, imag); constq->process(real, imag, cqre, cqim); - + for (int i = 0; i < ncoeff; ++i) { cq[i] += sqrt(cqre[i] * cqre[i] + cqim[i] * cqim[i]); } @@ -287,7 +287,7 @@ } mfcc->process(frame, ccout); - + for (int i = 0; i < ncoeff; ++i) { cc[i] += ccout[i]; } @@ -337,40 +337,40 @@ << " features with " << features[0].size() << " coefficients (ncoeff = " << ncoeff << ", ncomponents = " << ncomponents << ")" << std::endl; */ // copy the features to a native array and use the existing C segmenter... - double** arrFeatures = new double*[features.size()]; - for (int i = 0; i < sz; i++) - { + double** arrFeatures = new double*[features.size()]; + for (int i = 0; i < sz; i++) { if (featureType == FEATURE_TYPE_UNKNOWN) { arrFeatures[i] = new double[features[0].size()]; for (int j = 0; j < int(features[0].size()); j++) { arrFeatures[i][j] = features[i][j]; } } else { - arrFeatures[i] = new double[ncoeff+1]; // allow space for the normalised envelope + arrFeatures[i] = new double[ncoeff+1]; // allow space for the normalised envelope for (int j = 0; j < ncoeff; j++) { arrFeatures[i][j] = features[i][j]; } } } - + q = new int[features.size()]; - + if (featureType == FEATURE_TYPE_UNKNOWN || - featureType == FEATURE_TYPE_MFCC) + featureType == FEATURE_TYPE_MFCC) { cluster_segment(q, arrFeatures, features.size(), features[0].size(), nHMMStates, histogramLength, nclusters, neighbourhoodLimit); - else + } else { constq_segment(q, arrFeatures, features.size(), nbins, ncoeff, featureType, nHMMStates, histogramLength, nclusters, neighbourhoodLimit); - + } + // convert the cluster assignment sequence to a segmentation - makeSegmentation(q, features.size()); - + makeSegmentation(q, features.size()); + // de-allocate arrays delete [] q; for (int i = 0; i < int(features.size()); i++) delete [] arrFeatures[i]; delete [] arrFeatures; - + // clear the features clear(); } @@ -380,15 +380,13 @@ segmentation.segments.clear(); segmentation.nsegtypes = nclusters; segmentation.samplerate = samplerate; - + Segment segment; segment.start = 0; segment.type = q[0]; - - for (int i = 1; i < len; i++) - { - if (q[i] != q[i-1]) - { + + for (int i = 1; i < len; i++) { + if (q[i] != q[i-1]) { segment.end = i * getHopsize(); segmentation.segments.push_back(segment); segment.type = q[i];