From e6d0dc8c5167d06b8bb1c550a38a7ee8356a74b6 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 12 Oct 2011 12:19:06 +0200 Subject: [PATCH] better comparisons --- sound/weapons/loopfinder/findloop.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/weapons/loopfinder/findloop.c b/sound/weapons/loopfinder/findloop.c index 997e11e..14d12f4 100644 --- a/sound/weapons/loopfinder/findloop.c +++ b/sound/weapons/loopfinder/findloop.c @@ -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; } -- 2.39.2