aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am14
-rw-r--r--src/libxtract.c40
-rw-r--r--src/vector.c131
3 files changed, 106 insertions, 79 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1ef2862..ddfdb2e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,17 +1,15 @@
-SOURCES = libxtract.c scalar.c delta.c init.c
+SOURCES = libxtract.c scalar.c vector.c delta.c init.c
-if BUILD_VECTOR
-VECTOR = vector.c
-VECTOR_DEFINE = -DVECTORFUNCS
+if BUILD_FFT
+FFT_DEFINE = -DXTRACT_FFT
else
-VECTOR =
-VECTOR_DEFINE =
+FFT_DEFINE =
endif
lib_LTLIBRARIES = libxtract.la
-libxtract_la_CFLAGS = $(VECTOR_DEFINE)
-libxtract_la_SOURCES = $(SOURCES) $(VECTOR)
+libxtract_la_CFLAGS = $(FFT_DEFINE)
+libxtract_la_SOURCES = $(SOURCES)
libxtract_la_LDFLAGS = -shared
diff --git a/src/libxtract.c b/src/libxtract.c
index 14b089d..ad03ffc 100644
--- a/src/libxtract.c
+++ b/src/libxtract.c
@@ -54,23 +54,21 @@ int(*xtract[])(float *, int, void *, float *) = {
xtract_lowest_match,
xtract_hps,
xtract_f0,
- /* xtract_vector.h */
-#ifdef VECTORFUNCS
- xtract_magnitude_spectrum,
+/* xtract_delta.h */
+ xtract_flux,
+ xtract_attack_time,
+ xtract_decay_time,
+ xtract_delta_feature,
+/* xtract_vector.h */
xtract_autocorrelation,
- xtract_autocorrelation_fft,
xtract_amdf,
xtract_asdf,
- xtract_mfcc,
- xtract_dct,
xtract_bark_coefficients,
xtract_peaks,
-#endif
- /* xtract_delta.h */
- xtract_flux,
- xtract_attack_time,
- xtract_decay_time,
- xtract_delta_feature
+ xtract_magnitude_spectrum,
+ xtract_autocorrelation_fft,
+ xtract_mfcc,
+ xtract_dct
};
char *xtract_help_strings[] = {
@@ -104,17 +102,17 @@ char *xtract_help_strings[] = {
"xtract_lowest_match",
"xtract_hps",
"xtract_f0",
- "xtract_magnitude_spectrum",
+ "xtract_flux",
+ "xtract_attack_time",
+ "xtract_decay_time",
+ "xtract_delta_feature"
"xtract_autocorrelation",
- "xtract_autocorrelation_fft",
"xtract_amdf",
"xtract_asdf",
- "xtract_mfcc",
- "xtract_dct",
"xtract_bark_coefficients",
"xtract_peaks",
- "xtract_flux",
- "xtract_attack_time",
- "xtract_decay_time",
- "xtract_delta_feature"
-};
+ "xtract_magnitude_spectrum",
+ "xtract_autocorrelation_fft",
+ "xtract_mfcc",
+ "xtract_dct",
+ };
diff --git a/src/vector.c b/src/vector.c
index 9827bbe..8bc6f41 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -23,6 +23,9 @@
#include "xtract/libxtract.h"
#include <math.h>
+
+#ifdef XTRACT_FFT
+
#include <fftw3.h>
int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result){
@@ -50,23 +53,6 @@ int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result){
}
-int xtract_autocorrelation(float *data, int N, void *argv, float *result){
-
- /* Naive time domain implementation */
-
- int n = N, i;
-
- float corr;
-
- while(n--){
- corr = 0;
- for(i = 0; i < N - n; i++){
- corr += data[i] * data[i + n];
- }
- result[n] = corr / N;
- }
-}
-
int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result){
float *temp;
@@ -85,39 +71,6 @@ int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result){
fftwf_free(temp);
}
-int xtract_amdf(float *data, int N, void *argv, float *result){
-
- int n = N, i;
-
- float md, temp;
-
- while(n--){
- md = 0;
- for(i = 0; i < N - n; i++){
- temp = data[i] - data[i + n];
- temp = (temp < 0 ? -temp : temp);
- md += temp;
- }
- result[n] = md / N;
- }
-}
-
-int xtract_asdf(float *data, int N, void *argv, float *result){
-
- int n = N, i;
-
- float sd;
-
- while(n--){
- sd = 0;
- for(i = 0; i < N - n; i++){
- /*sd = 1;*/
- sd += SQ(data[i] - data[i + n]);
- }
- result[n] = sd / N;
- }
-}
-
int xtract_mfcc(float *data, int N, void *argv, float *result){
xtract_mel_filter *f;
@@ -151,6 +104,84 @@ int xtract_dct(float *data, int N, void *argv, float *result){
fftwf_destroy_plan(plan);
}
+#else
+
+int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result){
+
+ NOT_IMPLEMENTED;
+
+}
+
+int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result){
+
+ NOT_IMPLEMENTED;
+
+}
+
+int xtract_mfcc(float *data, int N, void *argv, float *result){
+
+ NOT_IMPLEMENTED;
+
+}
+
+int xtract_dct(float *data, int N, void *argv, float *result){
+
+ NOT_IMPLEMENTED;
+
+}
+
+#endif
+
+int xtract_autocorrelation(float *data, int N, void *argv, float *result){
+
+ /* Naive time domain implementation */
+
+ int n = N, i;
+
+ float corr;
+
+ while(n--){
+ corr = 0;
+ for(i = 0; i < N - n; i++){
+ corr += data[i] * data[i + n];
+ }
+ result[n] = corr / N;
+ }
+}
+
+int xtract_amdf(float *data, int N, void *argv, float *result){
+
+ int n = N, i;
+
+ float md, temp;
+
+ while(n--){
+ md = 0;
+ for(i = 0; i < N - n; i++){
+ temp = data[i] - data[i + n];
+ temp = (temp < 0 ? -temp : temp);
+ md += temp;
+ }
+ result[n] = md / N;
+ }
+}
+
+int xtract_asdf(float *data, int N, void *argv, float *result){
+
+ int n = N, i;
+
+ float sd;
+
+ while(n--){
+ sd = 0;
+ for(i = 0; i < N - n; i++){
+ /*sd = 1;*/
+ sd += SQ(data[i] - data[i + n]);
+ }
+ result[n] = sd / N;
+ }
+}
+
int xtract_bark_coefficients(float *data, int N, void *argv, float *result){
int *limits, band, n;