diff options
-rw-r--r-- | src/scalar.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/scalar.c b/src/scalar.c index 95b296b..065566e 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -301,8 +301,8 @@ int xtract_irregularity_j(const double *data, const int N, const void *argv, dou int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result) { - int n = N >> 1, h = 0, i; - double den = 0.0, p1 = 0.0, fund = 0.0, temp = 0.0; + int n = N >> 1, i; + double den = 0.0, p1 = 0.0, fund = 0.0, temp = 0.0, h = 0.0; const double *freqs; fund = *(double *)argv; @@ -314,7 +314,7 @@ int xtract_tristimulus_1(const double *data, const int N, const void *argv, doub { den += temp; h = floor(freqs[i] / fund + 0.5); - if(h == 1) + if(h > 0 && h < 2 && (int)h == 1) p1 += temp; } } @@ -333,10 +333,9 @@ int xtract_tristimulus_1(const double *data, const int N, const void *argv, doub int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result) { - - int n = N >> 1, h = 0, i; - double den, p2, p3, p4, ps, fund, temp; - den = p2 = p3 = p4 = ps = fund = temp = 0.0; + int n = N >> 1, i; + double den, p2, p3, p4, ps, fund, temp, h; + den = p2 = p3 = p4 = ps = fund = temp = h = 0.0; const double *freqs; fund = *(double *)argv; @@ -348,21 +347,24 @@ int xtract_tristimulus_2(const double *data, const int N, const void *argv, doub { den += temp; h = floor(freqs[i] / fund + 0.5); - switch (h) + if (h > 1 && h < 5) { - case 2: - p2 += temp; + switch ((int)h) + { + case 2: + p2 += temp; break; - case 3: - p3 += temp; + case 3: + p3 += temp; break; - case 4: - p4 += temp; + case 4: + p4 += temp; - default: - break; + default: + break; + } } } } @@ -384,8 +386,8 @@ 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; + int n = N >> 1, i; + double den = 0.0, num = 0.0, fund = 0.0, temp = 0.0, h = 0.0; const double *freqs; fund = *(double *)argv; |