From: Rudolf Polzer Date: Wed, 12 Oct 2011 10:19:06 +0000 (+0200) Subject: better comparisons X-Git-Tag: xonotic-v0.6.0~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e6d0dc8c5167d06b8bb1c550a38a7ee8356a74b6;p=xonotic%2Fmediasource.git better comparisons --- 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; }