changeset 75:ee2e1acbf2a8

Fixed autocorrelation_fft() it now gives comparable output to autocorrelation()
author Jamie Bullock <jamie@postlude.co.uk>
date Fri, 20 Apr 2007 08:49:49 +0000
parents de94190a63b7
children f913cf823628
files ChangeLog Makefile.am config.h.in configure.in examples/Makefile.am examples/puredata/Makefile.am src/Makefile.am src/vector.c xtract/Makefile.am
diffstat 9 files changed, 44 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Apr 04 10:25:47 2007 +0000
+++ b/ChangeLog	Fri Apr 20 08:49:49 2007 +0000
@@ -1,3 +1,8 @@
+2007-04-20 Jamie Bullock <jamie@postlude.co.uk>
+    * version 0.4.5
+	* Fixed autocorrelation_fft()
+	* Added MAINTAINERCLEAN files to Makefile.am 
+
 2007-03-14 Jamie Bullock <jamie@postlude.co.uk>
     * version 0.4.4
 	* Fixed return value macros for functions if fftw not used
--- a/Makefile.am	Wed Apr 04 10:25:47 2007 +0000
+++ b/Makefile.am	Fri Apr 20 08:49:49 2007 +0000
@@ -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
--- a/config.h.in	Wed Apr 04 10:25:47 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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 <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <math.h,> header file. */
-#undef HAVE_MATH_H_
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdio.h> header file. */
-#undef HAVE_STDIO_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <stdlib.h,> header file. */
-#undef HAVE_STDLIB_H_
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> 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
--- a/configure.in	Wed Apr 04 10:25:47 2007 +0000
+++ b/configure.in	Fri Apr 20 08:49:49 2007 +0000
@@ -4,7 +4,7 @@
 # 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)
 		
--- a/examples/Makefile.am	Wed Apr 04 10:25:47 2007 +0000
+++ b/examples/Makefile.am	Fri Apr 20 08:49:49 2007 +0000
@@ -1,3 +1,5 @@
+MAINTAINERCLEANFILES = Makefile.in 
+
 if BUILD_PD_EXAMPLE 
 PUREDATA_DIR = puredata
 endif
--- a/examples/puredata/Makefile.am	Wed Apr 04 10:25:47 2007 +0000
+++ b/examples/puredata/Makefile.am	Fri Apr 20 08:49:49 2007 +0000
@@ -1,3 +1,4 @@
+MAINTAINERCLEANFILES = Makefile.in
 
 SUFFIXES = .@PD_SUFFIX@
 PDDIR = $(prefix)/lib/pd
--- a/src/Makefile.am	Wed Apr 04 10:25:47 2007 +0000
+++ b/src/Makefile.am	Fri Apr 20 08:49:49 2007 +0000
@@ -1,5 +1,4 @@
-
-
+MAINTAINERCLEANFILES = Makefile.in
 
 SOURCES = libxtract.c descriptors.c scalar.c vector.c delta.c init.c
 
--- a/src/vector.c	Wed Apr 04 10:25:47 2007 +0000
+++ b/src/vector.c	Fri Apr 20 08:49:49 2007 +0000
@@ -156,25 +156,43 @@
 
 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;
 
-    plan = fftwf_plan_r2r_1d(N, input, temp, FFTW_HC2R, FFTW_ESTIMATE);
+    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(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;
 }
--- a/xtract/Makefile.am	Wed Apr 04 10:25:47 2007 +0000
+++ b/xtract/Makefile.am	Fri Apr 20 08:49:49 2007 +0000
@@ -1,3 +1,5 @@
+MAINTAINERCLEANFILES = Makefile.in
+
 libxtractdir = $(includedir)/xtract
 
 libxtract_HEADERS = libxtract.h xtract_macros.h xtract_types.h xtract_delta.h \