From df6ca885dba5d131417c709366efbe2ff524dda6 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Fri, 20 Apr 2007 08:49:49 +0000 Subject: Fixed autocorrelation_fft() it now gives comparable output to autocorrelation() --- ChangeLog | 5 +++ Makefile.am | 2 ++ config.h.in | 79 ------------------------------------------- configure.in | 2 +- examples/Makefile.am | 2 ++ examples/puredata/Makefile.am | 1 + src/Makefile.am | 3 +- src/vector.c | 42 ++++++++++++++++------- xtract/Makefile.am | 2 ++ 9 files changed, 44 insertions(+), 94 deletions(-) delete mode 100644 config.h.in diff --git a/ChangeLog b/ChangeLog index 1b2b5cb..fbaebcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-04-20 Jamie Bullock + * version 0.4.5 + * Fixed autocorrelation_fft() + * Added MAINTAINERCLEAN files to Makefile.am + 2007-03-14 Jamie Bullock * version 0.4.4 * Fixed return value macros for functions if fftw not used diff --git a/Makefile.am b/Makefile.am index 2bca8d8..6642025 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ + SUBDIRS = src xtract examples @DOXYGEN@ pkgconfigdir = $(libdir)/pkgconfig diff --git a/config.h.in b/config.h.in deleted file mode 100644 index babd7f3..0000000 --- a/config.h.in +++ /dev/null @@ -1,79 +0,0 @@ -/* 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 - -/* Define to enable debug */ -#undef DEBUG - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MATH_H_ - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H_ - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* LibXtract Version */ -#undef LIBXTRACT_VERSION - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION diff --git a/configure.in b/configure.in index 9c3c27b..8632634 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ m4_define(libxtract_major_version, 0) # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 4) +m4_define(libxtract_fix_version, 5) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) diff --git a/examples/Makefile.am b/examples/Makefile.am index 7e0e052..46acfbc 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,3 +1,5 @@ +MAINTAINERCLEANFILES = Makefile.in + if BUILD_PD_EXAMPLE PUREDATA_DIR = puredata endif diff --git a/examples/puredata/Makefile.am b/examples/puredata/Makefile.am index ec5c197..a86acb3 100644 --- a/examples/puredata/Makefile.am +++ b/examples/puredata/Makefile.am @@ -1,3 +1,4 @@ +MAINTAINERCLEANFILES = Makefile.in SUFFIXES = .@PD_SUFFIX@ PDDIR = $(prefix)/lib/pd diff --git a/src/Makefile.am b/src/Makefile.am index 66f4198..8dc7691 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,4 @@ - - +MAINTAINERCLEANFILES = Makefile.in SOURCES = libxtract.c descriptors.c scalar.c vector.c delta.c init.c diff --git a/src/vector.c b/src/vector.c index 97e087b..17733b9 100644 --- a/src/vector.c +++ b/src/vector.c @@ -156,25 +156,43 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *res int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result){ - float *temp, *input; - size_t bytes; - int n; + float *freq, *time; + int n, M; fftwf_plan plan; - temp = (float *)fftwf_malloc(N * sizeof(float)); - input = (float *)malloc(bytes = N * sizeof(float)); - input = memcpy(input, data, bytes); + M = N << 1; + + freq = (float *)fftwf_malloc(M * sizeof(float)); + /* Zero pad the input vector */ + time = (float *)calloc(M, sizeof(float)); + time = memcpy(time, data, N * sizeof(float)); - plan = fftwf_plan_r2r_1d(N, input, temp, FFTW_HC2R, FFTW_ESTIMATE); + plan = fftwf_plan_r2r_1d(M, time, freq, FFTW_R2HC, FFTW_ESTIMATE); fftwf_execute(plan); + + for(n = 1; n < M / 2; n++){ + freq[n] = XTRACT_SQ(freq[n]) + XTRACT_SQ(freq[M - n]); + freq[M - n] = 0.f; + } - for(n = 0; n < N - 1; n++) - result[n] = temp[n+1]; - + freq[0] = XTRACT_SQ(freq[0]); + freq[N] = XTRACT_SQ(freq[N]); + + plan = fftwf_plan_r2r_1d(M, freq, time, FFTW_HC2R, FFTW_ESTIMATE); + + fftwf_execute(plan); + + /* Normalisation factor */ + M = M * N; + + for(n = 0; n < N; n++) + result[n] = time[n] / (float)M; + /* result[n] = time[n+1] / (float)M; */ + fftwf_destroy_plan(plan); - fftwf_free(temp); - free(input); + fftwf_free(freq); + free(time); return XTRACT_SUCCESS; } diff --git a/xtract/Makefile.am b/xtract/Makefile.am index b29e60d..eca7030 100644 --- a/xtract/Makefile.am +++ b/xtract/Makefile.am @@ -1,3 +1,5 @@ +MAINTAINERCLEANFILES = Makefile.in + libxtractdir = $(includedir)/xtract libxtract_HEADERS = libxtract.h xtract_macros.h xtract_types.h xtract_delta.h \ -- cgit v1.2.3