/* This function returns the GF of bounds for False = S.contains(s_i) */ void count_n_not_contains(CONFIGURE *conf, MLINK lp, char** s, int n, bounds* results) { int i, j; // printf ("Parameters %d\n", n); // for (j = 0; j < n; j++) printf("String %d is %s \n", j, s[j]); int slen[n]; int *ctable[n]; for (i = 0; i < n; i++) { slen[i] = strlen(s[i]); ctable[i] = malloc(sizeof(int) * slen[i]); compute_correlation_table(s[i], ctable[i], slen[i]); } char* lBound; char* minupper; compute_from_n_correlation_table(conf, lp, ctable, slen, n, &lBound); //compute the upper bounds which is MIN(not contains(A_i)) for (i = 0; i < n; i++){ char* c = malloc(slen[i]*5+10); strcpy(c, " "); for (j = 0; j < slen[i]; j ++) { char tmp[10]; if (ctable[i][j] == 1) { sprintf(tmp, "+X^%d", j); strcat(c, tmp); } } char* expression = malloc(slen[i]*14 + 30); sprintf(expression, "(%s)/(X^%d + (1-%dX)(%s))", c, slen[i], conf->alphabet_size, c); char* gfi; send_to_mathematica(lp, expression, &gfi); if (i > 0){ char* tmpbest = malloc(strlen(minupper)+1); strcpy (tmpbest, minupper); MINF(conf, lp, tmpbest, gfi, &minupper); free(tmpbest); } else{ minupper = malloc(strlen(gfi)+1); strcpy (minupper, gfi); } } copy_bounds_concrete(lBound, minupper, results); // printf("Result of combination %s\n", lBound); free(minupper); free(lBound); for (i = 0; i < n; i++) free(ctable[i]); }
void noisiness_tick(t_noisiness *x) { t_int i, index=0, cpt; t_float Spz = 0.0f, SFM = 0.0f; double prod = 1.0f, sum = 0.0f; double invNumBand = 0.04f; // Zero padding for (i=x->BufSize; i<x->FFTSize; i++) x->BufFFT[i] = 0.0f; // Window the samples if (x->x_window != Recta) for (i=0; i<x->BufSize; ++i) x->BufFFT[i] *= x->WindFFT[i]; // FFT fftRealfast(x->FFTSize, x->BufFFT, x->memFFT); // Squared Absolute for (i=0; i<x->FFTSize; i+=2) x->BufFFT[i/2] = (x->BufFFT[i] * x->BufFFT[i]) + (x->BufFFT[i+1] * x->BufFFT[i+1]); // Band Spz for (i=0; i<NUMBAND; i++) { cpt = x->BufSizeBark[i]; Spz = 0.0f; while (cpt > 0) { Spz += x->BufFFT[index]; cpt--; index++; } Spz = Spz/x->BufSizeBark[i]; sum += Spz; prod *= Spz; } prod = pow(prod,invNumBand); sum = invNumBand * sum; SFM = prod/sum; // Spectral Flatness Measure (SFM) if (SFM > 0) { SFM = 10*log10(prod/sum); } else { SFM = 0.0f; } // Tonality factor or Peakiness x->x_noisiness = MINF((SFM/-SFM_MAX),1); // minimum of both // Output result outlet_float(x->x_outnois, (1.0 - x->x_noisiness)); }
void noisiness_tick_G4(t_noisiness *x) { t_int i, index=0, cpt; t_float Spz = 0.0f, SFM = 0.0f; double prod = 1.0f, sum = 0.0f; double invNumBand = 0.04f; // Zero padding for (i=x->BufSize; i<x->FFTSize; i++) x->BufFFT[i] = 0.0f; // Window the samples if (x->x_window != Recta) for (i=0; i<x->BufSize; ++i) x->BufFFT[i] *= x->WindFFT[i]; // Look at the real signal as an interleaved complex vector by casting it. // Then call the transformation function ctoz to get a split complex vector, // which for a real signal, divides into an even-odd configuration. ctoz ((COMPLEX *) x->BufFFT, 2, &x->x_A, 1, x->x_FFTSizeOver2); // Carry out a Forward FFT transform fft_zrip(x->x_setup, &x->x_A, 1, x->x_log2n, FFT_FORWARD); // The output signal is now in a split real form. Use the function // ztoc to get a split real vector. ztoc ( &x->x_A, 1, (COMPLEX *) x->BufFFT, 2, x->x_FFTSizeOver2); // Squared Absolute for (i=0; i<x->FFTSize; i+=2) x->BufFFT[i/2] = (x->BufFFT[i] * x->BufFFT[i]) + (x->BufFFT[i+1] * x->BufFFT[i+1]); // Band Spz for (i=0; i<NUMBAND; i++) { cpt = x->BufSizeBark[i]; Spz = 0.0f; while (cpt > 0) { Spz += x->BufFFT[index]; cpt--; index++; } Spz = Spz/x->BufSizeBark[i]; sum += Spz; prod *= Spz; } prod = pow(prod,invNumBand); sum = invNumBand * sum; SFM = prod/sum; // Spectral Flatness Measure (SFM) if (SFM > 0) { SFM = 10*log10(prod/sum); } else { SFM = 0.0f; } // Tonality factor or Peakiness x->x_noisiness = MINF((SFM/-SFM_MAX),1); // minimum of both // Output result outlet_float(x->x_outnois, (1.0 - x->x_noisiness)); }