Mercurial > hg > libxtract
comparison src/scalar.c @ 229:a2f66a305e53
tristimulus3 correction
author | Sean Enderby <sean.enderby@gmail.com> |
---|---|
date | Tue, 25 Feb 2014 14:12:29 +0000 |
parents | cccd314664ac |
children | b786a835df59 |
comparison
equal
deleted
inserted
replaced
228:cccd314664ac | 229:a2f66a305e53 |
---|---|
484 | 484 |
485 } | 485 } |
486 | 486 |
487 int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result) | 487 int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result) |
488 { | 488 { |
489 | 489 int n = N >> 1, h = 0, i; |
490 int n = N, count = 0; | 490 double den = 0.0, num = 0.0, fund = 0.0, temp = 0.0; |
491 | 491 const double *freqs; |
492 double den, num, temp; | 492 |
493 | 493 fund = *(double *)argv; |
494 den = num = temp = 0.0; | 494 freqs = data + n; |
495 | 495 |
496 for(n = 0; n < N; n++) | 496 for(i = 0; i < n; i++) |
497 { | 497 { |
498 if((temp = data[n])) | 498 if((temp = data[i])) |
499 { | 499 { |
500 den += temp; | 500 den += temp; |
501 if(count >= 5) | 501 h = round(freqs[i] / fund); |
502 if(h >= 5) | |
502 num += temp; | 503 num += temp; |
503 count++; | |
504 } | 504 } |
505 } | 505 } |
506 | 506 |
507 if(den == 0.0 || num == 0.0) | 507 if(den == 0.0 || num == 0.0) |
508 { | 508 { |