plugins/qm-dsp/dsp/segmentation/cluster_segmenter.c
/* segment constant-Q or chroma features */
segment constant-Q or chroma features
segment constant - Q or chroma features
void constq_segment(int* q, double** features, int frames_read, int bins, int ncoeff, int feature_type, 
                    int nHMM_states, int histogram_length, int nclusters, int neighbour_limit)
{
    int feature_length;
    double** chroma;
    int i;
    if (feature_type == FEATURE_TYPE_CONSTQ) {
        mpeg7_constq(features, frames_read, ncoeff);
        int ncomponents = 20;
        pca_project(features, frames_read, ncoeff, ncomponents);
        for (i = 0; i < frames_read; i++) {
            features[i][ncomponents] = features[i][ncoeff];
        }
        feature_length = ncomponents + 1;
        cluster_segment(q, features, frames_read, feature_length,
                        nHMM_states, histogram_length, nclusters,
                        neighbour_limit);
    }
    if (feature_type == FEATURE_TYPE_CHROMA) {
        chroma = (double**) malloc(frames_read*sizeof(double*));
        for (i = 0; i < frames_read; i++) {
            chroma[i] = (double*) malloc(bins*sizeof(double));
        }
        cq2chroma(features, frames_read, ncoeff, bins, chroma);
        feature_length = bins;
        cluster_segment(q, chroma, frames_read, feature_length,
                        nHMM_states, histogram_length, nclusters,
                        neighbour_limit);
        for (i = 0; i < frames_read; i++)
            free(chroma[i]);
        free(chroma);
    }
}
void constq_segment ( int * q , double * * features , int frames_read , int bins , int ncoeff , int feature_type , int nHMM_states , int histogram_length , int nclusters , int neighbour_limit ) { int feature_length ; double * * chroma ; int i ; if ( feature_type == FEATURE_TYPE_CONSTQ ) { mpeg7_constq ( features , frames_read , ncoeff ) ; int ncomponents = 20 ; pca_project ( features , frames_read , ncoeff , ncomponents ) ; for ( i = 0 ; i < frames_read ; i ++ ) { features [ i ] [ ncomponents ] = features [ i ] [ ncoeff ] ; } feature_length = ncomponents + 1 ; cluster_segment ( q , features , frames_read , feature_length , nHMM_states , histogram_length , nclusters , neighbour_limit ) ; } if ( feature_type == FEATURE_TYPE_CHROMA ) { chroma = ( double * * ) malloc ( frames_read * sizeof ( double * ) ) ; for ( i = 0 ; i < frames_read ; i ++ ) { chroma [ i ] = ( double * ) malloc ( bins * sizeof ( double ) ) ; } cq2chroma ( features , frames_read , ncoeff , bins , chroma ) ; feature_length = bins ; cluster_segment ( q , chroma , frames_read , feature_length , nHMM_states , histogram_length , nclusters , neighbour_limit ) ; for ( i = 0 ; i < frames_read ; i ++ ) free ( chroma [ i ] ) ; free ( chroma ) ; } }
segment constant-Q or chroma features
segment constant - Q or chroma features
/* do PCA on the features (but not the envelope) */ /* copy the envelope so that it immediatly follows the chosen components */ /* convert constant-Q to normalised chroma features */