shithub: aubio

Download patch

ref: 70585a5980d007d8aa3b52ad1bfa7263abb9a3e3
parent: b050e8e67ce54dad93add48e1a4549470cfc07bd
parent: 15b97d9f4f9078c1d82faa8ac8b71bc2334ce5ec
author: Paul Brossier <piem@piem.org>
date: Wed Nov 21 11:53:13 EST 2007

merge from main branch

--- a/.bzrignore
+++ b/.bzrignore
@@ -5,6 +5,10 @@
 **/*.lo
 **/*.la
 
+# gcov generated files
+**/*.gcno
+**/*.gcda
+
 # ignore compiled examples
 RE:examples/[a-z]*
 
@@ -33,6 +37,7 @@
 config.sub
 configure
 depcomp
+mkinstalldirs
 install-sh
 libtool
 ltmain.sh
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,3 +35,9 @@
 install-data-hook: install-pkgconfig
 uninstall-hook: uninstall-pkgconfig
 
+lcov: all
+	mkdir -p $(top_builddir)/lcov
+	lcov --directory $(top_builddir) --output-file $(top_builddir)/lcov/aubio.info --compat-libtool --zerocounters
+	cd tests/python && ./run_all_tests -v || echo "some tests failed"
+	lcov --directory $(top_builddir) --output-file $(top_builddir)/lcov/aubio.info --compat-libtool --capture
+	genhtml --output-directory $(top_builddir)/lcov $(top_builddir)/lcov/aubio.info 
--- a/configure.ac
+++ b/configure.ac
@@ -34,7 +34,7 @@
 
 dnl Enable debugging (no)
 AC_ARG_ENABLE(debug,
-  [  --enable-debug[[=value]]  compile with debug [[default=no]]],
+  AC_HELP_STRING([--enable-debug],[compile in debug mode [[default=no]]]),
   with_debug="yes",
   with_debug="no")
 if test "$with_debug" = "yes"
@@ -45,7 +45,7 @@
 
 dnl Enable full warnings (yes)
 AC_ARG_ENABLE(warnings,
-  [  --enable-warnings[[=value]] compile with all gcc warnings [[default=yes]]],
+  AC_HELP_STRING([--enable-warnings],[compile with all gcc warnings [[default=yes]]]),
   with_warnme="no",
   with_warnme="yes")
 if test "$with_warnme" = "yes"
@@ -66,10 +66,17 @@
   fi
 fi
 
+dnl fail on compilation warnings 
 AC_ARG_ENABLE(errorfail,
-  [  --enable-errorfail[[=value]]  fail on compilation warnings [[default=no]]],
+  AC_HELP_STRING([--enable-errorfail],[fail on compilation warnings [[default=no]]]),
   AUBIO_CFLAGS="$AUBIO_CFLAGS -Werror -Wmissing-prototypes -Wmissing-declarations -Wno-unused-parameter",
-  with_warnme="no")
+  with_errorfail="no")
+
+dnl add gcov/lcov profiling and coverage flags
+AC_ARG_ENABLE(lcov,
+  AC_HELP_STRING([--enable-lcov],[compile with gcov/lcov profiling flags [[default=no]]]),
+  AUBIO_CFLAGS="$AUBIO_CFLAGS -fprofile-arcs -ftest-coverage",
+  with_lcov="no")
 
 dnl Check for libtool
 AC_LIBTOOL_DLOPEN
--- a/examples/aubioonset.c
+++ b/examples/aubioonset.c
@@ -71,8 +71,8 @@
        * actual onset */
       if (isonset && output_filename == NULL) {
         if(frames >= 4) {
-          outmsg("%f\n",(frames-4)*overlap_size/(float)samplerate);
-        } else if (frames < 4) {
+          outmsg("%f\n",(frames-frames_delay)*overlap_size/(float)samplerate);
+        } else if (frames < frames_delay) {
           outmsg("%f\n",0.);
         }
       }
@@ -79,6 +79,7 @@
 }
 
 int main(int argc, char **argv) {
+  frames_delay = 4;
   examples_common_init(argc,argv);
   examples_common_process(aubio_process,process_print);
   examples_common_del();
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -21,6 +21,7 @@
 int lash_main (void);
 void save_data (void);
 void restore_data(lash_config_t * lash_config);
+void flush_process(aubio_process_func_t process_func, aubio_print_func_t print);
 pthread_t lash_thread;
 #endif /* LASH_SUPPORT */
 
@@ -32,6 +33,7 @@
 int verbose = 0;
 int usejack = 0;
 int usedoubled = 1;
+int frames_delay = 0;
 
 
 /* energy,specdiff,hfc,complexdomain,phase */
@@ -394,6 +396,8 @@
     }
 
     debug("Processed %d frames of %d samples.\n", frames, buffer_size);
