plugins/qm-dsp/dsp/segmentation/cluster_segmenter.c
/* applies MPEG-7 normalisation to constant-Q features, storing normalised envelope (norm) in last feature dimension */
applies MPEG-7 normalisation to constant-Q features, storing normalised envelope (norm) in last feature dimension
applies MPEG - 7 normalisation to constant - Q features storing normalised envelope ( norm ) in last feature dimension
void mpeg7_constq(double** features, int nframes, int ncoeff)
{
    int i, j;
    double ss;
    double env;
    double maxenv = 0;
    for (i = 0; i < nframes; i++) {
        for (j = 0; j < ncoeff; j++) {
            features[i][j] = 10.0 * log10(features[i][j]+DBL_EPSILON);
        }
    }
    for (i = 0; i < nframes; i++) {
        ss = 0;
        for (j = 0; j < ncoeff; j++) {
            ss += features[i][j] * features[i][j];
        }
        env = sqrt(ss);
        for (j = 0; j < ncoeff; j++) {
            features[i][j] /= env;
        }
        features[i][ncoeff] = env;
        if (env > maxenv) {
            maxenv = env;
        }
    } 
    for (i = 0; i < nframes; i++) {
        features[i][ncoeff] /= maxenv;
    }
}
void mpeg7_constq ( double * * features , int nframes , int ncoeff ) { int i , j ; double ss ; double env ; double maxenv = 0 ; for ( i = 0 ; i < nframes ; i ++ ) { for ( j = 0 ; j < ncoeff ; j ++ ) { features [ i ] [ j ] = 10.0 * log10 ( features [ i ] [ j ] + DBL_EPSILON ) ; } } for ( i = 0 ; i < nframes ; i ++ ) { ss = 0 ; for ( j = 0 ; j < ncoeff ; j ++ ) { ss += features [ i ] [ j ] * features [ i ] [ j ] ; } env = sqrt ( ss ) ; for ( j = 0 ; j < ncoeff ; j ++ ) { features [ i ] [ j ] /= env ; } features [ i ] [ ncoeff ] = env ; if ( env > maxenv ) { maxenv = env ; } } for ( i = 0 ; i < nframes ; i ++ ) { features [ i ] [ ncoeff ] /= maxenv ; } }
applies MPEG-7 normalisation to constant-Q features, storing normalised envelope (norm) in last feature dimension
applies MPEG - 7 normalisation to constant - Q features storing normalised envelope ( norm ) in last feature dimension
/* convert const-Q features to dB scale */ /* normalise each feature vector and add the norm as an extra feature dimension */ /* normalise the envelopes */