aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scalar.c14
-rw-r--r--xtract/xtract_scalar.h4
2 files changed, 10 insertions, 8 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;
}
diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h
index e18aea6..48b8f9e 100644
--- a/xtract/xtract_scalar.h
+++ b/xtract/xtract_scalar.h
@@ -324,9 +324,9 @@ int xtract_power(const double *data, const int N, const void *argv, double *resu
/* Odd to even harmonic ratio */
/** \brief Extract the Odd to even harmonic ratio of an input vector
*
- * \param *data: a pointer to the first element in an array of doubles representing the amplitudes of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to the first half of the array pointed to by *result from xtract_harmonic_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the amplitudes of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to array pointed to by *result from xtract_harmonic_spectrum().
* \param N: the number of elements to be considered. If using the array pointed to by *result from xtract_harmonics, N should equal half the total array size i.e., just the amplitudes of the peaks.
- * \param *argv: a pointer to NULL
+ * \param *argv: a pointer to a double representing the fundamental frequency of the input vector.
* \param *result: the even/odd harmonic ratio of N values from the array pointed to by *data
*/
int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result);