+
+    flush_process(process_func, print);
     del_aubio_sndfile(file);
 
     if (output_filename != NULL)
@@ -402,6 +406,18 @@
   }
 }
 
+void flush_process(aubio_process_func_t process_func, aubio_print_func_t print){
+  uint i,j;
+  for (i = 0; i < channels; i++) {
+    for (j = 0; j < obuf->length; j++) {
+      fvec_write_sample(obuf,0.,i,j);
+    }
+  }
+  for (i = 0; (signed)i < frames_delay; i++) {
+    process_func(ibuf->data, obuf->data, overlap_size);
+    print(); 
+  }
+}
 
 
 void send_noteon(int pitch, int velo)
--- a/examples/utils.h
+++ b/examples/utils.h
@@ -41,6 +41,7 @@
 extern int verbose;
 extern int usejack;
 extern int usedoubled;
+extern int frames_delay;
 extern unsigned int median;
 extern const char * output_filename;
 extern const char * input_filename;
--- a/src/fft.c
+++ b/src/fft.c
@@ -45,7 +45,7 @@
   uint_t channels;
   uint_t fft_size;
   real_t *in, *out;
-  fftw_plan   pfw, pbw;
+  fftw_plan pfw, pbw;
   fft_data_t * specdata;     /* complex spectral data */
   fvec_t * compspec;
 };
@@ -60,7 +60,7 @@
   s->compspec = new_fvec(winsize,channels);
   /* create plans */
 #ifdef HAVE_COMPLEX_H
-  s->fft_size = winsize/2+1;
+  s->fft_size = winsize/2 + 1;
   s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size);
   s->pfw = fftw_plan_dft_r2c_1d(winsize, s->in,  s->specdata, FFTW_ESTIMATE);
   s->pbw = fftw_plan_dft_c2r_1d(winsize, s->specdata, s->out, FFTW_ESTIMATE);
@@ -101,7 +101,7 @@
       s->in[j] = input->data[i][j];
     }
     fftw_execute(s->pfw);
-#if HAVE_COMPLEX_H
+#ifdef HAVE_COMPLEX_H
     compspec->data[i][0] = REAL(s->specdata[0]);
     for (j = 1; j < s->fft_size -1 ; j++) {
       compspec->data[i][j] = REAL(s->specdata[j]);
@@ -120,7 +120,7 @@
   uint_t i, j;
   const smpl_t renorm = 1./(smpl_t)s->winsize;
   for (i = 0; i < compspec->channels; i++) {
-#if HAVE_COMPLEX_H
+#ifdef HAVE_COMPLEX_H
     s->specdata[0] = compspec->data[i][0];
     for (j=1; j < s->fft_size - 1; j++) {
       s->specdata[j] = compspec->data[i][j] + 
--- a/src/onsetdetection.c
+++ b/src/onsetdetection.c
@@ -283,10 +283,6 @@
 	return o;
 }
 
-void aubio_onsetdetection_free (aubio_onsetdetection_t *o){
-  del_aubio_onsetdetection(o);
-}
-
 void del_aubio_onsetdetection (aubio_onsetdetection_t *o){
 
 	switch(o->type) {
--- a/src/onsetdetection.h
+++ b/src/onsetdetection.h
@@ -160,13 +160,6 @@
 
 */
 void del_aubio_onsetdetection(aubio_onsetdetection_t *o);
-/** deletion of an onset detection object (obsolete)
-
-  \param o onset detection object as returned by new_aubio_onsetdetection()
-
-*/
-void aubio_onsetdetection_free(aubio_onsetdetection_t *o);
-
 
 #ifdef __cplusplus
 }
--- a/src/pitchyinfft.c
+++ b/src/pitchyinfft.c
@@ -137,7 +137,7 @@
         return vec_quadint_min(yin,tau,1);
     }
   } else
-    return 0;
+    return 0.;
 }
 
 void del_aubio_pitchyinfft(aubio_pitchyinfft_t *p){
--- a/swig/aubio.i
+++ b/swig/aubio.i
@@ -177,7 +177,6 @@
 } aubio_onsetdetection_type;
 aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels);
 void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
-void aubio_onsetdetection_free(aubio_onsetdetection_t *o);
 
 /* should these still be exposed ? */
 void aubio_onsetdetection_energy  (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset);
--- a/tests/src/Makefile.am
+++ b/tests/src/Makefile.am
@@ -6,7 +6,6 @@
 
 bin_PROGRAMS = \
 	test-fft \
