aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2006-10-20 12:30:46 +0000
committerJamie Bullock <jamie@postlude.co.uk>2006-10-20 12:30:46 +0000
commit26b8e9773d86c259b7faa2d20846ca5ac3862281 (patch)
tree59645cf6472b11bb06fe4d60b7c42e3c205dc3d8
parenta642a56300874cabc18848d29d0b8cb882fa48db (diff)
downloadLibXtract-26b8e9773d86c259b7faa2d20846ca5ac3862281.tar.gz
LibXtract-26b8e9773d86c259b7faa2d20846ca5ac3862281.tar.bz2
LibXtract-26b8e9773d86c259b7faa2d20846ca5ac3862281.zip
Replaced --enable-vector with --enable-fft and improved build
-rw-r--r--config.h.in6
-rw-r--r--configure.in24
-rw-r--r--doc/documentation.doxygen.in2
-rw-r--r--src/Makefile.am14
-rw-r--r--src/libxtract.c40
-rw-r--r--src/vector.c131
-rw-r--r--xtract/Makefile.am8
-rw-r--r--xtract/libxtract.h19
-rw-r--r--xtract/xtract_vector.h47
9 files changed, 156 insertions, 135 deletions
diff --git a/config.h.in b/config.h.in
index 120d8f5..b05b0e5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,14 +1,14 @@
/* config.h.in. Generated from configure.in by autoheader. */
+/* Build the fft functions */
+#undef BUILD_FFT
+
/* Build the pd example */
#undef BUILD_PD_EXAMPLE
/* Build the simpletest example */
#undef BUILD_SIMPLETEST
-/* Build the vector functions */
-#undef BUILD_VECTOR
-
/* Define to enable debug */
#undef DEBUG
diff --git a/configure.in b/configure.in
index 4f38526..81dc360 100644
--- a/configure.in
+++ b/configure.in
@@ -25,13 +25,13 @@ AC_CHECK_HEADERS([math.h, stdlib.h, stdio.h])
AC_CHECK_PROG([DOXYGEN], [doxygen], [doc], [])
AC_SUBST(DOXYGEN)
-AC_ARG_ENABLE(vector,
- [ --enable-vector Turn fft-based vector processing on],
+AC_ARG_ENABLE(fft,
+ [ --enable-fft Turn fft-based fft processing on],
[case "${enableval}" in
- yes) vector=true ;;
- no) vector=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-vector) ;;
- esac],[vector=false])
+ yes) fft=true ;;
+ no) fft=false ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-fft) ;;
+ esac],[fft=false])
AC_ARG_ENABLE(pd_example,
[ --enable-pd_example Compile the Pure Data external example],
@@ -86,9 +86,9 @@ AC_ARG_WITH(fftw3_dir,
])
dnl Are we building with fftw?
-if [[ "$vector" = "true" ]] ; then
+if [[ "$fft" = "true" ]] ; then
LDFLAGS="$LDFLAGS -lfftw3f"
- AC_DEFINE([BUILD_VECTOR], [1], [Build the vector functions])
+ AC_DEFINE([BUILD_FFT], [1], [Build the fft functions])
AC_CHECK_HEADER(fftw3.h, [have_fftw3_hdr=yes ], [
have_pd_hdr=no
echo
@@ -98,7 +98,7 @@ if [[ "$vector" = "true" ]] ; then
])
fi
-AM_CONDITIONAL(BUILD_VECTOR, test "x${vector}" = 'xtrue')
+AM_CONDITIONAL(BUILD_FFT, test "x${fft}" = 'xtrue')
dnl are we building the simpletest example
@@ -221,10 +221,10 @@ echo "Summary:"
echo
dnl echo you are using the ${host} architecture
-if test "$vector" = "true"; then
- echo "Fftw3: yes (using fftw3f)"
+if test "$fft" = "true"; then
+ echo "fft: yes (using fftw3f)"
else
- echo "Fftw3: no (not using fftw3, no vector functions)"
+ echo "fft: no (not using fftw3, no fft functions)"
fi
if test "$simpletest" = "true"; then
echo "simpletest example: yes"
diff --git a/doc/documentation.doxygen.in b/doc/documentation.doxygen.in
index c1c18ee..eca850d 100644
--- a/doc/documentation.doxygen.in
+++ b/doc/documentation.doxygen.in
@@ -1005,7 +1005,7 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
-PREDEFINED = XTRACT
+PREDEFINED = XTRACT XTRACT_FFT
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
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;
diff --git a/xtract/Makefile.am b/xtract/Makefile.am
index 0dd9942..b29e60d 100644
--- a/xtract/Makefile.am
+++ b/xtract/Makefile.am
@@ -1,11 +1,5 @@
libxtractdir = $(includedir)/xtract
-if BUILD_VECTOR
-XTRACT_VECTOR = xtract_vector.h
-else
-XTRACT_VECTOR =
-endif
-
libxtract_HEADERS = libxtract.h xtract_macros.h xtract_types.h xtract_delta.h \
- xtract_scalar.h $(XTRACT_VECTOR)
+ xtract_scalar.h xtract_vector.h
diff --git a/xtract/libxtract.h b/xtract/libxtract.h
index 6b90da3..235353e 100644
--- a/xtract/libxtract.h
+++ b/xtract/libxtract.h
@@ -53,7 +53,8 @@ extern "C" {
* @{
*/
-#define XTRACT_FEATURES 43
+#define XTRACT_FEATURES 42
+
#define LOG_LIMIT 10e-10
#define VERY_BIG_NUMBER 2e10
#define SR_LIMIT 192000
@@ -91,19 +92,19 @@ enum features_ {
LOWEST_MATCH,
HPS,
F0,
- MAGNITUDE_SPECTRUM,
+ FLUX,
+ ATTACK_TIME,
+ DECAY_TIME,
+ DELTA_FEATURE,
AUTOCORRELATION,
- AUTOCORRELATION_FFT,
AMDF,
ASDF,
- MFCC,
- DCT,
BARK_COEFFICIENTS,
PEAKS,
- FLUX,
- ATTACK_TIME,
- DECAY_TIME,
- DELTA_FEATURE
+ MAGNITUDE_SPECTRUM,
+ AUTOCORRELATION_FFT,
+ MFCC,
+ DCT
};
/** \brief Enumeration of feature types */
diff --git a/xtract/xtract_vector.h b/xtract/xtract_vector.h
index fc39aa7..d72d051 100644
--- a/xtract/xtract_vector.h
+++ b/xtract/xtract_vector.h
@@ -43,24 +43,42 @@ extern "C" {
*/
int xtract_magnitude_spectrum(float *data, int N, void *argv, float *result);
-
-/** \brief Extract autocorrelation from time domain signal using time-domain autocorrelation technique
+/** \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 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(float *data, int N, void *argv, float *result);
+int xtract_autocorrelation_fft(float *data, int N, void *argv, float *result);
-/** \brief Extract autocorrelation from time domain signal using FFT based method
+/** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner
+ *
+ * \param *data: a pointer to the first element in an array of floats
+ * \param N: the number of array elements to be considered
+ * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank
+ * \param *result: a pointer to an array containing the resultant MFCC
+ *
+ * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
+ */
+int xtract_mfcc(float *data, int N, void *argv, float *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 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(float *data, int N, void *argv, float *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 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(float *data, int N, void *argv, float *result);
+int xtract_autocorrelation(float *data, int N, void *argv, float *result);
/** \brief Extract Average Magnitude Difference Function from time domain signal
*
@@ -80,17 +98,6 @@ int xtract_amdf(float *data, int N, void *argv, float *result);
*/
int xtract_asdf(float *data, int N, void *argv, float *result);
-/** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner
- *
- * \param *data: a pointer to the first element in an array of floats
- * \param N: the number of array elements to be considered
- * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank
- * \param *result: a pointer to an array containing the resultant MFCC
- *
- * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
- */
-int xtract_mfcc(float *data, int N, void *argv, float *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 spectrum of an audio vector
* \param N: the number of array elements to be considered
@@ -102,14 +109,6 @@ int xtract_mfcc(float *data, int N, void *argv, float *result);
*/
int xtract_bark_coefficients(float *data, int N, void *argv, float *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 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(float *data, int N, void *argv, float *result);
-
/** \brief Extract the frequency and amplitude of spectral peaks from a of a magnitude spectrum
* \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
* \param N: the number of array elements to be considered