]> git.rm.cloudns.org Git - xonotic/mediasource.git/commitdiff
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 997e11e3b2dd6efc78f05219f0f455465b99bb38..14d12f42a206f71c76083dd415a77ae8fdda1c4e 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;
 }