-	test-mfft \
 	test-hist \
 	test-scale \
 	test-cvec \
--- a/tests/src/test-fft.c
+++ b/tests/src/test-fft.c
@@ -1,57 +1,28 @@
-#include <stdlib.h>
-#include <math.h>
-#include <complex.h>
+
 #include <aubio.h>
 
-#define NEW_ARRAY(_t,_n)		(_t*)malloc((_n)*sizeof(_t))
-
-
 int main(){
-        uint_t i,j;
-        uint_t win_s      = 1024;                       // window size
-        uint_t channels   = 1;                          // number of channel
-        fvec_t * in       = new_fvec (win_s, channels); // input buffer
-        cvec_t * fftgrain = new_cvec (win_s, channels); // fft norm and phase
-        fvec_t * out      = new_fvec (win_s, channels); // output buffer
-  
-        // allocate fft and other memory space
-        aubio_fft_t * fft      = new_aubio_fft(win_s);    // fft interface
-        smpl_t * w             = NEW_ARRAY(smpl_t,win_s); // window
-        // complex spectral data
-        fft_data_t ** spec     = NEW_ARRAY(fft_data_t*,channels); 
-        for (i=0; i < channels; i++)
-                spec[i] = NEW_ARRAY(fft_data_t,win_s);
-        // initialize the window (see mathutils.c)
-        aubio_window(w,win_s,aubio_win_hanningz);
-  
-        // fill input with some data
-        in->data[0][win_s/2] = 1;
-  
-        // execute stft
-        for (i=0; i < channels; i++) {
-                aubio_fft_do (fft,in->data[i],spec[i],win_s);
-                // put norm and phase into fftgrain
-                aubio_fft_getnorm(fftgrain->norm[i], spec[i], win_s/2+1);
-                aubio_fft_getphas(fftgrain->phas[i], spec[i], win_s/2+1);
-        }
-  
-        // execute inverse fourier transform
-        for (i=0; i < channels; i++) {
-                for (j=0; j<win_s/2+1; j++) {
-                        spec[i][j]  = cexp(I*aubio_unwrap2pi(fftgrain->phas[i][j]));
-                        spec[i][j] *= fftgrain->norm[i][j];
-                }
-                aubio_fft_rdo(fft,spec[i],out->data[i],win_s);
-        }
-
+        /* allocate some memory */
+        uint_t win_s      = 4096;                       /* window size        */
+        uint_t channels   = 100;                        /* number of channels */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer       */
+        cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
+        fvec_t * out      = new_fvec (win_s, channels); /* output buffer      */
+        /* allocate fft and other memory space */
+        aubio_fft_t * fft = new_aubio_fft(win_s,channels);
+        /* fill input with some data */
+        //printf("initialised\n");
+        /* execute stft */
+        aubio_fft_do (fft,in,fftgrain);
+        //printf("computed forward\n");
+        /* execute inverse fourier transform */
+        aubio_fft_rdo(fft,fftgrain,out);
+        //printf("computed backard\n");
+        del_aubio_fft(fft);
         del_fvec(in);
-        del_fvec(out);
         del_cvec(fftgrain);
-        free(w);
-        del_aubio_fft(fft);
-        for (i=0; i < channels; i++)
-                free(spec[i]);
-        free(spec); 
+        del_fvec(out);
+        //printf("memory freed\n");
         aubio_cleanup();
         return 0;
 }
--- a/tests/src/test-mfft.c
+++ /dev/null
@@ -1,28 +1,0 @@
-
-#include <aubio.h>
-
-int main(){
-        /* allocate some memory */
-        uint_t win_s      = 4096;                       /* window size        */
-        uint_t channels   = 100;                        /* number of channels */
-        fvec_t * in       = new_fvec (win_s, channels); /* input buffer       */
-        cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
-        fvec_t * out      = new_fvec (win_s, channels); /* output buffer      */
-        /* allocate fft and other memory space */
-        aubio_mfft_t * fft = new_aubio_mfft(win_s,channels);
-        /* fill input with some data */
-        //printf("initialised\n");
-        /* execute stft */
-        aubio_mfft_do (fft,in,fftgrain);
-        //printf("computed forward\n");
-        /* execute inverse fourier transform */
-        aubio_mfft_rdo(fft,fftgrain,out);
-        //printf("computed backard\n");
-        del_aubio_mfft(fft);
-        del_fvec(in);
-        del_cvec(fftgrain);
-        del_fvec(out);
-        //printf("memory freed\n");
-        aubio_cleanup();
-        return 0;
-}