From 8fad3a92195af9f58d008ec82c267c7a992456cc Mon Sep 17 00:00:00 2001 From: Sean Enderby Date: Tue, 25 Feb 2014 14:12:29 +0000 Subject: tristimulus3 correction --- src/scalar.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/scalar.c b/src/scalar.c index d064840..ba662f2 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -486,21 +486,21 @@ int xtract_tristimulus_2(const double *data, const int N, const void *argv, doub int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result) { + int n = N >> 1, h = 0, i; + double den = 0.0, num = 0.0, fund = 0.0, temp = 0.0; + const double *freqs; - int n = N, count = 0; - - double den, num, temp; - - den = num = temp = 0.0; + fund = *(double *)argv; + freqs = data + n; - for(n = 0; n < N; n++) + for(i = 0; i < n; i++) { - if((temp = data[n])) + if((temp = data[i])) { den += temp; - if(count >= 5) + h = round(freqs[i] / fund); + if(h >= 5) num += temp; - count++; } } -- cgit v1.2.3