better comparisons
authorRudolf Polzer <divVerent@xonotic.org>
Wed, 12 Oct 2011 10:19:06 +0000 (12:19 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Wed, 12 Oct 2011 10:19:06 +0000 (12:19 +0200)
sound/weapons/loopfinder/findloop.c

index 997e11e..14d12f4 100644 (file)
@@ -52,12 +52,18 @@ void doFourier(double *input, int channels, sf_count_t len, fftw_complex *output
        fftw_execute_dft_r2c(planlos, windowedData, output);
 }
 
+// idea: if match, then sxx * syy = sxy * sxy
+
 double vectorDot(fftw_complex *v1, fftw_complex *v2, size_t length)
 {
        size_t i;
        double sum = 0;
        for(i = 0; i < length; ++i)
                sum += cabs(v1[i]) * cabs(v2[i]);
+       for(i = 0; i < length; ++i)
+               sum += 0.001 * creal(v1[i]) * creal(v2[i]);
+       for(i = 0; i < length; ++i)
+               sum += 0.001 * cimag(v1[i]) * cimag(v2[i]);
        return sum;
 }