aboutsummaryrefslogtreecommitdiff
path: root/src/scalar.c
diff options
context:
space:
mode:
authorSean Enderby <sean.enderby@gmail.com>2014-02-25 14:12:29 +0000
committerSean Enderby <sean.enderby@gmail.com>2014-02-25 14:12:29 +0000
commit8fad3a92195af9f58d008ec82c267c7a992456cc (patch)
tree38ae4ff6031899201535736067000510d922fc27 /src/scalar.c
parent1e53c1ea582a5927f8e6d900b2a06165962b77b5 (diff)
downloadLibXtract-8fad3a92195af9f58d008ec82c267c7a992456cc.tar.gz
LibXtract-8fad3a92195af9f58d008ec82c267c7a992456cc.tar.bz2
LibXtract-8fad3a92195af9f58d008ec82c267c7a992456cc.zip
tristimulus3 correction
Diffstat (limited to 'src/scalar.c')
-rw-r--r--src/scalar.c18
1 files changed, 9 insertions, 9 deletions
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++;
}
}