aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/MSP/xtract~.c41
-rw-r--r--examples/puredata/xtract~.c38
-rw-r--r--examples/simpletest/simpletest.c26
-rw-r--r--src/delta.c28
-rw-r--r--src/descriptors.c44
-rw-r--r--src/helper.c12
-rw-r--r--src/init.c26
-rw-r--r--src/libxtract.c2
-rw-r--r--src/scalar.c387
-rw-r--r--src/vector.c162
-rw-r--r--src/window.c96
-rw-r--r--src/xtract_window_private.h18
-rw-r--r--xtract/libxtract.h34
-rw-r--r--xtract/xtract_delta.h18
-rw-r--r--xtract/xtract_helper.h8
-rw-r--r--xtract/xtract_scalar.h184
-rw-r--r--xtract/xtract_types.h4
-rw-r--r--xtract/xtract_vector.h50
18 files changed, 567 insertions, 611 deletions
diff --git a/examples/MSP/xtract~.c b/examples/MSP/xtract~.c
index 3e50de0..e46ec6a 100644
--- a/examples/MSP/xtract~.c
+++ b/examples/MSP/xtract~.c
@@ -51,6 +51,8 @@ typedef struct _xtract {
t_int feature_type;
tracked_memory memory;
void *argv;
+ double *data;
+ double *result;
} t_xtract_tilde;
static t_int *xtract_perform(t_int *w) {
@@ -58,9 +60,13 @@ static t_int *xtract_perform(t_int *w) {
t_xtract_tilde *x = (t_xtract_tilde *)(w[2]);
t_int N = (t_int)(w[3]);
t_int return_code = 0;
- float result = 0.f;
+ double result = 0.f;
- return_code = xtract[x->feature]((float *)in, N, x->argv, &result);
+ for(n = 0; n < N; ++n){
+ x->data[n] = (double)in[n];
+ }
+
+ return_code = xtract[x->feature](x->data, N, x->argv, &result);
if(return_code == XTRACT_FEATURE_NOT_IMPLEMENTED)
perror("Feature not implemented");
@@ -68,14 +74,13 @@ static t_int *xtract_perform(t_int *w) {
/* set nan, inf or -inf to 0 */
result = (isinf(result) || isnan(result) ? 0 : result);
- outlet_float(x->outlet, result);
+ outlet_float(x->outlet, (float)result);
return (w+4);
}
static t_int *xtract_perform_vector(t_int *w) {
t_sample *in = (t_float *)(w[1]);
t_sample *out = (t_float *)(w[2]);
- float *temp_in, *temp_out;
t_xtract_tilde *x = (t_xtract_tilde *)(w[3]);
t_int N = (t_int)(w[4]), n;
t_int return_code = 0;
@@ -87,28 +92,20 @@ static t_int *xtract_perform_vector(t_int *w) {
post("xtract~ %s: Blocksize mismatch, try specifying the blocksize as a second argument", x->feature_name->s_name);
return (w+5);
}
-
- n = N;
- temp_in = (float *)getbytes(N * sizeof(float));
- temp_out= (float *)getbytes(N * sizeof(float));
-
- while(n--)
- temp_in[n] = in[n];
+ for(n = 0; n < N; ++n){
+ x->data[n] = (double)in[n];
+ }
- n = N;
+ return_code = xtract[x->feature](x->data, N, x->argv, x->result);
- return_code = xtract[x->feature](temp_in, N, x->argv, temp_out);
-
- while(n--)
- out[n] = temp_out[n];
+ for(n = 0; n < N; ++n){
+ out[n] = (float)x->result[n];
+ }
if(return_code == XTRACT_FEATURE_NOT_IMPLEMENTED)
perror("Feature not implemented");
- freebytes(temp_in, sizeof(float) * N);
- freebytes(temp_out, sizeof(float) * N);
-
return (w+5);
}
@@ -144,6 +141,10 @@ static void *xtract_tilde_new(t_symbol *me, t_int argc, t_atom *argv) {
x->argv = NULL;
x->done_init = 0;
+
+ x->data = (double *)getbytes(N * sizeof(double));
+ x->result = (double *)getbytes(N * sizeof(double));
+
if(argc)
tmp = argv[0].a_w.w_sym; /*atom_getsymbol(argv); */
@@ -312,6 +313,8 @@ static void xtract_tilde_free(t_xtract_tilde *x) {
if(x->argv != NULL && x->memory.argv)
freebytes(x->argv, x->memory.argv);
+ freebytes(x->data);
+ freebytes(x->result);
}
int main(void) {
diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c
index 2223bc7..8ec1c15 100644
--- a/examples/puredata/xtract~.c
+++ b/examples/puredata/xtract~.c
@@ -51,7 +51,9 @@ typedef struct _tracked_memory {
typedef struct _xtract {
t_object x_obj;
t_float f;
- t_float *window;
+ double *window;
+ double *data;
+ double *result;
t_int feature,
is_scalar,
is_subframe,
@@ -68,17 +70,21 @@ static t_int *xtract_perform(t_int *w) {
t_xtract_tilde *x = (t_xtract_tilde *)(w[2]);
t_int N = (t_int)(w[3]);
t_int rv = 0;
- float result = 0;
+ double result = 0.0;
- rv = xtract[x->feature]((float *)in, N, x->argv, &result);
+ for(n = 0; n < N; ++n) {
+ x->data[n] = (double)in[n];
+ }
+
+ rv = xtract[x->feature](x->data, N, x->argv, &result);
if(rv == XTRACT_FEATURE_NOT_IMPLEMENTED)
pd_error(x, "Feature not implemented");
/* set nan, inf or -inf to 0 */
- result = (isinf(result) || isnan(result) ? 0 : result);
+ result = (isinf(result) || isnan(result) ? 0.0 : result);
- outlet_float(x->x_obj.ob_outlet, result);
+ outlet_float(x->x_obj.ob_outlet, (float)result);
return (w+4);
}
@@ -86,7 +92,6 @@ static t_int *xtract_perform_vector(t_int *w) {
t_sample *in = (t_sample *)(w[1]);
t_sample *out = (t_sample *)(w[2]);
- t_float *tmp_in, *tmp_out;
t_xtract_tilde *x = (t_xtract_tilde *)(w[3]);
t_int N = (t_int)(w[4]), n;
t_int rv = 0;
@@ -98,31 +103,28 @@ static t_int *xtract_perform_vector(t_int *w) {
n = N;
- tmp_in = copybytes(in, N * sizeof(t_float));
- tmp_out = getbytes(N * sizeof(t_float));
+ for(n = 0; n < N; ++n) {
+ x->data[n] = (double)in[n];
+ }
if(x->feature == XTRACT_PEAK_SPECTRUM || x->feature == XTRACT_LPC)
N >>= 1;
if(x->is_subframe){
- rv = xtract_features_from_subframes(tmp_in, N, x->feature,
- x->argv, tmp_out);
+ rv = xtract_features_from_subframes(x->data, N, x->feature,
+ x->argv, x->result);
}
else{
- rv = xtract[x->feature](tmp_in, N, x->argv, tmp_out);
-
+ rv = xtract[x->feature](x->data, N, x->argv, x->result);
}
if(rv == XTRACT_FEATURE_NOT_IMPLEMENTED)
pd_error(x, "Feature not implemented");
while(n--)
- out[n] = tmp_out[n];
-
- freebytes(tmp_in, N * sizeof(t_float));
- freebytes(tmp_out, N * sizeof(t_float));
+ out[n] = (float)x->result[n];
return (w+5);
}
@@ -169,6 +171,10 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) {
x->is_subframe = 0;
x->feature = -1;
+ /* Allocate data area */
+ x->data = (double *)getbytes(N * sizeof(double));
+ x->result = (double *)getbytes(N * sizeof(double));
+
/* Parse arguments */
if(argc){
arg1 = atom_getsymbol(argv);
diff --git a/examples/simpletest/simpletest.c b/examples/simpletest/simpletest.c
index 33290c3..7b6cb22 100644
--- a/examples/simpletest/simpletest.c
+++ b/examples/simpletest/simpletest.c
@@ -35,18 +35,18 @@
int main(void)
{
- float mean = 0.f;
- float input[BLOCKSIZE];
- float spectrum[BLOCKSIZE];
- float mfccs[MFCC_FREQ_BANDS * sizeof(float)];
- float argf[4];
+ double mean = 0.f;
+ double input[BLOCKSIZE];
+ double spectrum[BLOCKSIZE];
+ double mfccs[MFCC_FREQ_BANDS * sizeof(double)];
+ double argd[4];
int n;
xtract_mel_filter mel_filters;
/* fill the input array with a sawtooth wave */
for(n = 0; n < BLOCKSIZE; ++n)
{
- input[n] = ((n % PERIOD) / (float)PERIOD) - .5;
+ input[n] = ((n % PERIOD) / (double)PERIOD) - .5;
}
/* get the mean of the input */
@@ -54,13 +54,13 @@ int main(void)
printf("\nInput mean = %.2f\n\n", mean);
/* get the spectrum */
- argf[0] = SAMPLERATE / (float)BLOCKSIZE;
- argf[1] = XTRACT_MAGNITUDE_SPECTRUM;
- argf[2] = 0.f; /* No DC component */
- argf[3] = 0.f; /* No Normalisation */
+ argd[0] = SAMPLERATE / (double)BLOCKSIZE;
+ argd[1] = XTRACT_MAGNITUDE_SPECTRUM;
+ argd[2] = 0.f; /* No DC component */
+ argd[3] = 0.f; /* No Normalisation */
xtract_init_fft(BLOCKSIZE, XTRACT_SPECTRUM);
- xtract[XTRACT_SPECTRUM]((void *)&input, BLOCKSIZE, &argf[0], (void *)&spectrum[0]);
+ xtract[XTRACT_SPECTRUM]((void *)&input, BLOCKSIZE, &argd[0], (void *)&spectrum[0]);
/* print the spectral bins */
printf("\nSpectral bins:\n");
@@ -71,10 +71,10 @@ int main(void)
/* compute the MFCCs */
mel_filters.n_filters = MFCC_FREQ_BANDS;
- mel_filters.filters = malloc(MFCC_FREQ_BANDS * sizeof(float *));
+ mel_filters.filters = malloc(MFCC_FREQ_BANDS * sizeof(double *));
for(n = 0; n < MFCC_FREQ_BANDS; ++n)
{
- mel_filters.filters[n] = malloc(BLOCKSIZE * sizeof(float));
+ mel_filters.filters[n] = malloc(BLOCKSIZE * sizeof(double));
}
xtract_init_mfcc(BLOCKSIZE >> 1, SAMPLERATE >> 1, XTRACT_EQUAL_GAIN, MFCC_FREQ_MIN, MFCC_FREQ_MAX, mel_filters.n_filters, mel_filters.filters);
diff --git a/src/delta.c b/src/delta.c
index eea91d2..8e6f611 100644
--- a/src/delta.c
+++ b/src/delta.c
@@ -27,7 +27,7 @@
#include "xtract/libxtract.h"
-int xtract_flux(const float *data, const int N, const void *argv , float *result)
+int xtract_flux(const double *data, const int N, const void *argv , double *result)
{
/* FIX: don't be lazy -- take the lnorm of the difference vector! */
@@ -35,20 +35,20 @@ int xtract_flux(const float *data, const int N, const void *argv , float *result
}
-int xtract_lnorm(const float *data, const int N, const void *argv , float *result)
+int xtract_lnorm(const double *data, const int N, const void *argv , double *result)
{
int n,
type;
- float order;
+ double order;
- order = *(float *)argv;
- type = *((float *)argv+1);
+ order = *(double *)argv;
+ type = *((double *)argv+1);
- order = order > 0 ? order : 2.f;
+ order = order > 0 ? order : 2.0;
- *result = 0.f;
+ *result = 0.0;
switch(type)
{
@@ -57,40 +57,40 @@ int xtract_lnorm(const float *data, const int N, const void *argv , float *resul
for(n = 0; n < N; n++)
{
if(data[n] > 0)
- *result += powf(data[n], order);
+ *result += pow(data[n], order);
}
break;
default:
for(n = 0; n < N; n++)
- *result += powf(data[n], order);
+ *result += pow(data[n], order);
break;
}
- *result = powf(*result, 1.f / order);
+ *result = pow(*result, 1.0 / order);
return XTRACT_SUCCESS;
}
-int xtract_attack_time(const float *data, const int N, const void *argv , float *result)
+int xtract_attack_time(const double *data, const int N, const void *argv , double *result)
{
return XTRACT_FEATURE_NOT_IMPLEMENTED;
}
-int xtract_decay_time(const float *data, const int N, const void *argv, float *result)
+int xtract_decay_time(const double *data, const int N, const void *argv, double *result)
{
return XTRACT_FEATURE_NOT_IMPLEMENTED;
}
-int xtract_difference_vector(const float *data, const int N, const void *argv, float *result)
+int xtract_difference_vector(const double *data, const int N, const void *argv, double *result)
{
- const float *frame1,
+ const double *frame1,
*frame2;
int n;
diff --git a/src/descriptors.c b/src/descriptors.c
index 6fe7942..15b790b 100644
--- a/src/descriptors.c
+++ b/src/descriptors.c
@@ -32,7 +32,7 @@ xtract_function_descriptor_t *xtract_make_descriptors(void)
int f , F;
char *name, *p_name, *desc, *p_desc, *author;
- float *argv_min, *argv_max, *argv_def, *result_min, *result_max;
+ double *argv_min, *argv_max, *argv_def, *result_min, *result_max;
int *argc, *year, *argv_donor;
xtract_vector_t *data_format, *result_format;
xtract_unit_t *data_unit, *argv_unit, *result_unit;
@@ -80,8 +80,8 @@ xtract_function_descriptor_t *xtract_make_descriptors(void)
*argv_unit = XTRACT_DBFS;
break;
case XTRACT_SPECTRAL_INHARMONICITY:
- *argv_min = 0.f;
- *argv_max = XTRACT_SR_UPPER_LIMIT / 2;
+ *argv_min = 0.0;
+ *argv_max = XTRACT_SR_UPPER_LIMIT / 2.0;
*argv_def = XTRACT_FUNDAMENTAL_DEFAULT;
*argv_unit = XTRACT_HERTZ;
break;
@@ -104,29 +104,29 @@ xtract_function_descriptor_t *xtract_make_descriptors(void)
*argv_max = XTRACT_FFT_BANDS_MAX;
*argv_def = XTRACT_SPEC_BW_DEF ;
*argv_unit = XTRACT_HERTZ;
- *(argv_min + 1) = 0.f;
- *(argv_max + 1) = 100.f;
- *(argv_def + 1) = 95.f;
+ *(argv_min + 1) = 0.0;
+ *(argv_max + 1) = 100.0;
+ *(argv_def + 1) = 95.0;
*(argv_unit + 1) = XTRACT_PERCENT;
break;
case XTRACT_PEAK_SPECTRUM:
- *argv_min = XTRACT_SR_LOWER_LIMIT / 2;
- *argv_max = XTRACT_SR_UPPER_LIMIT / 2;
- *argv_def = XTRACT_SR_DEFAULT / 2;
+ *argv_min = XTRACT_SR_LOWER_LIMIT / 2.0;
+ *argv_max = XTRACT_SR_UPPER_LIMIT / 2.0;
+ *argv_def = XTRACT_SR_DEFAULT / 2.0;
*argv_unit = XTRACT_HERTZ;
- *(argv_min + 1) = 0.f;
- *(argv_max + 1) = 100.f ;
- *(argv_def + 1) = 10.f ;
+ *(argv_min + 1) = 0.0;
+ *(argv_max + 1) = 100.0 ;
+ *(argv_def + 1) = 10.0 ;
*(argv_unit + 1) = XTRACT_PERCENT;
break;
case XTRACT_HARMONIC_SPECTRUM:
- *argv_min = 0.f;
- *argv_max = XTRACT_SR_UPPER_LIMIT / 2;
+ *argv_min = 0.0;
+ *argv_max = XTRACT_SR_UPPER_LIMIT / 2.0;
*argv_def = XTRACT_FUNDAMENTAL_DEFAULT;
*argv_unit = XTRACT_HERTZ;
- *(argv_min + 1) = 0.f;
- *(argv_max + 1) = 1.f ;
- *(argv_def + 1) = .1f ;
+ *(argv_min + 1) = 0.0;
+ *(argv_max + 1) = 1.0 ;
+ *(argv_def + 1) = .1 ;
*(argv_unit + 1) = XTRACT_NONE;
break;
case XTRACT_NOISINESS:
@@ -1251,18 +1251,18 @@ xtract_function_descriptor_t *xtract_make_descriptors(void)
case XTRACT_HPS:
case XTRACT_ROLLOFF:
*result_unit = XTRACT_HERTZ;
- *result_min = 0.f;
- *result_max = XTRACT_SR_UPPER_LIMIT / 2;
+ *result_min = 0.0;
+ *result_max = XTRACT_SR_UPPER_LIMIT / 2.0;
break;
case XTRACT_ZCR:
*result_unit = XTRACT_HERTZ;
- *result_min = 0.f;
+ *result_min = 0.0;
*result_max = XTRACT_ANY;
break;
case XTRACT_ODD_EVEN_RATIO:
*result_unit = XTRACT_NONE;
- *result_min = 0.f;
- *result_max = 1.f;
+ *result_min = 0.0;
+ *result_max = 1.0;
break;
case XTRACT_FLATNESS_DB:
*result_unit = XTRACT_DBFS;
diff --git a/src/helper.c b/src/helper.c
index 2a050e9..de33ffa 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -35,14 +35,14 @@
#define INDEX 1
#endif
-int xtract_windowed(const float *data, const int N, const void *argv, float *result)
+int xtract_windowed(const double *data, const int N, const void *argv, double *result)
{
int n;
- const float *window;
+ const double *window;
n = N;
- window = (const float *)argv;
+ window = (const double *)argv;
while(n--)
result[n] = data[n] * window[n];
@@ -51,12 +51,12 @@ int xtract_windowed(const float *data, const int N, const void *argv, float *res
}
-int xtract_features_from_subframes(const float *data, const int N, const int feature, const void *argv, float *result)
+int xtract_features_from_subframes(const double *data, const int N, const int feature, const void *argv, double *result)
{
- const float *frame1,
+ const double *frame1,
*frame2;
- float *result1,
+ double *result1,
*result2;
int n, rv;
diff --git a/src/init.c b/src/init.c
index 7b932da..87f8caf 100644
--- a/src/init.c
+++ b/src/init.c
@@ -39,11 +39,11 @@
#include "xtract_globals_private.h"
-int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables)
+int xtract_init_mfcc(int N, double nyquist, int style, double freq_min, double freq_max, int freq_bands, double **fft_tables)
{
int n, i, k, *fft_peak, M, next_peak;
- float norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
+ double norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
freq_bw_mel, *mel_peak, *height_norm, *lin_peak;
mel_peak = height_norm = lin_peak = NULL;
@@ -54,11 +54,11 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq
mel_freq_min = 1127 * log(1 + freq_min / 700);
freq_bw_mel = (mel_freq_max - mel_freq_min) / freq_bands;
- mel_peak = (float *)malloc((freq_bands + 2) * sizeof(float));
+ mel_peak = (double *)malloc((freq_bands + 2) * sizeof(double));
/* +2 for zeros at start and end */
- lin_peak = (float *)malloc((freq_bands + 2) * sizeof(float));
+ lin_peak = (double *)malloc((freq_bands + 2) * sizeof(double));
fft_peak = (int *)malloc((freq_bands + 2) * sizeof(int));
- height_norm = (float *)malloc(freq_bands * sizeof(float));
+ height_norm = (double *)malloc(freq_bands * sizeof(double));
if(mel_peak == NULL || height_norm == NULL ||
lin_peak == NULL || fft_peak == NULL)
@@ -109,7 +109,7 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq
// zero the start of the array
for(k = 0; k < i; k++)
- fft_tables[n][k] = 0.f;
+ fft_tables[n][k] = 0.0;
// fill in the rise
for(; i <= fft_peak[n]; i++)
@@ -133,7 +133,7 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq
// zero the rest of the array
for(k = next_peak + 1; k < N; k++)
- fft_tables[n][k] = 0.f;
+ fft_tables[n][k] = 0.0;
}
@@ -239,10 +239,10 @@ void xtract_free_fft(void)
}
}
-int xtract_init_bark(int N, float sr, int *band_limits)
+int xtract_init_bark(int N, double sr, int *band_limits)
{
- float edges[] = {0, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, 20500, 27000}; /* Takes us up to sr = 54kHz (CCRMA: JOS)*/
+ double edges[] = {0, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, 20500, 27000}; /* Takes us up to sr = 54kHz (CCRMA: JOS)*/
int bands = XTRACT_BARK_BANDS;
@@ -253,11 +253,11 @@ int xtract_init_bark(int N, float sr, int *band_limits)
return XTRACT_SUCCESS;
}
-float *xtract_init_window(const int N, const int type)
+double *xtract_init_window(const int N, const int type)
{
- float *window;
+ double *window;
- window = malloc(N * sizeof(float));
+ window = malloc(N * sizeof(double));
switch (type)
{
@@ -296,7 +296,7 @@ float *xtract_init_window(const int N, const int type)
return window;
}
-void xtract_free_window(float *window)
+void xtract_free_window(double *window)
{
free(window);
}
diff --git a/src/libxtract.c b/src/libxtract.c
index 43a7d16..3bc744e 100644
--- a/src/libxtract.c
+++ b/src/libxtract.c
@@ -24,7 +24,7 @@
#include "xtract/libxtract.h"
#define XTRACT_H
-int(*xtract[])(const float *, const int, const void *, float *) =
+int(*xtract[])(const double *, const int, const void *, double *) =
{
/* xtract_scalar.h */
xtract_mean,
diff --git a/src/scalar.c b/src/scalar.c
index 1ef3839..80f0058 100644
--- a/src/scalar.c
+++ b/src/scalar.c
@@ -34,37 +34,12 @@
#include "xtract/xtract_helper.h"
#include "xtract_macros_private.h"
-#ifndef powf
-#define powf pow
-#endif
-
-#ifndef expf
-#define expf exp
-#endif
-
-#ifndef sqrtf
-#define sqrtf sqrt
-#endif
-
-#ifndef fabsf
-#define fabsf fabs
-#endif
-
-
-void test(void)
-{
- printf("Hello world\n");
-#ifdef WORDS_BIGENDIAN
- printf("Big endian!\n");
-#endif
-}
-
-int xtract_mean(const float *data, const int N, const void *argv, float *result)
+int xtract_mean(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- *result = 0.f;
+ *result = 0.0;
while(n--)
*result += data[n];
@@ -74,57 +49,57 @@ int xtract_mean(const float *data, const int N, const void *argv, float *result)
return XTRACT_SUCCESS;
}
-int xtract_variance(const float *data, const int N, const void *argv, float *result)
+int xtract_variance(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- *result = 0.f;
+ *result = 0.0;
while(n--)
- *result += powf(data[n] - *(float *)argv, 2);
+ *result += pow(data[n] - *(double *)argv, 2);
*result = *result / (N - 1);
return XTRACT_SUCCESS;
}
-int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result)
+int xtract_standard_deviation(const double *data, const int N, const void *argv, double *result)
{
- *result = sqrtf(*(float *)argv);
+ *result = sqrt(*(double *)argv);
return XTRACT_SUCCESS;
}
-int xtract_average_deviation(const float *data, const int N, const void *argv, float *result)
+int xtract_average_deviation(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- *result = 0.f;
+ *result = 0.0;
while(n--)
- *result += fabsf(data[n] - *(float *)argv);
+ *result += fabs(data[n] - *(double *)argv);
*result /= N;
return XTRACT_SUCCESS;
}
-int xtract_skewness(const float *data, const int N, const void *argv, float *result)
+int xtract_skewness(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- float temp = 0.f;
+ double temp = 0.0;
- *result = 0.f;
+ *result = 0.0;
while(n--)
{
- temp = (data[n] - ((float *)argv)[0]) / ((float *)argv)[1];
- *result += powf(temp, 3);
+ temp = (data[n] - ((double *)argv)[0]) / ((double *)argv)[1];
+ *result += pow(temp, 3);
}
*result /= N;
@@ -133,34 +108,34 @@ int xtract_skewness(const float *data, const int N, const void *argv, float *re
return XTRACT_SUCCESS;
}
-int xtract_kurtosis(const float *data, const int N, const void *argv, float *result)
+int xtract_kurtosis(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- float temp = 0.f;
+ double temp = 0.0;
- *result = 0.f;
+ *result = 0.0;
while(n--)
{
- temp = (data[n] - ((float *)argv)[0]) / ((float *)argv)[1];
- *result += powf(temp, 4);
+ temp = (data[n] - ((double *)argv)[0]) / ((double *)argv)[1];
+ *result += pow(temp, 4);
}
*result /= N;
- *result -= 3.0f;
+ *result -= 3.0;
return XTRACT_SUCCESS;
}
-int xtract_spectral_centroid(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_centroid(const double *data, const int N, const void *argv, double *result)
{
int n = (N >> 1);
- const float *freqs, *amps;
- float FA = 0.f, A = 0.f;
+ const double *freqs, *amps;
+ double FA = 0.0, A = 0.0;
amps = data;
freqs = data + n;
@@ -171,39 +146,39 @@ int xtract_spectral_centroid(const float *data, const int N, const void *argv,
A += amps[n];
}
- if(A == 0.f)
- *result = 0.f;
+ if(A == 0.0)
+ *result = 0.0;
else
*result = FA / A;
return XTRACT_SUCCESS;
}
-int xtract_spectral_mean(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_mean(const double *data, const int N, const void *argv, double *result)
{
return xtract_spectral_centroid(data, N, argv, result);
}
-int xtract_spectral_variance(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_variance(const double *data, const int N, const void *argv, double *result)
{
int m;
- float A = 0.f;
- const float *freqs, *amps;
+ double A = 0.0;
+ const double *freqs, *amps;
m = N >> 1;
amps = data;
freqs = data + m;
- *result = 0.f;
+ *result = 0.0;
while(m--)
{
A += amps[m];
- *result += powf(freqs[m] - ((float *)argv)[0], 2) * amps[m];
+ *result += pow(freqs[m] - ((double *)argv)[0], 2) * amps[m];
}
*result = *result / A;
@@ -211,30 +186,30 @@ int xtract_spectral_variance(const float *data, const int N, const void *argv, f
return XTRACT_SUCCESS;
}
-int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_standard_deviation(const double *data, const int N, const void *argv, double *result)
{
- *result = sqrtf(*(float *)argv);
+ *result = sqrt(*(double *)argv);
return XTRACT_SUCCESS;
}
-/*int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result){
+/*int xtract_spectral_average_deviation(const double *data, const int N, const void *argv, double *result){
int m;
- float A = 0.f;
- const float *freqs, *amps;
+ double A = 0.0;
+ const double *freqs, *amps;
m = N >> 1;
amps = data;
freqs = data + m;
- *result = 0.f;
+ *result = 0.0;
while(m--){
A += amps[m];
- *result += fabsf((amps[m] * freqs[m]) - *(float *)argv);
+ *result += fabs((amps[m] * freqs[m]) - *(double *)argv);
}
*result /= A;
@@ -242,89 +217,89 @@ int xtract_spectral_standard_deviation(const float *data, const int N, const voi
return XTRACT_SUCCESS;
}*/
-int xtract_spectral_skewness(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_skewness(const double *data, const int N, const void *argv, double *result)
{
int m;
- const float *freqs, *amps;
+ const double *freqs, *amps;
m = N >> 1;
amps = data;
freqs = data + m;
- *result = 0.f;
+ *result = 0.0;
while(m--)
- *result += powf(freqs[m] - ((float *)argv)[0], 3) * amps[m];
+ *result += pow(freqs[m] - ((double *)argv)[0], 3) * amps[m];
- *result /= powf(((float *)argv)[1], 3);
+ *result /= pow(((double *)argv)[1], 3);
return XTRACT_SUCCESS;
}
-int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_kurtosis(const double *data, const int N, const void *argv, double *result)
{
int m;
- const float *freqs, *amps;
+ const double *freqs, *amps;
m = N >> 1;
amps = data;
freqs = data + m;
- *result = 0.f;
+ *result = 0.0;
while(m--)
- *result += powf(freqs[m] - ((float *)argv)[0], 4) * amps[m];
+ *result += pow(freqs[m] - ((double *)argv)[0], 4) * amps[m];
- *result /= powf(((float *)argv)[1], 4);
- *result -= 3.0f;
+ *result /= pow(((double *)argv)[1], 4);
+ *result -= 3.0;
return XTRACT_SUCCESS;
}
-int xtract_irregularity_k(const float *data, const int N, const void *argv, float *result)
+int xtract_irregularity_k(const double *data, const int N, const void *argv, double *result)
{
int n,
M = N - 1;
- *result = 0.f;
+ *result = 0.0;
for(n = 1; n < M; n++)
- *result += fabsf(data[n] - (data[n-1] + data[n] + data[n+1]) / 3.f);
+ *result += fabs(data[n] - (data[n-1] + data[n] + data[n+1]) / 3.0);
return XTRACT_SUCCESS;
}
-int xtract_irregularity_j(const float *data, const int N, const void *argv, float *result)
+int xtract_irregularity_j(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- double num = 0.f, den = 0.f;
+ double num = 0.0, den = 0.0;
while(n--)
{
- num += powf(data[n] - data[n+1], 2);
- den += powf(data[n], 2);
+ num += pow(data[n] - data[n+1], 2);
+ den += pow(data[n], 2);
}
- *result = (float)(num / den);
+ *result = (double)(num / den);
return XTRACT_SUCCESS;
}
-int xtract_tristimulus_1(const float *data, const int N, const void *argv, float *result)
+int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- float den, p1, temp;
+ double den, p1, temp;
- den = p1 = temp = 0.f;
+ den = p1 = temp = 0.0;
for(n = 0; n < N; n++)
{
@@ -336,9 +311,9 @@ int xtract_tristimulus_1(const float *data, const int N, const void *argv, float
}
}
- if(den == 0.f || p1 == 0.f)
+ if(den == 0.0 || p1 == 0.0)
{
- *result = 0.f;
+ *result = 0.0;
return XTRACT_NO_RESULT;
}
else
@@ -348,14 +323,14 @@ int xtract_tristimulus_1(const float *data, const int N, const void *argv, float
}
}
-int xtract_tristimulus_2(const float *data, const int N, const void *argv, float *result)
+int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- float den, p2, p3, p4, ps, temp;
+ double den, p2, p3, p4, ps, temp;
- den = p2 = p3 = p4 = ps = temp = 0.f;
+ den = p2 = p3 = p4 = ps = temp = 0.0;
for(n = 0; n < N; n++)
{
@@ -373,9 +348,9 @@ int xtract_tristimulus_2(const float *data, const int N, const void *argv, float
ps = p2 + p3 + p4;
- if(den == 0.f || ps == 0.f)
+ if(den == 0.0 || ps == 0.0)
{
- *result = 0.f;
+ *result = 0.0;
return XTRACT_NO_RESULT;
}
else
@@ -386,14 +361,14 @@ int xtract_tristimulus_2(const float *data, const int N, const void *argv, float
}
-int xtract_tristimulus_3(const float *data, const int N, const void *argv, float *result)
+int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result)
{
int n = N, count = 0;
- float den, num, temp;
+ double den, num, temp;
- den = num = temp = 0.f;
+ den = num = temp = 0.0;
for(n = 0; n < N; n++)
{
@@ -406,9 +381,9 @@ int xtract_tristimulus_3(const float *data, const int N, const void *argv, float
}
}
- if(den == 0.f || num == 0.f)
+ if(den == 0.0 || num == 0.0)
{
- *result = 0.f;
+ *result = 0.0;
return XTRACT_NO_RESULT;
}
else
@@ -418,15 +393,15 @@ int xtract_tristimulus_3(const float *data, const int N, const void *argv, float
}
}
-int xtract_smoothness(const float *data, const int N, const void *argv, float *result)
+int xtract_smoothness(const double *data, const int N, const void *argv, double *result)
{
int n, M;
- float *input;
+ double *input;
- input = (float *)malloc(N * sizeof(float));
- memcpy(input, data, N * sizeof(float));
+ input = (double *)malloc(N * sizeof(double));
+ memcpy(input, data, N * sizeof(double));
if (input[0] <= 0)
input[0] = XTRACT_LOG_LIMIT;
@@ -439,8 +414,8 @@ int xtract_smoothness(const float *data, const int N, const void *argv, float *r
{
if(input[n+1] <= 0)
input[n+1] = XTRACT_LOG_LIMIT;
- *result += fabsf(20.f * logf(input[n]) - (20.f * logf(input[n-1]) +
- 20.f * logf(input[n]) + 20.f * logf(input[n+1])) / 3.f);
+ *result += fabs(20.0 * log(input[n]) - (20.0 * log(input[n-1]) +
+ 20.0 * log(input[n]) + 20.0 * log(input[n+1])) / 3.0);
}
free(input);
@@ -448,13 +423,13 @@ int xtract_smoothness(const float *data, const int N, const void *argv, float *r
return XTRACT_SUCCESS;
}
-int xtract_spread(const float *data, const int N, const void *argv, float *result)
+int xtract_spread(const double *data, const int N, const void *argv, double *result)
{
return xtract_spectral_variance(data, N, argv, result);
}
-int xtract_zcr(const float *data, const int N, const void *argv, float *result)
+int xtract_zcr(const double *data, const int N, const void *argv, double *result)
{
int n = N;
@@ -462,39 +437,39 @@ int xtract_zcr(const float *data, const int N, const void *argv, float *result)
for(n = 1; n < N; n++)
if(data[n] * data[n-1] < 0) (*result)++;
- *result /= (float)N;
+ *result /= (double)N;
return XTRACT_SUCCESS;
}
-int xtract_rolloff(const float *data, const int N, const void *argv, float *result)
+int xtract_rolloff(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- float pivot, temp, percentile;
+ double pivot, temp, percentile;
- pivot = temp = 0.f;
- percentile = ((float *)argv)[1];
+ pivot = temp = 0.0;
+ percentile = ((double *)argv)[1];
while(n--) pivot += data[n];
- pivot *= percentile / 100.f;
+ pivot *= percentile / 100.0;
for(n = 0; temp < pivot; n++)
temp += data[n];
- *result = n * ((float *)argv)[0];
- /* *result = (n / (float)N) * (((float *)argv)[1] * .5); */
+ *result = n * ((double *)argv)[0];
+ /* *result = (n / (double)N) * (((double *)argv)[1] * .5); */
return XTRACT_SUCCESS;
}
-int xtract_loudness(const float *data, const int N, const void *argv, float *result)
+int xtract_loudness(const double *data, const int N, const void *argv, double *result)
{
int n = N, rv;
- *result = 0.f;
+ *result = 0.0;
if(n > XTRACT_BARK_BANDS)
{
@@ -505,27 +480,27 @@ int xtract_loudness(const float *data, const int N, const void *argv, float *res
rv = XTRACT_SUCCESS;
while(n--)
- *result += powf(data[n], 0.23);
+ *result += pow(data[n], 0.23);
return rv;
}
-int xtract_flatness(const float *data, const int N, const void *argv, float *result)
+int xtract_flatness(const double *data, const int N, const void *argv, double *result)
{
int n, count, denormal_found;
double num, den, temp;
- num = 1.f;
- den = temp = 0.f;
+ num = 1.0;
+ den = temp = 0.0;
denormal_found = 0;
count = 0;
for(n = 0; n < N; n++)
{
- if((temp = data[n]) != 0.f)
+ if((temp = data[n]) != 0.0)
{
if (xtract_is_denormal(num))
{
@@ -540,15 +515,15 @@ int xtract_flatness(const float *data, const int N, const void *argv, float *res
if(!count)
{
- *result = 0.f;
+ *result = 0.0;
return XTRACT_NO_RESULT;
}
- num = powf(num, 1.f / (float)N);
- den /= (float)N;
+ num = pow(num, 1.0 / (double)N);
+ den /= (double)N;
- *result = (float) (num / den);
+ *result = (double) (num / den);
if(denormal_found)
return XTRACT_DENORMAL_FOUND;
@@ -557,12 +532,12 @@ int xtract_flatness(const float *data, const int N, const void *argv, float *res
}
-int xtract_flatness_db(const float *data, const int N, const void *argv, float *result)
+int xtract_flatness_db(const double *data, const int N, const void *argv, double *result)
{
- float flatness;
+ double flatness;
- flatness = *(float *)argv;
+ flatness = *(double *)argv;
if (flatness <= 0)
flatness = XTRACT_LOG_LIMIT;
@@ -573,27 +548,27 @@ int xtract_flatness_db(const float *data, const int N, const void *argv, float *
}
-int xtract_tonality(const float *data, const int N, const void *argv, float *result)
+int xtract_tonality(const double *data, const int N, const void *argv, double *result)
{
- float sfmdb;
+ double sfmdb;
- sfmdb = *(float *)argv;
+ sfmdb = *(double *)argv;
- *result = XTRACT_MIN(sfmdb / -60.f, 1);
+ *result = XTRACT_MIN(sfmdb / -60.0, 1);
return XTRACT_SUCCESS;
}
-int xtract_crest(const float *data, const int N, const void *argv, float *result)
+int xtract_crest(const double *data, const int N, const void *argv, double *result)
{
- float max, mean;
+ double max, mean;
- max = mean = 0.f;
+ max = mean = 0.0;
- max = *(float *)argv;
- mean = *((float *)argv+1);
+ max = *(double *)argv;
+ mean = *((double *)argv+1);
*result = max / mean;
@@ -601,15 +576,15 @@ int xtract_crest(const float *data, const int N, const void *argv, float *result
}
-int xtract_noisiness(const float *data, const int N, const void *argv, float *result)
+int xtract_noisiness(const double *data, const int N, const void *argv, double *result)
{
- float h, i, p; /*harmonics, inharmonics, partials */
+ double h, i, p; /*harmonics, inharmonics, partials */
- i = p = h = 0.f;
+ i = p = h = 0.0;
- h = *(float *)argv;
- p = *((float *)argv+1);
+ h = *(double *)argv;
+ p = *((double *)argv+1);
i = p - h;
@@ -619,28 +594,28 @@ int xtract_noisiness(const float *data, const int N, const void *argv, float *re
}
-int xtract_rms_amplitude(const float *data, const int N, const void *argv, float *result)
+int xtract_rms_amplitude(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- *result = 0.f;
+ *result = 0.0;
while(n--) *result += XTRACT_SQ(data[n]);
- *result = sqrtf(*result / (float)N);
+ *result = sqrt(*result / (double)N);
return XTRACT_SUCCESS;
}
-int xtract_spectral_inharmonicity(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result)
{
int n = N >> 1;
- float num = 0.f, den = 0.f, fund;
- const float *freqs, *amps;
+ double num = 0.0, den = 0.0, fund;
+ const double *freqs, *amps;
- fund = *(float *)argv;
+ fund = *(double *)argv;
amps = data;
freqs = data + n;
@@ -648,7 +623,7 @@ int xtract_spectral_inharmonicity(const float *data, const int N, const void *ar
{
if(amps[n])
{
- num += fabsf(freqs[n] - n * fund) * XTRACT_SQ(amps[n]);
+ num += fabs(freqs[n] - n * fund) * XTRACT_SQ(amps[n]);
den += XTRACT_SQ(amps[n]);
}
}
@@ -659,19 +634,19 @@ int xtract_spectral_inharmonicity(const float *data, const int N, const void *ar
}
-int xtract_power(const float *data, const int N, const void *argv, float *result)
+int xtract_power(const double *data, const int N, const void *argv, double *result)
{
return XTRACT_FEATURE_NOT_IMPLEMENTED;
}
-int xtract_odd_even_ratio(const float *data, const int N, const void *argv, float *result)
+int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result)
{
int M = (N >> 1), n;
- float odd = 0.f, even = 0.f, temp;
+ double odd = 0.0, even = 0.0, temp;
for(n = 0; n < M; n++)
{
@@ -688,9 +663,9 @@ int xtract_odd_even_ratio(const float *data, const int N, const void *argv, floa
}
}
- if(odd == 0.f || even == 0.f)
+ if(odd == 0.0 || even == 0.0)
{
- *result = 0.f;
+ *result = 0.0;
return XTRACT_NO_RESULT;
}
else
@@ -700,15 +675,15 @@ int xtract_odd_even_ratio(const float *data, const int N, const void *argv, floa
}
}
-int xtract_sharpness(const float *data, const int N, const void *argv, float *result)
+int xtract_sharpness(const double *data, const int N, const void *argv, double *result)
{
int n = N, rv;
- float sl, g; /* sl = specific loudness */
+ double sl, g; /* sl = specific loudness */
double temp;
- sl = g = 0.f;
- temp = 0.f;
+ sl = g = 0.0;
+ temp = 0.0;
if(n > XTRACT_BARK_BANDS)
rv = XTRACT_BAD_VECTOR_SIZE;
@@ -718,27 +693,27 @@ int xtract_sharpness(const float *data, const int N, const void *argv, float *re
while(n--)
{
- sl = powf(data[n], 0.23);
- g = (n < 15 ? 1.f : 0.066 * expf(0.171 * n));
+ sl = pow(data[n], 0.23);
+ g = (n < 15 ? 1.0 : 0.066 * exp(0.171 * n));
temp += n * g * sl;
}
- temp = 0.11 * temp / (float)N;
- *result = (float)temp;
+ temp = 0.11 * temp / (double)N;
+ *result = (double)temp;
return rv;
}
-int xtract_spectral_slope(const float *data, const int N, const void *argv, float *result)
+int xtract_spectral_slope(const double *data, const int N, const void *argv, double *result)
{
- const float *freqs, *amps;
- float f, a,
+ const double *freqs, *amps;
+ double f, a,
F, A, FA, FXTRACT_SQ; /* sums of freqs, amps, freq * amps, freq squared */
int n, M;
- F = A = FA = FXTRACT_SQ = 0.f;
+ F = A = FA = FXTRACT_SQ = 0.0;
n = M = N >> 1;
amps = data;
@@ -754,30 +729,30 @@ int xtract_spectral_slope(const float *data, const int N, const void *argv, floa
FXTRACT_SQ += f * f;
}
- *result = (1.f / A) * (M * FA - F * A) / (M * FXTRACT_SQ - F * F);
+ *result = (1.0 / A) * (M * FA - F * A) / (M * FXTRACT_SQ - F * F);
return XTRACT_SUCCESS;
}
-int xtract_lowest_value(const float *data, const int N, const void *argv, float *result)
+int xtract_lowest_value(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- float temp;
+ double temp;
*result = data[--n];
while(n--)
{
- if((temp = data[n]) > *(float *)argv)
+ if((temp = data[n]) > *(double *)argv)
*result = XTRACT_MIN(*result, data[n]);
}
return XTRACT_SUCCESS;
}
-int xtract_highest_value(const float *data, const int N, const void *argv, float *result)
+int xtract_highest_value(const double *data, const int N, const void *argv, double *result)
{
int n = N;
@@ -791,12 +766,12 @@ int xtract_highest_value(const float *data, const int N, const void *argv, float
}
-int xtract_sum(const float *data, const int N, const void *argv, float *result)
+int xtract_sum(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- *result = 0.f;
+ *result = 0.0;
while(n--)
*result += *data++;
@@ -805,12 +780,12 @@ int xtract_sum(const float *data, const int N, const void *argv, float *result)
}
-int xtract_nonzero_count(const float *data, const int N, const void *argv, float *result)
+int xtract_nonzero_count(const double *data, const int N, const void *argv, double *result)
{
int n = N;
- *result = 0.f;
+ *result = 0.0;
while(n--)
*result += (*data++ ? 1 : 0);
@@ -819,35 +794,35 @@ int xtract_nonzero_count(const float *data, const int N, const void *argv, float
}
-int xtract_hps(const float *data, const int N, const void *argv, float *result)
+int xtract_hps(const double *data, const int N, const void *argv, double *result)
{
int n = N, M, m, l, peak_index, position1_lwr;
- float *coeffs2, *coeffs3, *product, L,
+ double *coeffs2, *coeffs3, *product, L,
largest1_lwr, peak, ratio1, sr;
- sr = *(float*)argv;
+ sr = *(double*)argv;
if(sr == 0)
- sr = 44100.f;
+ sr = 44100.0;
- coeffs2 = (float *)malloc(N * sizeof(float));
- coeffs3 = (float *)malloc(N * sizeof(float));
- product = (float *)malloc(N * sizeof(float));
+ coeffs2 = (double *)malloc(N * sizeof(double));
+ coeffs3 = (double *)malloc(N * sizeof(double));
+ product = (double *)malloc(N * sizeof(double));
while(n--) coeffs2[n] = coeffs3[n] = 1;
M = N >> 1;
- L = N / 3.f;
+ L = N / 3.0;
while(M--)
{
m = M << 1;
- coeffs2[M] = (data[m] + data[m+1]) * 0.5f;
+ coeffs2[M] = (data[m] + data[m+1]) * 0.5;
if(M < L)
{
l = M * 3;
- coeffs3[M] = (data[l] + data[l+1] + data[l+2]) / 3.f;
+ coeffs3[M] = (data[l] + data[l+1] + data[l+2]) / 3.0;
}
}
@@ -880,7 +855,7 @@ int xtract_hps(const float *data, const int N, const void *argv, float *result)
peak_index * 0.6 && ratio1 > 0.1)
peak_index = position1_lwr;
- *result = sr / (float)peak_index;
+ *result = sr / (double)peak_index;
free(coeffs2);
free(coeffs3);
@@ -890,25 +865,25 @@ int xtract_hps(const float *data, const int N, const void *argv, float *result)
}
-int xtract_f0(const float *data, const int N, const void *argv, float *result)
+int xtract_f0(const double *data, const int N, const void *argv, double *result)
{
int M, tau, n;
- float sr;
+ double sr;
size_t bytes;
- float f0, err_tau_1, err_tau_x, array_max,
+ double f0, err_tau_1, err_tau_x, array_max,
threshold_peak, threshold_centre,
*input;
- sr = *(float *)argv;
+ sr = *(double *)argv;
if(sr == 0)
- sr = 44100.f;
+ sr = 44100.0;
- input = (float *)malloc(bytes = N * sizeof(float));
+ input = (double *)malloc(bytes = N * sizeof(double));
input = memcpy(input, data, bytes);
- /* threshold_peak = *((float *)argv+1);
- threshold_centre = *((float *)argv+2);
- printf("peak: %.2f\tcentre: %.2f\n", threshold_peak, threshold_centre);*/
+ /* threshold_peak = *((double *)argv+1);
+ threshold_centre = *((double *)argv+2);
+ printf("peak: %.2\tcentre: %.2\n", threshold_peak, threshold_centre);*/
/* add temporary dynamic control over thresholds to test clipping effects */
/* FIX: tweak and make into macros */
@@ -949,14 +924,14 @@ int xtract_f0(const float *data, const int N, const void *argv, float *result)
/* Estimate fundamental freq */
for (n = 1; n < M; n++)
- err_tau_1 = err_tau_1 + fabsf(input[n] - input[n+1]);
+ err_tau_1 = err_tau_1 + fabs(input[n] - input[n+1]);
/* FIX: this doesn't pose too much load if it returns 'early', but if it can't find f0, load can be significant for larger block sizes M^2 iterations! */
for (tau = 2; tau < M; tau++)
{
err_tau_x = 0;
for (n = 1; n < M; n++)
{
- err_tau_x = err_tau_x + fabsf(input[n] - input[n+tau]);
+ err_tau_x = err_tau_x + fabs(input[n] - input[n+tau]);
}
if (err_tau_x < err_tau_1)
{
@@ -971,27 +946,27 @@ int xtract_f0(const float *data, const int N, const void *argv, float *result)
return XTRACT_NO_RESULT;
}
-int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result)
+int xtract_failsafe_f0(const double *data, const int N, const void *argv, double *result)
{
- float *spectrum = NULL, argf[2], *peaks = NULL, return_code, sr;
+ double *spectrum = NULL, argf[2], *peaks = NULL, return_code, sr;
return_code = xtract_f0(data, N, argv, result);
if(return_code == XTRACT_NO_RESULT)
{
- sr = *(float *)argv;
+ sr = *(double *)argv;
if(sr == 0)
- sr = 44100.f;
- spectrum = (float *)malloc(N * sizeof(float));
- peaks = (float *)malloc(N * sizeof(float));
+ sr = 44100.0;
+ spectrum = (double *)malloc(N * sizeof(double));
+ peaks = (double *)malloc(N * sizeof(double));
argf[0] = sr;
argf[1] = XTRACT_MAGNITUDE_SPECTRUM;
xtract_spectrum(data, N, argf, spectrum);
- argf[1] = 10.f;
+ argf[1] = 10.0;
xtract_peak_spectrum(spectrum, N >> 1, argf, peaks);
- argf[0] = 0.f;
+ argf[0] = 0.0;
xtract_lowest_value(peaks+(N >> 1), N >> 1, argf, result);
free(spectrum);
diff --git a/src/vector.c b/src/vector.c
index f396745..5639374 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -31,47 +31,19 @@
#include "xtract/libxtract.h"
#include "xtract_macros_private.h"
-
-#ifndef roundf
-float roundf(float f)
-{
- if (f - (int)f >= 0.5)
- return (float)((int)f + 1);
- else
- return (float)((int)f);
-}
-#endif
-
-#ifndef powf
-#define powf pow
-#endif
-
-#ifndef expf
-#define expf exp
-#endif
-
-#ifndef sqrtf
-#define sqrtf sqrt
-#endif
-
-#ifndef fabsf
-#define fabsf fabs
-#endif
-
#include "xtract_globals_private.h"
-#include "xtract_macros_private.h"
-int xtract_spectrum(const float *data, const int N, const void *argv, float *result)
+int xtract_spectrum(const double *data, const int N, const void *argv, double *result)
{
int vector = 0;
int withDC = 0;
int normalise = 0;
- float q = 0.f;
- float temp = 0.f;
- float max = 0.f;
- float NxN = XTRACT_SQ(N);
- float *marker = NULL;
+ double q = 0.0;
+ double temp = 0.0;
+ double max = 0.0;
+ double NxN = XTRACT_SQ(N);
+ double *marker = NULL;
size_t bytes = N * sizeof(double);
double *rfft = NULL;
unsigned int n = 0;
@@ -86,10 +58,10 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *res
rfft[n] = (double)data[n];
}
- q = *(float *)argv;
- vector = (int)*((float *)argv+1);
- withDC = (int)*((float *)argv+2);
- normalise = (int)*((float *)argv+3);
+ q = *(double *)argv;
+ vector = (int)*((double *)argv+1);
+ withDC = (int)*((double *)argv+2);
+ normalise = (int)*((double *)argv+3);
XTRACT_CHECK_q;
@@ -122,7 +94,7 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *res
temp = XTRACT_SQ(rfft[nx2]) + XTRACT_SQ(rfft[nx2+1]);
if (temp > XTRACT_LOG_LIMIT)
{
- temp = logf(sqrtf(temp) / (float)N);
+ temp = log(sqrt(temp) / (double)N);
}
else
{
@@ -160,7 +132,7 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *res
}
if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) >
XTRACT_LOG_LIMIT)
- temp = logf(temp / NxN);
+ temp = log(temp / NxN);
else
temp = XTRACT_LOG_LIMIT_DB;
@@ -187,7 +159,7 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *res
++n;
}
- *marker = (float)(sqrt(XTRACT_SQ(rfft[n*2]) +
+ *marker = (double)(sqrt(XTRACT_SQ(rfft[n*2]) +
XTRACT_SQ(rfft[n*2+1])) / (double)N);
XTRACT_SET_FREQUENCY;
@@ -208,7 +180,7 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *res
return XTRACT_SUCCESS;
}
-int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result)
+int xtract_autocorrelation_fft(const double *data, const int N, const void *argv, double *result)
{
double *rfft = NULL;
@@ -219,7 +191,7 @@ int xtract_autocorrelation_fft(const float *data, const int N, const void *argv,
/* Zero pad the input vector */
rfft = (double *)calloc(M, sizeof(double));
- memcpy(rfft, data, N * sizeof(float));
+ memcpy(rfft, data, N * sizeof(double));
rdft(M, 1, rfft, ooura_data_autocorrelation_fft.ooura_ip,
ooura_data_autocorrelation_fft.ooura_w);
@@ -227,7 +199,7 @@ int xtract_autocorrelation_fft(const float *data, const int N, const void *argv,
for(n = 2; n < M; n++)
{
rfft[n*2] = XTRACT_SQ(rfft[n*2]) + XTRACT_SQ(rfft[n*2+1]);
- rfft[n*2+1] = 0.f;
+ rfft[n*2+1] = 0.0;
}
rfft[0] = XTRACT_SQ(rfft[0]);
@@ -240,14 +212,14 @@ int xtract_autocorrelation_fft(const float *data, const int N, const void *argv,
M = M * N;
for(n = 0; n < N; n++)
- result[n] = rfft[n] / (float)M;
+ result[n] = rfft[n] / (double)M;
free(rfft);
return XTRACT_SUCCESS;
}
-int xtract_mfcc(const float *data, const int N, const void *argv, float *result)
+int xtract_mfcc(const double *data, const int N, const void *argv, double *result)
{
xtract_mel_filter *f;
@@ -257,12 +229,12 @@ int xtract_mfcc(const float *data, const int N, const void *argv, float *result)
for(filter = 0; filter < f->n_filters; filter++)
{
- result[filter] = 0.f;
+ result[filter] = 0.0;
for(n = 0; n < N; n++)
{
result[filter] += data[n] * f->filters[filter][n];
}
- result[filter] = logf(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]);
+ result[filter] = log(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]);
}
xtract_dct(result, f->n_filters, NULL, result);
@@ -270,31 +242,31 @@ int xtract_mfcc(const float *data, const int N, const void *argv, float *result)
return XTRACT_SUCCESS;
}
-int xtract_dct(const float *data, const int N, const void *argv, float *result)
+int xtract_dct(const double *data, const int N, const void *argv, double *result)
{
int n;
int m;
- float *temp = calloc(N, sizeof(float));
+ double *temp = calloc(N, sizeof(double));
for (n = 0; n < N; ++n)
{
for(m = 1; m <= N; ++m) {
- temp[n] += data[m - 1] * cos(M_PI * (n / (float)N) * (m - 0.5));
+ temp[n] += data[m - 1] * cos(M_PI * (n / (double)N) * (m - 0.5));
}
}
return XTRACT_SUCCESS;
}
-int xtract_autocorrelation(const float *data, const int N, const void *argv, float *result)
+int xtract_autocorrelation(const double *data, const int N, const void *argv, double *result)
{
/* Naive time domain implementation */
int n = N, i;
- float corr;
+ double corr;
while(n--)
{
@@ -309,50 +281,50 @@ int xtract_autocorrelation(const float *data, const int N, const void *argv, flo
return XTRACT_SUCCESS;
}
-int xtract_amdf(const float *data, const int N, const void *argv, float *result)
+int xtract_amdf(const double *data, const int N, const void *argv, double *result)
{
int n = N, i;
- float md, temp;
+ double md, temp;
while(n--)
{
- md = 0.f;
+ md = 0.0;
for(i = 0; i < N - n; i++)
{
temp = data[i] - data[i + n];
temp = (temp < 0 ? -temp : temp);
md += temp;
}
- result[n] = md / (float)N;
+ result[n] = md / (double)N;
}
return XTRACT_SUCCESS;
}
-int xtract_asdf(const float *data, const int N, const void *argv, float *result)
+int xtract_asdf(const double *data, const int N, const void *argv, double *result)
{
int n = N, i;
- float sd;
+ double sd;
while(n--)
{
- sd = 0.f;
+ sd = 0.0;
for(i = 0; i < N - n; i++)
{
/*sd = 1;*/
sd += XTRACT_SQ(data[i] - data[i + n]);
}
- result[n] = sd / (float)N;
+ result[n] = sd / (double)N;
}
return XTRACT_SUCCESS;
}
-int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result)
+int xtract_bark_coefficients(const double *data, const int N, const void *argv, double *result)
{
int *limits, band, n;
@@ -361,7 +333,7 @@ int xtract_bark_coefficients(const float *data, const int N, const void *argv, f
for(band = 0; band < XTRACT_BARK_BANDS - 1; band++)
{
- result[band] = 0.f;
+ result[band] = 0.0;
for(n = limits[band]; n < limits[band + 1]; n++)
result[band] += data[n];
}
@@ -369,19 +341,19 @@ int xtract_bark_coefficients(const float *data, const int N, const void *argv, f
return XTRACT_SUCCESS;
}
-int xtract_peak_spectrum(const float *data, const int N, const void *argv, float *result)
+int xtract_peak_spectrum(const double *data, const int N, const void *argv, double *result)
{
- float threshold, max, y, y2, y3, p, q, *input = NULL;
+ double threshold, max, y, y2, y3, p, q, *input = NULL;
size_t bytes;
int n = N, rv = XTRACT_SUCCESS;
- threshold = max = y = y2 = y3 = p = q = 0.f;
+ threshold = max = y = y2 = y3 = p = q = 0.0;
if(argv != NULL)
{
- q = ((float *)argv)[0];
- threshold = ((float *)argv)[1];
+ q = ((double *)argv)[0];
+ threshold = ((double *)argv)[1];
}
else
rv = XTRACT_BAD_ARGV;
@@ -394,9 +366,9 @@ int xtract_peak_spectrum(const float *data, const int N, const void *argv, float
XTRACT_CHECK_q;
- input = (float *)calloc(N, sizeof(float));
+ input = (double *)calloc(N, sizeof(double));
- bytes = N * sizeof(float);
+ bytes = N * sizeof(double);
if(input != NULL)
input = memcpy(input, data, bytes);
@@ -439,30 +411,30 @@ int xtract_peak_spectrum(const float *data, const int N, const void *argv, float
return (rv ? rv : XTRACT_SUCCESS);
}
-int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, float *result)
+int xtract_harmonic_spectrum(const double *data, const int N, const void *argv, double *result)
{
int n = (N >> 1), M = n;
- const float *freqs, *amps;
- float f0, threshold, ratio, nearest, distance;
+ const double *freqs, *amps;
+ double f0, threshold, ratio, nearest, distance;
amps = data;
freqs = data + n;
- f0 = *((float *)argv);
- threshold = *((float *)argv+1);
+ f0 = *((double *)argv);
+ threshold = *((double *)argv+1);
- ratio = nearest = distance = 0.f;
+ ratio = nearest = distance = 0.0;
while(n--)
{
if(freqs[n])
{
ratio = freqs[n] / f0;
- nearest = roundf(ratio);
+ nearest = round(ratio);
distance = fabs(nearest - ratio);
if(distance > threshold)
- result[n] = result[M + n] = 0.f;
+ result[n] = result[M + n] = 0.0;
else
{
result[n] = amps[n];
@@ -470,19 +442,19 @@ int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, f
}
}
else
- result[n] = result[M + n] = 0.f;
+ result[n] = result[M + n] = 0.0;
}
return XTRACT_SUCCESS;
}
-int xtract_lpc(const float *data, const int N, const void *argv, float *result)
+int xtract_lpc(const double *data, const int N, const void *argv, double *result)
{
int i, j, k, M, L;
- float r = 0.f,
- error = 0.f;
+ double r = 0.0,
+ error = 0.0;
- float *ref = NULL,
+ double *ref = NULL,
*lpc = NULL ;
error = data[0];
@@ -494,11 +466,11 @@ int xtract_lpc(const float *data, const int N, const void *argv, float *result)
if(error == 0.0)
{
- memset(result, 0, M * sizeof(float));
+ memset(result, 0, M * sizeof(double));
return XTRACT_NO_RESULT;
}
- memset(result, 0, M * sizeof(float));
+ memset(result, 0, M * sizeof(double));
for (i = 0; i < L; i++)
{
@@ -513,7 +485,7 @@ int xtract_lpc(const float *data, const int N, const void *argv, float *result)
lpc[i] = r;
for (j = 0; j < i / 2; j++)
{
- float tmp = lpc[j];
+ double tmp = lpc[j];
lpc[j] = r * lpc[i - 1 - j];
lpc[i - 1 - j] += r * tmp;
}
@@ -525,14 +497,14 @@ int xtract_lpc(const float *data, const int N, const void *argv, float *result)
return XTRACT_SUCCESS;
}
-int xtract_lpcc(const float *data, const int N, const void *argv, float *result)
+int xtract_lpcc(const double *data, const int N, const void *argv, double *result)
{
/* Given N lpc coefficients extract an LPC cepstrum of size argv[0] */
/* Based on an an algorithm by rabiner and Juang */
int n, k;
- float sum;
+ double sum;
int order = N - 1; /* Eventually change this to Q = 3/2 p as suggested in Rabiner */
int cep_length;
@@ -540,13 +512,13 @@ int xtract_lpcc(const float *data, const int N, const void *argv, float *result)
cep_length = N - 1; /* FIX: if we're going to have default values, they should come from the descriptor */
else
cep_length = *(int *)argv;
- //cep_length = (int)((float *)argv)[0];
+ //cep_length = (int)((double *)argv)[0];
- memset(result, 0, cep_length * sizeof(float));
+ memset(result, 0, cep_length * sizeof(double));
for (n = 1; n <= order && n <= cep_length; n++)
{
- sum = 0.f;
+ sum = 0.0;
for (k = 1; k < n; k++)
sum += k * result[k-1] * data[n - k];
result[n-1] = data[n] + sum / n;
@@ -555,7 +527,7 @@ int xtract_lpcc(const float *data, const int N, const void *argv, float *result)
/* be wary of these interpolated values */
for(n = order + 1; n <= cep_length; n++)
{
- sum = 0.f;
+ sum = 0.0;
for (k = n - (order - 1); k < n; k++)
sum += k * result[k-1] * data[n - k];
result[n-1] = sum / n;
@@ -564,11 +536,11 @@ int xtract_lpcc(const float *data, const int N, const void *argv, float *result)
return XTRACT_SUCCESS;
}
-//int xtract_lpcc_s(const float *data, const int N, const void *argv, float *result){
+//int xtract_lpcc_s(const double *data, const int N, const void *argv, double *result){
// return XTRACT_SUCCESS;
//}
-int xtract_subbands(const float *data, const int N, const void *argv, float *result)
+int xtract_subbands(const double *data, const int N, const void *argv, double *result)
{
int n, bw, xtract_func, nbands, scale, start, lower, *argi, rv;
@@ -595,7 +567,7 @@ int xtract_subbands(const float *data, const int N, const void *argv, float *res
if(lower >= N || lower + bw >= N)
{
// printf("n: %d\n", n);
- result[n] = 0.f;
+ result[n] = 0.0;
continue;
}
diff --git a/src/window.c b/src/window.c
index bce0770..18a4e15 100644
--- a/src/window.c
+++ b/src/window.c
@@ -27,108 +27,108 @@
#include "xtract_window_private.h"
-void gauss(float *window, const int N, const float sd)
+void gauss(double *window, const int N, const double sd)
{
int n;
- const float M = N - 1;
- float num,
+ const double M = N - 1;
+ double num,
den,
exponent;
for (n = 0; n < N; n++)
{
- num = n - M / 2.f;
- den = sd * M / 2.f;
+ num = n - M / 2.0;
+ den = sd * M / 2.0;
- exponent = -0.5 * powf(num / den, 2);
+ exponent = -0.5 * pow(num / den, 2);
window[n] = exp(exponent);
}
}
-void hamming(float *window, const int N)
+void hamming(double *window, const int N)
{
int n;
- const float M = N - 1;
+ const double M = N - 1;
for (n = 0; n < N; n++)
- window[n] = 0.53836 - (0.46164 * cosf(2.0 * PI * (float)n / M));
+ window[n] = 0.53836 - (0.46164 * cos(2.0 * PI * (double)n / M));
}
-void hann(float *window, const int N)
+void hann(double *window, const int N)
{
int n;
- const float M = N - 1;
+ const double M = N - 1;
for (n = 0; n < N; n++)
- window[n] = 0.5 * (1.0 - cosf(2.0 * PI * (float)n / M));
+ window[n] = 0.5 * (1.0 - cos(2.0 * PI * (double)n / M));
}
-void bartlett(float *window, const int N)
+void bartlett(double *window, const int N)
{
int n;
- const float M = N - 1;
+ const double M = N - 1;
for (n = 0; n < N; n++)
- window[n] = 2.f / M * (M / 2.f - fabsf(n - M / 2.f));
+ window[n] = 2.0 / M * (M / 2.0 - fabs(n - M / 2.0));
}
-void triangular(float *window, const int N)
+void triangular(double *window, const int N)
{
int n;
- const float M = N - 1;
+ const double M = N - 1;
for (n = 0; n < N; n++)
- window[n] = 2.f / N * (N / 2.f - fabsf(n - M / 2.f));
+ window[n] = 2.0 / N * (N / 2.0 - fabs(n - M / 2.0));
}
-void bartlett_hann(float *window, const int N)
+void bartlett_hann(double *window, const int N)
{
int n;
- const float M = N - 1,
+ const double M = N - 1,
a0 = 0.62,
a1 = 0.5,
a2 = 0.38;
- float term1 = 0.f,
- term2 = 0.f;
+ double term1 = 0.0,
+ term2 = 0.0;
for (n = 0; n < N; n++)
{
- term1 = a1 * fabsf(n / M - 0.5);
- term2 = a2 * cosf(2.0 * PI * (float)n / M);
+ term1 = a1 * fabs(n / M - 0.5);
+ term2 = a2 * cos(2.0 * PI * (double)n / M);
window[n] = a0 - term1 - term2;
}
}
-void blackman(float *window, const int N)
+void blackman(double *window, const int N)
{
int n;
- const float M = N - 1,
+ const double M = N - 1,
a0 = 0.42,
a1 = 0.5,
a2 = 0.08;
- float term1 = 0.f,
- term2 = 0.f;
+ double term1 = 0.0,
+ term2 = 0.0;
for (n = 0; n < N; n++)
{
- term1 = a1 * cosf(2.0 * PI * (float)n / M);
- term2 = a2 * cosf(4.0 * PI * (float)n / M);
+ term1 = a1 * cos(2.0 * PI * (double)n / M);
+ term2 = a2 * cos(4.0 * PI * (double)n / M);
window[n] = a0 - term1 + term2;
}
@@ -137,19 +137,19 @@ void blackman(float *window, const int N)
#define BIZ_EPSILON 1E-21 // Max error acceptable
/* Based on code from mplayer window.c, and somewhat beyond me */
-float besselI0(float x)
+double besselI0(double x)
{
- float temp;
- float sum = 1.0;
- float u = 1.0;
- float halfx = x/2.0;
+ double temp;
+ double sum = 1.0;
+ double u = 1.0;
+ double halfx = x/2.0;
int n = 1;
do
{
- temp = halfx/(float)n;
+ temp = halfx/(double)n;
u *=temp * temp;
sum += u;
n++;
@@ -161,41 +161,41 @@ float besselI0(float x)
}
-void kaiser(float *window, const int N, const float alpha)
+void kaiser(double *window, const int N, const double alpha)
{
int n;
- const float M = N - 1;
- float num;
+ const double M = N - 1;
+ double num;
for (n = 0; n < N; n++)
{
- num = besselI0(alpha * sqrtf(1.0 - powf((2.0 * n / M - 1), 2)));
+ num = besselI0(alpha * sqrt(1.0 - pow((2.0 * n / M - 1), 2)));
window[n] = num / besselI0(alpha);
}
}
-void blackman_harris(float *window, const int N)
+void blackman_harris(double *window, const int N)
{
int n;
- const float M = N - 1,
+ const double M = N - 1,
a0 = 0.35875,
a1 = 0.48829,
a2 = 0.14128,
a3 = 0.01168;
- float term1 = 0.f,
- term2 = 0.f,
- term3 = 0.f;
+ double term1 = 0.0,
+ term2 = 0.0,
+ term3 = 0.0;
for (n = 0; n < N; n++)
{
- term1 = a1 * cosf(2.0 * PI * n / M);
- term2 = a2 * cosf(4.0 * PI * n / M);
- term3 = a3 * cosf(6.0 * PI * n / M);
+ term1 = a1 * cos(2.0 * PI * n / M);
+ term2 = a2 * cos(4.0 * PI * n / M);
+ term3 = a3 * cos(6.0 * PI * n / M);
window[n] = a0 - term1 + term2 - term3;
}
diff --git a/src/xtract_window_private.h b/src/xtract_window_private.h
index 609010b..5708161 100644
--- a/src/xtract_window_private.h
+++ b/src/xtract_window_private.h
@@ -32,7 +32,7 @@
* \param sd the standard deviation of the "distribution" represented by the Gaussian curve. The higher the value of sd, the wider the curve. Generally sd <= 0.5
*
*/
-void gauss(float *window, const int N, const float sd);
+void gauss(double *window, const int N, const double sd);
/** \brief generate a Hamming window
*
@@ -40,7 +40,7 @@ void gauss(float *window, const int N, const float sd);
* \param N the number of elements in the array pointed to by *window
*
*/
-void hamming(float *window, const int N);
+void hamming(double *window, const int N);
/** \brief generate a Hann window
*
@@ -48,7 +48,7 @@ void hamming(float *window, const int N);
* \param N the number of elements in the array pointed to by *window
*
*/
-void hann(float *window, const int N);
+void hann(double *window, const int N);
/** \brief generate a Bartlett window
*
@@ -56,7 +56,7 @@ void hann(float *window, const int N);
* \param N the number of elements in the array pointed to by *window
*
*/
-void bartlett(float *window, const int N);
+void bartlett(double *window, const int N);
/** \brief generate a Triangular window
*
@@ -64,7 +64,7 @@ void bartlett(float *window, const int N);
* \param N the number of elements in the array pointed to by *window
*
*/
-void triangular(float *window, const int N);
+void triangular(double *window, const int N);
/** \brief generate a Bartlett-Hann window
*
@@ -72,7 +72,7 @@ void triangular(float *window, const int N);
* \param N the number of elements in the array pointed to by *window
*
*/
-void bartlett_hann(float *window, const int N);
+void bartlett_hann(double *window, const int N);
/** \brief generate a Blackman window
*
@@ -80,7 +80,7 @@ void bartlett_hann(float *window, const int N);
* \param N the number of elements in the array pointed to by *window
*
*/
-void blackman(float *window, const int N);
+void blackman(double *window, const int N);
/** \brief generate a Kaiser window
*
@@ -89,7 +89,7 @@ void blackman(float *window, const int N);
* \param alpha The larger the value of |alpha|, the narrower the window becomes
*
*/
-void kaiser(float *window, const int N, const float alpha);
+void kaiser(double *window, const int N, const double alpha);
/** \brief generate a Blackman-Harris window
*
@@ -97,5 +97,5 @@ void kaiser(float *window, const int N, const float alpha);
* \param N the number of elements in the array pointed to by *window
*
*/
-void blackman_harris(float *window, const int N);
+void blackman_harris(double *window, const int N);
diff --git a/xtract/libxtract.h b/xtract/libxtract.h
index 94773c6..8082a47 100644
--- a/xtract/libxtract.h
+++ b/xtract/libxtract.h
@@ -32,12 +32,12 @@
*
* All feature extraction functions follow the same prototype:
*
-int xtract_function_name(const float *data, const int N, const void *argv, float *result){
+int xtract_function_name(const double *data, const int N, const void *argv, double *result){
*
- * \param const float *data points to an array of floats representing the input data
+ * \param const double *data points to an array of doubles representing the input data
* \param const int N represents the number of elementes from *data to be considered in the calculation
* \param const void *argv represents an arbitrary list of arguments. Used to pass in values required by the feature calculation
- * \param float *result points to an array of floats, or a single float represnting the result of the calculation
+ * \param double *result points to an array of doubles, or a single double represnting the result of the calculation
*
*
* It is up to the calling function to allocate enough memory for the *data, *argv, and *result, and to free it when required. Some feature extraction functions may also require an _init() function to be called in order to perform some initialisation. The struct xtract_function_descriptor_t is used to give an indication of recommended default values, and argc for the *argv array.
@@ -282,9 +282,9 @@ typedef struct _xtract_function_descriptor {
struct {
xtract_type_t type; /* type of the array/value pointed to by argv */
- float min[XTRACT_MAXARGS];
- float max[XTRACT_MAXARGS];
- float def[XTRACT_MAXARGS]; /* defaults */
+ double min[XTRACT_MAXARGS];
+ double max[XTRACT_MAXARGS];
+ double def[XTRACT_MAXARGS]; /* defaults */
xtract_unit_t unit[XTRACT_MAXARGS];
int donor[XTRACT_MAXARGS]; /* suggested donor functions for argv */
} argv;
@@ -296,8 +296,8 @@ typedef struct _xtract_function_descriptor {
union {
struct {
- float min;
- float max;
+ double min;
+ double max;
xtract_unit_t unit;
} scalar;
@@ -344,9 +344,9 @@ typedef struct _xtract_function_descriptor {
#include "libxtract.h"
main () {
-float values[] = {1.0, 2.0, 3.0, 4.0, 5.0};
+double values[] = {1.0, 2.0, 3.0, 4.0, 5.0};
int N = 5;
-float mean;
+double mean;
xtract[MEAN]((void *)values, N, NULL, &mean);
@@ -357,21 +357,21 @@ printf("Mean = %.2f\n", mean);
*
*/
#ifdef XTRACT_H
-extern int(*xtract[XTRACT_FEATURES])(const float *data, const int N, const void *argv, float *result);
+extern int(*xtract[XTRACT_FEATURES])(const double *data, const int N, const void *argv, double *result);
#endif
/** \brief A structure to store a set of n_filters Mel filters */
typedef struct xtract_mel_filter_ {
int n_filters;
- float **filters;
+ double **filters;
} xtract_mel_filter;
/** \brief A function to initialise a mel filter bank
*
* It is up to the caller to pass in a pointer to memory allocated for freq_bands arrays of length N. This function populates these arrays with magnitude coefficients representing the mel filterbank on a linear scale
*/
-int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables);
+int xtract_init_mfcc(int N, double nyquist, int style, double freq_min, double freq_max, int freq_bands, double **fft_tables);
/** \brief A function to initialise bark filter bounds
*
@@ -381,7 +381,7 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq
* \param sr: The sample audio sample rate
* \param *band_limits: a pointer to an array of BARK_BANDS ints
*/
-int xtract_init_bark(int N, float sr, int *band_limits);
+int xtract_init_bark(int N, double sr, int *band_limits);
/** \brief An initialisation function for functions using FFT
*
@@ -406,14 +406,14 @@ void xtract_free_fft(void);
* \param type: the type of the window as given in the enumeration window_types_
*
*/
-float *xtract_init_window(const int N, const int type);
+double *xtract_init_window(const int N, const int type);
/** \brief Free a window as allocated by xtract_make_window()
*
- * \param *window: a pointer to an array of floats as allocated by xtract_make_window()
+ * \param *window: a pointer to an array of doubles as allocated by xtract_make_window()
*
*/
-void xtract_free_window(float *window);
+void xtract_free_window(double *window);
/* \brief A function to build an array of function descriptors */
xtract_function_descriptor_t *xtract_make_descriptors();
diff --git a/xtract/xtract_delta.h b/xtract/xtract_delta.h
index c761699..9c0882c 100644
--- a/xtract/xtract_delta.h
+++ b/xtract/xtract_delta.h
@@ -45,25 +45,25 @@ extern "C" {
* \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);
+int xtract_flux(const double *data, const int N, const void *argv , double *result);
/** \brief Extract the L-norm of a vector
*
- * \param *data: a pointer to the first element in an array of floats representing the difference between two subsequent frames of output from a vector-based feature e.g. the *result from xtract_difference_vector()
+ * \param *data: a pointer to the first element in an array of doubles representing the difference between two subsequent frames of output from a vector-based feature e.g. the *result from xtract_difference_vector()
* \param N: the length of the array pointed to by *data
- * \param *argv: a pointer to an array of floats, the first representing the "norm order". The second argument represents the filter type determining what values we consider from the difference vector as given in the enumeration xtract_lnorm_filter_types_ (libxtract.h)
- * \param *result: a pointer to a float representing the flux
+ * \param *argv: a pointer to an array of doubles, the first representing the "norm order". The second argument represents the filter type determining what values we consider from the difference vector as given in the enumeration xtract_lnorm_filter_types_ (libxtract.h)
+ * \param *result: a pointer to a double representing the flux
*
*/
-int xtract_lnorm(const float *data, const int N, const void *argv , float *result);
+int xtract_lnorm(const double *data, const int N, const void *argv , double *result);
/*xtract_frame_tracker *xf */
/** \brief Extract attack Time */
-int xtract_attack_time(const float *data, const int N, const void *argv , float *result);
+int xtract_attack_time(const double *data, const int N, const void *argv , double *result);
/* xtract_amp_tracker *xa */
/** Extract temporal decrease */
-int xtract_decay_time(const float *data, const int N, const void *argv, float *result);
+int xtract_decay_time(const double *data, const int N, const void *argv, double *result);
/* xtract_amp_tracker *xa */
@@ -75,9 +75,9 @@ int xtract_decay_time(const float *data, const int N, const void *argv, float *r
* \param *result a pointer to an array of size N / 2 representing the difference between the two input vectors.
*
* */
-int xtract_difference_vector(const float *data, const int N, const void *argv, float *result);
+int xtract_difference_vector(const double *data, const int N, const void *argv, double *result);
/*xtract_frame_tracker *xf */
-/*float frames*/
+/*double frames*/
/** @} */
diff --git a/xtract/xtract_helper.h b/xtract/xtract_helper.h
index 17bb23e..bc5b892 100644
--- a/xtract/xtract_helper.h
+++ b/xtract/xtract_helper.h
@@ -44,7 +44,7 @@ extern "C" {
/** \brief Apply a window function to an array of length N
*
- * \param *data a pointer to an array of floats
+ * \param *data a pointer to an array of doubles
* \param N the number of elements in the array pointed to by *data
* \param *argv a pointer to a window function as returned by xtract_make_window()
* \param *result a pointer to the first element an array containing the windowed data
@@ -52,11 +52,11 @@ extern "C" {
* It is up to the caller to generate and free the array containing the window, and to allocate and free memory of size N to hold the data pointed to by *result
*
*/
-int xtract_windowed(const float *data, const int N, const void *argv, float *result);
+int xtract_windowed(const double *data, const int N, const void *argv, double *result);
/** \brief Divides the array pointed to by *data into two subframes, and applies a given feature to each subframe, returning them in a single array pointed to by result
*
- * \param *data an array of floats
+ * \param *data an array of doubles
* \param N the number of elements in the array pointed by *data
* \param feature an integer representing the feature to be applied to each subframe in data. This will be a value as given in the enumeration xtract_features_ (libxtract.h)
* \param *argv a pointer to the argument vector to be passed to the feature extraction function as determined by feature
@@ -66,7 +66,7 @@ int xtract_windowed(const float *data, const int N, const void *argv, float *res
* It is important to ensure that any _init_*() functions that are called in preparation for functions that are called on subframes are given the subframe size as 'N', and not the frame size. i.e. if xtract_features_from_subframes() is called with N=64, and feature=XTRACT_SPECTRUM, then xtract_init_fft() should be called with N=32.
*
*/
-int xtract_features_from_subframes(const float *data, const int N, const int feature, const void *argv, float *result);
+int xtract_features_from_subframes(const double *data, const int N, const int feature, const void *argv, double *result);
/** \brief Test whether a number is denormal */
int xtract_is_denormal(double const d);
diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h
index 907d5fe..eee2df4 100644
--- a/xtract/xtract_scalar.h
+++ b/xtract/xtract_scalar.h
@@ -47,114 +47,114 @@ void test(void);
* \param *argv: a pointer to NULL
* \param *result: the mean of N values from the array pointed to by *data
*/
-int xtract_mean(const float *data, const int N, const void *argv, float *result);
+int xtract_mean(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the variance of an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float representing the mean of the input vector
+ * \param *argv: a pointer to a double representing the mean of the input vector
* \param *result: the variance of N values from the array pointed to by *data
*/
-int xtract_variance(const float *data, const int N, const void *argv, float *result);
+int xtract_variance(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the deviation of an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float representing the variance of the input vector
+ * \param *argv: a pointer to a double representing the variance of the input vector
* \param *result: the deviation of N values from the array pointed to by *data
*/
-int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result);
+int xtract_standard_deviation(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the average deviation of an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float representing the mean of the input vector
+ * \param *argv: a pointer to a double representing the mean of the input vector
* \param *result: the average deviation of N values from the array pointed to by *data
*/
-int xtract_average_deviation(const float *data, const int N, const void *argv, float *result);
+int xtract_average_deviation(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the skewness of an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
- * \param *argv: a pointer to an array of floats representing the mean and standard deviation of the input vector
+ * \param *argv: a pointer to an array of doubles representing the mean and standard deviation of the input vector
* \param *result: the skewness of N values from the array pointed to by *data
*/
-int xtract_skewness(const float *data, const int N, const void *argv, float *result);
+int xtract_skewness(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the kurtosis of an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
* \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector
* \param *result: the kurtosis of N values from the array pointed to by *data
*/
-int xtract_kurtosis(const float *data, const int N, const void *argv, float *result);
+int xtract_kurtosis(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the mean of an input spectrum
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the size of the array pointed to by *data
* \param *argv: a pointer to NULL
* \param *result: the mean of the spectrum pointed to by *data
*/
-int xtract_spectral_mean(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_mean(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the variance of an input spectrum
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the number of elements to be considered
* \param N: the size of the array pointed to by *data
- * \param *argv: a pointer to a float representing the spectral mean of the input spectrum
+ * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
* \param *result: the variance of the spectrum pointed to by *data
*/
-int xtract_spectral_variance(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_variance(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the deviation of an input spectrum
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the size of the array pointed to by *data
- * \param *argv: a pointer to a float representing the spectral variance of the input spectrum
+ * \param *argv: a pointer to a double representing the spectral variance of the input spectrum
* \param *result: the deviation of the spectrum pointed to by *data
*/
-int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_standard_deviation(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the average deviation of an input spectrum
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the size of the array pointed to by *data
- * \param *argv: a pointer to a float representing the spectral mean of the input spectrum
+ * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
* \param *result: the average deviation of the spectrum pointed to by *data
*/
/*
-int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_average_deviation(const double *data, const int N, const void *argv, double *result);
*/
/** \brief Extract the skewness of an input spectrum
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the size of the array pointed to by *data
- * \param *argv: a pointer to an array of floats representing the spectral mean and spectral standard deviation of the input spectrum
+ * \param *argv: a pointer to an array of doubles representing the spectral mean and spectral standard deviation of the input spectrum
* \param *result: the skewness of the spectrum pointed to by *data
*/
-int xtract_spectral_skewness(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_skewness(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the kurtosis of an input spectrum
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the size of the array pointed to by *data
* \param *argv: a pointer to an array of values representing the spectral mean and spectral standard deviation of the input spectrum
* \param *result: the kurtosis of the spectrum pointed to by *data
*/
-int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_kurtosis(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the centroid of an input vector
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the centroid of the values pointed to by *data
@@ -162,29 +162,29 @@ int xtract_spectral_kurtosis(const float *data, const int N, const void *argv,
* Note: for a more 'accurate' result *result from xtract_peak_spectrum() can be passed in. This gives the interpolated peak frequency locations.
*
*/
-int xtract_spectral_centroid(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_centroid(const double *data, const int N, const void *argv, double *result);
/** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994)
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the irregularity of N values from the array pointed to by *data
*/
-int xtract_irregularity_k(const float *data, const int N, const void *argv, float *result);
+int xtract_irregularity_k(const double *data, const int N, const void *argv, double *result);
/** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999)
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the irregularity of N values from the array pointed to by *data
*/
-int xtract_irregularity_j(const float *data, const int N, const void *argv, float *result);
+int xtract_irregularity_j(const double *data, const int N, const void *argv, double *result);
/** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982)
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients of the harmonic spectrum of an audio vector e.g. a pointer to the first half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_peak_spectrum()) can be used if one wishes to consider all partials not just harmonics.
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients of the harmonic spectrum of an audio vector e.g. a pointer to the first half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_peak_spectrum()) can be used if one wishes to consider all partials not just harmonics.
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the tristimulus of N values from the array pointed to by *data
@@ -192,51 +192,51 @@ int xtract_irregularity_j(const float *data, const int N, const void *argv, floa
* These three functions provide the first, second and third order tristimulus formulae
*
*/
-int xtract_tristimulus_1(const float *data, const int N, const void *argv, float *result);
-int xtract_tristimulus_2(const float *data, const int N, const void *argv, float *result);
-int xtract_tristimulus_3(const float *data, const int N, const void *argv, float *result);
+int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result);
+int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result);
+int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the smoothness of an input vector using a method described by McAdams (1999)
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
* \param *argv: a pointer to the first element of an array of integers containing the lower bound, upper bound, and pre-scaling factor, whereby array data in the range lower < n < upper will be pre-scaled by p before processing.
* \param *result: the smoothness of N values from the array pointed to by *data
*/
-int xtract_smoothness(const float *data, const int N, const void *argv, float *result);
+int xtract_smoothness(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005)
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float corresponding to the spectral centroid
+ * \param *argv: a pointer to a double corresponding to the spectral centroid
* \param *result: the spectral spread of N values from the array pointed to by *data
*/
-int xtract_spread(const float *data, const int N, const void *argv, float *result);
+int xtract_spread(const double *data, const int N, const void *argv, double *result);
/* Zero crossing rate */
/** \brief Extract the zero crossing rate of an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the zero crossing rate of N values from the array pointed to by *data
*/
-int xtract_zcr(const float *data, const int N, const void *argv, float *result);
+int xtract_zcr(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the spectral rolloff of an input vector using a method described by Bee Suan Ong (2005)
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
- * \param *argv: a pointer to an array containing a float representing (samplerate / N ) and a float representing the threshold for rolloff, i.e. the percentile at which the rolloff is determined, expressed as a percentage, and
+ * \param *argv: a pointer to an array containing a double representing (samplerate / N ) and a double representing the threshold for rolloff, i.e. the percentile at which the rolloff is determined, expressed as a percentage, and
* \param *result: the spectral rolloff in Hz of N values from the array pointed to by *data. This is the point in the spectrum below which argv[0] of the energy is distributed.
*/
-int xtract_rolloff(const float *data, const int N, const void *argv, float *result);
+int xtract_rolloff(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the 'total loudness' of an input vector using a method described by Moore, Glasberg et al (2005)
*
- * \param *data: a pointer to the first element in an array of floats representing a set of BARK_BANDS bark coefficients
+ * \param *data: a pointer to the first element in an array of doubles representing a set of BARK_BANDS bark coefficients
* \param N: the number of coefficients to be considered
* \param *argv: a pointer to NULL
* \param *result: the total loudness of N values from the array pointed to by *data
@@ -244,30 +244,30 @@ int xtract_rolloff(const float *data, const int N, const void *argv, float *resu
* Note: if N = 1, the 'specific loudness' of the bark band pointed to by *data will be given by *result
*
*/
-int xtract_loudness(const float *data, const int N, const void *argv, float *result);
+int xtract_loudness(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the spectral flatness measure of an input vector, where the flatness measure (SFM) is defined as the ratio of the geometric mean to the arithmetic mean of a magnitude spectrum.
*
* \note The computation method used here is the most efficient by a significant margin, but suffers from precision problems due to the multiplication operationin the geometric mean calculation. This is particularly accute for larger values of N (>=256). However, as noted by Peeters (2003), the SFM should generally be computed on a small number of 'bands' rather than on the complete magnitude spectrum. It is therefore highly recommended that xtract_bands() is used prior to calling xtract_flatness().
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). Alternatively the magnitudes from a number of 'subbands' can be used by using *result from xtract_bands().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). Alternatively the magnitudes from a number of 'subbands' can be used by using *result from xtract_bands().
* \param N: the number of *data array elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the flatness of N values from the array pointed to by *data
*/
-int xtract_flatness(const float *data, const int N, const void *argv, float *result);
+int xtract_flatness(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the LOG spectral flatness measure of an input vector
*
* \param *data: a pointer to NULL.
* \param N: not used - can safely be set to 0.
- * \param *argv: a pointer to a float represnting spectral flatness.
+ * \param *argv: a pointer to a double represnting spectral flatness.
* \param *result: the LOG spectral flatness of N values from the array pointed to by *data
*
* flatness_db = 10 * log10(flatness)
*
*/
-int xtract_flatness_db(const float *data, const int N, const void *argv, float *result);
+int xtract_flatness_db(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the tonality factor of an input vector using a method described by Peeters 2003
*
@@ -276,127 +276,127 @@ int xtract_flatness_db(const float *data, const int N, const void *argv, float *
* \param *argv: a pointer to the LOG spectral flatness measure of an audio vector (e.g. the output from xtract_flatness_db)
* \param *result: the tonality factor of N values from the array pointed to by *data
*/
-int xtract_tonality(const float *data, const int N, const void *argv, float *result);
+int xtract_tonality(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000)
*
* \param *data: a pointer to NULL
* \param N:
- * \param *argv: a pointer to an array containing a float represnting the number of harmonic partials in a spectrum, and a float representing the number of partials in a spectrum
+ * \param *argv: a pointer to an array containing a double represnting the number of harmonic partials in a spectrum, and a double representing the number of partials in a spectrum
* \param *result: the noisiness coefficient as calculated from argv
*/
-int xtract_noisiness(const float *data, const int N, const void *argv, float *result);
+int xtract_noisiness(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the RMS amplitude of an input vector using a method described by Tae Hong Park (2000)
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the RMS amplitude of N values from the array pointed to by *data
*/
-int xtract_rms_amplitude(const float *data, const int N, const void *argv, float *result);
+int xtract_rms_amplitude(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the Inharmonicity of an input vector
*
- * \param *data: a pointer to the first element in an array of floats represeting a magnitude peak spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_peak_spectrum())
+ * \param *data: a pointer to the first element in an array of doubles represeting a magnitude peak spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_peak_spectrum())
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float representing the fundamental frequency of the input vector.
+ * \param *argv: a pointer to a double representing the fundamental frequency of the input vector.
* \param *result: the inharmonicity of N values from the array pointed to by *data
*/
-int xtract_spectral_inharmonicity(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003)
*
* \param *data: a pointer to NULL
* \param N: not used
- * \param *argv: a pointer to an array containing a float representing the maximum value in a spectrum, and a float representing the mean value of a spectrum
+ * \param *argv: a pointer to an array containing a double representing the maximum value in a spectrum, and a double representing the mean value of a spectrum
* \param *result: the spectral crest of N values from the array pointed to by *data
*/
-int xtract_crest(const float *data, const int N, const void *argv, float *result);
+int xtract_crest(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the Spectral Power of an input vector using a method described by Bee Suan Ong (2005)
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the spectral power of N values from the array pointed to by *data
*/
-int xtract_power(const float *data, const int N, const void *argv, float *result);
+int xtract_power(const double *data, const int N, const void *argv, double *result);
/* 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 floats 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 the first half of the 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 *result: the even/odd harmonic ratio of N values from the array pointed to by *data
*/
-int xtract_odd_even_ratio(const float *data, const int N, const void *argv, float *result);
+int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the Sharpness of an input vector
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the Sharpness of N values from the array pointed to by *data
*/
-int xtract_sharpness(const float *data, const int N, const void *argv, float *result);
+int xtract_sharpness(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the Slope of an input vector using a method described by Peeters(2003)
*
- * \param *data: a pointer to the first element in an array of floats representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
+ * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()).
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the Slope of N values from the array pointed to by *data
*/
-int xtract_spectral_slope(const float *data, const int N, const void *argv, float *result);
+int xtract_spectral_slope(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the value of the lowest value in an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float representing the lower limit for the search. i.e. (*result > *argv) returns 1.
+ * \param *argv: a pointer to a double representing the lower limit for the search. i.e. (*result > *argv) returns 1.
* \param *result: a pointer to a value representing the lowest component in *data that falls above a given threshold.
*
*/
-int xtract_lowest_value(const float *data, const int N, const void *argv, float *result);
+int xtract_lowest_value(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the value of the highest value in an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL.
* \param *result: a pointer to a value representing the highest component in *data.
*
*/
-int xtract_highest_value(const float *data, const int N, const void *argv, float *result);
+int xtract_highest_value(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the sum of the values in an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL.
* \param *result: a pointer to a value representing the sum of all of the values pointed to by *data.
*
*/
-int xtract_sum(const float *data, const int N, const void *argv, float *result);
+int xtract_sum(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the Pitch of an input vector using Harmonic Product Spectrum (HPS) analysis
*
* \warning {This function doesn't work properly}
*
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the pitch of N values from the array pointed to by *data
*/
-int xtract_hps(const float *data, const int N, const void *argv, float *result);
+int xtract_hps(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the fundamental frequency of an input vector
*
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float representing the audio sample rate
+ * \param *argv: a pointer to a double representing the audio sample rate
* \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
@@ -404,29 +404,29 @@ int xtract_hps(const float *data, const int N, const void *argv, float *result);
* 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);
+int xtract_f0(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the fundamental frequency of an input vector
*
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of elements to be considered
- * \param *argv: a pointer to a float representing the audio sample rate
+ * \param *argv: a pointer to a double representing the audio sample rate
* \param *result: the pitch of N values from the array pointed to by *data
*
* This function wraps xtract_f0, but provides the frequency of the lowest partial in the peak spectrum if f0 can't be found.
*
*/
-int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result);
+int xtract_failsafe_f0(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the number of non-zero elements in an input vector
*
- * \param *data: a pointer to the first element in an array of floats
+ * \param *data: a pointer to the first element in an array of doubles
* \param N: the number of elements to be considered
* \param *argv: not used
* \param *result: the number of non-zero elements in the array pointed to by *data
*
*/
-int xtract_nonzero_count(const float *data, const int N, const void *argv, float *result);
+int xtract_nonzero_count(const double *data, const int N, const void *argv, double *result);
/** @} */
diff --git a/xtract/xtract_types.h b/xtract/xtract_types.h
index 6c22e18..fe75b6e 100644
--- a/xtract/xtract_types.h
+++ b/xtract/xtract_types.h
@@ -33,12 +33,12 @@ extern "C" {
/* \brief Data structure used to store amplitude data between calls to xtract_attack_time and other functions. */
typedef struct _xtract_amp_tracker {
int count;
- float previous_amp;
+ double previous_amp;
} xtract_amp_tracker;
typedef struct _xtract_frame_tracker {
int frame_count;
- float *previous_frame;
+ double *previous_frame;
} xtract_frame_tracker;
#ifdef __cplusplus
diff --git a/xtract/xtract_vector.h b/xtract/xtract_vector.h
index 35ef6d0..f935da6 100644
--- a/xtract/xtract_vector.h
+++ b/xtract/xtract_vector.h
@@ -40,9 +40,9 @@ extern "C" {
/** \brief Extract frequency domain spectrum from time domain signal
*
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of array elements to be considered
- * \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second will be cast to an integer and determines the spectrum type (e.g. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM). The third argument determines whether or not the DC component is included in the output. If argv[2] == 1, then the DC component is included in which case the size of the array pointed to by *result must be N+2. For any further use of the array pointed to by *result, the value of N must reflect the (larger) array size. The fourth argument determines whether the magnitude/power coefficients are to be normalised. If argv[3] == 1, then the coefficients are normalised.
+ * \param *argv: a pointer to an array of doubles, the first representing (samplerate / N), the second will be cast to an integer and determines the spectrum type (e.g. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM). The third argument determines whether or not the DC component is included in the output. If argv[2] == 1, then the DC component is included in which case the size of the array pointed to by *result must be N+2. For any further use of the array pointed to by *result, the value of N must reflect the (larger) array size. The fourth argument determines whether the magnitude/power coefficients are to be normalised. If argv[3] == 1, then the coefficients are normalised.
* \param *result: a pointer to an array of size N containing N/2 magnitude/power/log magnitude/log power coefficients and N/2 bin frequencies.
*
* The magnitude/power coefficients are scaled to the range 0-1 so that for a given coefficient x, 0 <= x <= 1
@@ -50,16 +50,16 @@ extern "C" {
* \note Before calling xtract_spectrum(), the FFT must be initialised by calling xtract_init_fft(N, XTRACT_SPECTRUM)
*
*/
-int xtract_spectrum(const float *data, const int N, const void *argv, float *result);
+int xtract_spectrum(const double *data, const int N, const void *argv, double *result);
/** \brief Extract autocorrelation from time domain signal using FFT based method
*
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of array elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the autocorrelation of N values from the array pointed to by *data
*/
-int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result);
+int xtract_autocorrelation_fft(const double *data, const int N, const void *argv, double *result);
/** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner
*
@@ -70,45 +70,45 @@ int xtract_autocorrelation_fft(const float *data, const int N, const void *argv,
*
* The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
*/
-int xtract_mfcc(const float *data, const int N, const void *argv, float *result);
+int xtract_mfcc(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the Discrete Cosine transform of a time domain signal
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of array elements to be considered
* \param *argv: a pointer to NULL
* \param *result: a pointer to an array containing resultant dct coefficients
*/
-int xtract_dct(const float *data, const int N, const void *argv, float *result);
+int xtract_dct(const double *data, const int N, const void *argv, double *result);
/** \brief Extract autocorrelation from time domain signal using time-domain autocorrelation technique
*
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of array elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the autocorrelation of N values from the array pointed to by *data
*/
-int xtract_autocorrelation(const float *data, const int N, const void *argv, float *result);
+int xtract_autocorrelation(const double *data, const int N, const void *argv, double *result);
/** \brief Extract Average Magnitude Difference Function from time domain signal
*
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of array elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the AMDF of N values from the array pointed to by *data
*/
-int xtract_amdf(const float *data, const int N, const void *argv, float *result);
+int xtract_amdf(const double *data, const int N, const void *argv, double *result);
/** \brief Extract Average Squared Difference Function from time domain signal
*
- * \param *data: a pointer to the first element in an array of floats representing an audio vector
+ * \param *data: a pointer to the first element in an array of doubles representing an audio vector
* \param N: the number of array elements to be considered
* \param *argv: a pointer to NULL
* \param *result: the ASDF of N values from the array pointed to by *data
*/
-int xtract_asdf(const float *data, const int N, const void *argv, float *result);
+int xtract_asdf(const double *data, const int N, const void *argv, double *result);
/** \brief Extract Bark band coefficients based on a method
- * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the magnitude spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
+ * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the magnitude spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of array elements to be considered
* \param *argv: a pointer to an array of ints representing the limits of each bark band. This can be obtained by calling xtract_init_bark.
* \param *result: a pointer to an array containing resultant bark coefficients
@@ -116,24 +116,24 @@ int xtract_asdf(const float *data, const int N, const void *argv, float *result)
* The limits array pointed to by *argv must be obtained by first calling xtract_init_bark
*
*/
-int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result);
+int xtract_bark_coefficients(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the amplitude and frequency of spectral peaks from a magnitude spectrum
* \param *data: a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the size of the input array (note: it is assumed that enough memory has been allocated for an output array twice the size)
- * \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found
+ * \param *argv: a pointer to an array of doubles, the first representing (samplerate / N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found
* \param *result: a pointer to an array of size N * 2 containing N magnitude/power/log magnitude/log power coefficients and N bin frequencies.
*
*/
-int xtract_peak_spectrum(const float *data, const int N, const void *argv, float *result);
+int xtract_peak_spectrum(const double *data, const int N, const void *argv, double *result);
/** \brief Extract the harmonic spectrum of from a of a peak spectrum
- * \param *data: a pointer to the first element in an array of floats representing the peak spectrum of an audio vector (e.g. *result from xtract_peaks). It is expected that the first half of the array pointed to by *data will contain amplitudes for each peak considered, and the the second half will contain the respective frequencies
+ * \param *data: a pointer to the first element in an array of doubles representing the peak spectrum of an audio vector (e.g. *result from xtract_peaks). It is expected that the first half of the array pointed to by *data will contain amplitudes for each peak considered, and the the second half will contain the respective frequencies
* \param N: the size of the array pointed to by *data
* \param *argv: a pointer to an array containing the fundamental (f0) of the spectrum, and a threshold (t) where 0<=t<=1.0, and t determines the distance from the nearest harmonic number within which a partial can be considered harmonic.
* \param *result: a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies.
*/
-int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, float *result);
+int xtract_harmonic_spectrum(const double *data, const int N, const void *argv, double *result);
/** \brief Extract Linear Predictive Coding Coefficients
*
@@ -148,26 +148,26 @@ int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, f
*
* An array of size 2 * (N - 1) must be allocated, and *result must point to its first element.
*/
-int xtract_lpc(const float *data, const int N, const void *argv, float *result);
+int xtract_lpc(const double *data, const int N, const void *argv, double *result);
/** \brief Extract Linear Predictive Coding Cepstral Coefficients
*
* \param *data: a pointer to the first element in an array of LPC coeffiecients e.g. a pointer to the second half of the array pointed to by *result from xtract_lpc()
* \param N: the number of LPC coefficients to be considered
- * \param *argv: a pointer to a float representing the order of the result vector. This must be a whole number. According to Rabiner and Juang the ratio between the number (p) of LPC coefficients and the order (Q) of the LPC cepstrum is given by Q ~ (3/2)p where Q > p.
+ * \param *argv: a pointer to a double representing the order of the result vector. This must be a whole number. According to Rabiner and Juang the ratio between the number (p) of LPC coefficients and the order (Q) of the LPC cepstrum is given by Q ~ (3/2)p where Q > p.
* \param *result: a pointer to an array containing the resultant LPCC.
*
* An array of size Q, where Q is given by argv[0] must be allocated, and *result must point to its first element.
*
*/
-int xtract_lpcc(const float *data, const int N, const void *argv, float *result);
+int xtract_lpcc(const double *data, const int N, const void *argv, double *result);
/** \brief Extract subbands from a spectrum
*
* \param *data: a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum().
* \param N: the number of elements from the array pointed to by *data to be considered
* \param *argv: A pointer to an array containing four integers. The first represents the extraction function to applied to each subband e.g. XTRACT_SUM or XTRACT_MEAN, the second represents the number of subbands required, and the third represents the frequency scale to be used for the subband bounds as defined in the enumeration xtract_subband_scales_ (libxtract.h). The fourth integer represent the start point of the subbands as a location in the input array as pointed to by *data (e.g. a value of 5 would start the subband extraction at bin 5)
- * \param *result: A pointer to an array containing the resultant subband values. The calling function is responsible for allocating and freeing memory for *result. xtract_subbands() assumes that at least argv[1] * sizeof(float) bytes have been allocated. If the requested nbands extends the subband range beyond N, then the remaining bands will be set to 0. If the array pointed to by *result has more than argv[1] elements, the superfluous elements will be unchanged.
+ * \param *result: A pointer to an array containing the resultant subband values. The calling function is responsible for allocating and freeing memory for *result. xtract_subbands() assumes that at least argv[1] * sizeof(double) bytes have been allocated. If the requested nbands extends the subband range beyond N, then the remaining bands will be set to 0. If the array pointed to by *result has more than argv[1] elements, the superfluous elements will be unchanged.
*
* xtract_subbands() divides a spectrum into subbands and applies the function given by argv[0] to the values in each subband to give a 'reduced' representation of the spectrum as *result
*
@@ -178,7 +178,7 @@ int xtract_lpcc(const float *data, const int N, const void *argv, float *result)
* It is assumed that a sensible function will be given in argv[0], and for this function argv will always be NULL. Sensible values for argv[0] are XTRACT_MEAN and XTRACT_SUM, although something like XTRACT_IRREGULARITY_K might yield interesting results.
*
*/
-int xtract_subbands(const float *data, const int N, const void *argv, float *result);
+int xtract_subbands(const double *data, const int N, const void *argv, double *result);
/** @} */
#ifdef __cplusplus