aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2008-05-04 11:02:40 +0000
committerJamie Bullock <jamie@postlude.co.uk>2008-05-04 11:02:40 +0000
commit6a4be601746f6a84fc70434a61b16bea86b6c147 (patch)
treefd8e8bfac0e6846f848a38490d583f4bfa7f6a6e
parentd817fc9b42b0c04d6452159ca63f5a30834f5489 (diff)
downloadLibXtract-6a4be601746f6a84fc70434a61b16bea86b6c147.tar.gz
LibXtract-6a4be601746f6a84fc70434a61b16bea86b6c147.tar.bz2
LibXtract-6a4be601746f6a84fc70434a61b16bea86b6c147.zip
Fixed bug in peak interpolation algorithm in xtract_peak_spectrum()
-rw-r--r--src/delta.c1
-rw-r--r--src/scalar.c2
-rw-r--r--src/vector.c2
-rw-r--r--xtract/xtract_delta.h1
-rw-r--r--xtract/xtract_scalar.h2
5 files changed, 7 insertions, 1 deletions
diff --git a/src/delta.c b/src/delta.c
index 25d380b..b1effd0 100644
--- a/src/delta.c
+++ b/src/delta.c
@@ -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);
}
diff --git a/src/scalar.c b/src/scalar.c
index 4a2b672..d2bc317 100644
--- a/src/scalar.c
+++ b/src/scalar.c
@@ -434,6 +434,8 @@ int xtract_spread(const float *data, const int N, const void *argv, float *resul
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;
diff --git a/src/vector.c b/src/vector.c
index 449cd0d..b891111 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -436,7 +436,7 @@ int xtract_peak_spectrum(const float *data, const int N, const void *argv, float
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;
diff --git a/xtract/xtract_delta.h b/xtract/xtract_delta.h
index 6e19708..152a891 100644
--- a/xtract/xtract_delta.h
+++ b/xtract/xtract_delta.h
@@ -39,6 +39,7 @@ extern "C" {
/** \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);
diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h
index 9bccb01..fdfb42a 100644
--- a/xtract/xtract_scalar.h
+++ b/xtract/xtract_scalar.h
@@ -394,6 +394,8 @@ int xtract_hps(const float *data, const int N, const void *argv, float *result);
* \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);