Mercurial > hg > libxtract
changeset 117:2b2d0609e44f
Fixed bug in peak interpolation algorithm in xtract_peak_spectrum()
author | Jamie Bullock <jamie@postlude.co.uk> |
---|---|
date | Sun, 04 May 2008 11:02:40 +0000 |
parents | 859495925633 |
children | 8c8b508dcc95 |
files | src/delta.c src/scalar.c src/vector.c xtract/xtract_delta.h xtract/xtract_scalar.h |
diffstat | 5 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/delta.c Wed Mar 26 13:04:33 2008 +0000 +++ b/src/delta.c Sun May 04 11:02:40 2008 +0000 @@ -26,6 +26,7 @@ int xtract_flux(const float *data, const int N, const void *argv , float *result){ + /* FIX: don't be lazy -- take the lnorm of the difference vector! */ return xtract_lnorm(data, N, argv, result); }
--- a/src/scalar.c Wed Mar 26 13:04:33 2008 +0000 +++ b/src/scalar.c Sun May 04 11:02:40 2008 +0000 @@ -434,6 +434,8 @@ den += data[n]; } + /* FIX: spectral spread is mathematically equivalent to spectral variance -- + * here we are computing the spectral standard deviation */ *result = sqrtf(num / den); return XTRACT_SUCCESS;
--- a/src/vector.c Wed Mar 26 13:04:33 2008 +0000 +++ b/src/vector.c Sun May 04 11:02:40 2008 +0000 @@ -436,7 +436,7 @@ for(n = 1; n < N; n++){ if(input[n] >= threshold){ if(input[n] > input[n - 1] && input[n] > input[n + 1]){ - result[N + n] = q * (n + (p = .5 * (y = input[n-1] - + result[N + n] = q * (n + (p = .5 * ((y = input[n-1]) - (y3 = input[n+1])) / (input[n - 1] - 2 * (y2 = input[n]) + input[n + 1]))); result[n] = y2 - .25 * (y - y3) * p;
--- a/xtract/xtract_delta.h Wed Mar 26 13:04:33 2008 +0000 +++ b/xtract/xtract_delta.h Sun May 04 11:02:40 2008 +0000 @@ -39,6 +39,7 @@ /** \brief Extract flux * + * \note FIX: don't be lazy -- take the lnorm of the difference vector! * An alias for xtract_lnorm() */ int xtract_flux(const float *data, const int N, const void *argv , float *result);
--- a/xtract/xtract_scalar.h Wed Mar 26 13:04:33 2008 +0000 +++ b/xtract/xtract_scalar.h Sun May 04 11:02:40 2008 +0000 @@ -394,6 +394,8 @@ * \param *result: the pitch of N values from the array pointed to by *data * * This algorithm is based on the AMDF, with peak and centre clipping. It would benefit from further improvements to improve noise robustness and overall efficiency + * + * It is based on suggestion by Robert Bristow-Johnson in a discussion on the comp.dsp mailing list, subject "Reference implementation of pitch detection" * */ int xtract_f0(const float *data, const int N, const void *argv, float *result);