diff options
author | Sean Enderby <sean.enderby@gmail.com> | 2014-02-24 14:32:04 +0000 |
---|---|---|
committer | Sean Enderby <sean.enderby@gmail.com> | 2014-02-24 14:32:04 +0000 |
commit | 2b976e4bce32413fc3e76dc81a48178f4d871270 (patch) | |
tree | d2100c69124eece8ec5c1811144ecdaacee82469 /src | |
parent | f0e868fcf448ca3b546d318ff59f6dab12156279 (diff) | |
download | LibXtract-2b976e4bce32413fc3e76dc81a48178f4d871270.tar.gz LibXtract-2b976e4bce32413fc3e76dc81a48178f4d871270.tar.bz2 LibXtract-2b976e4bce32413fc3e76dc81a48178f4d871270.zip |
correction to xtract_odd_even_ratio
Diffstat (limited to 'src')
-rw-r--r-- | src/scalar.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/scalar.c b/src/scalar.c index 47d3a8f..3a9abdf 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -622,7 +622,6 @@ int xtract_rms_amplitude(const double *data, const int N, const void *argv, doub int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result) { - int n = N >> 1, h = 0; double num = 0.0, den = 0.0, fund; const double *freqs, *amps; @@ -656,16 +655,19 @@ int xtract_power(const double *data, const int N, const void *argv, double *resu int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result) { + int n = N >> 1, h = 0; + double odd = 0.0, even = 0.0, fund, temp; + const double *freqs; - int M = (N >> 1), n; - - double odd = 0.0, even = 0.0, temp; + fund = *(double *)argv; + freqs = data + n; - for(n = 0; n < M; n++) + while(n--) { if((temp = data[n])) { - if(XTRACT_IS_ODD(n)) + h = round(freqs[n] / fund); + if(XTRACT_IS_ODD(h)) { odd += temp; } |