shithub: aubio

Download patch

ref: 437fa65d085d43c60cc57511c6ae9712a901e2d9
parent: ccfafb2d4db682e1c846ee5c23f3320c05f79e05
author: Paul Brossier <piem@altern.org>
date: Mon Aug 8 22:27:58 EDT 2005

added examples, bumped VERSION to 0.2.0beta1

--- a/VERSION
+++ b/VERSION
@@ -1,5 +1,5 @@
 AUBIO_MAJOR_VERSION=0
-AUBIO_MINOR_VERSION=1
-AUBIO_PATCH_VERSION=9
-AUBIO_VERSION_STATUS=beta5
+AUBIO_MINOR_VERSION=2
+AUBIO_PATCH_VERSION=0
+AUBIO_VERSION_STATUS=beta1
 
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,7 +1,9 @@
-#SUBDIRS=onsets
+if COMPILE_TESTS 
+SUBDIRS = tests
+endif
 
 # global flags
-AM_CFLAGS = -I../src -I../ext @LADCCA_CFLAGS@
+AM_CFLAGS = -I$(srcdir)/../src -I$(srcdir)/../ext @LADCCA_CFLAGS@
 AM_LDFLAGS = -L../src -L../ext @LADCCA_LIBS@ -laubioext -laubio
 #AM_SOURCES = utils.c
 
@@ -10,7 +12,7 @@
 	aubioonset \
 	aubiotrack \
 	aubionotes
-	
+
 EXTRA_DIST = utils.h
 
 # optionally add sources file for these programs
--- /dev/null
+++ b/examples/tests/Makefile.am
@@ -1,0 +1,9 @@
+AM_CFLAGS = -I$(srcdir)/../../src -I$(srcdir)/../../ext @LADCCA_CFLAGS@
+AM_LDFLAGS = -L../../src -L../../ext @LADCCA_LIBS@ -laubioext -laubio
+LDADD = @JACK_LIBS@
+
+bin_PROGRAMS = \
+	test-fft \
+	test-mfft \
+	test-phasevoc \
+	test-phasevoc-jack
--- /dev/null
+++ b/examples/tests/test-fft.c
@@ -1,0 +1,43 @@
+
+#include "aubio_priv.h"
+#include "aubio.h"
+
+int main(){
+        uint_t i,j;
+        /* allocate some memory */
+        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);              /* fftw interface */
+        smpl_t * w             = AUBIO_ARRAY(smpl_t,win_s);         /* window */
+        /* complex spectral data */
+        fft_data_t ** spec      = AUBIO_ARRAY(fft_data_t*,channels); 
+        for (i=0; i < channels; i++)
+                spec[i] = AUBIO_ARRAY(fft_data_t,win_s);
+        /* initialize the window (see mathutils.c) */
+        window(w,win_s,hanningz);
+  
+        /* fill input with some data */
+  
+        /* 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]  = CEXPC(I*unwrap2pi(fftgrain->phas[i][j]));
+                        spec[i][j] *= fftgrain->norm[i][j];
+                }
+                aubio_fft_rdo(fft,spec[i],out->data[i],win_s);
+        }
+        return 0;
+}
--- /dev/null
+++ b/examples/tests/test-mfft.c
@@ -1,0 +1,27 @@
+
+#include "aubio.h"
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 4096;                       /* window size        */
+        uint_t channels   = 1000;                       /* 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");
+        return 0;
+}
--- /dev/null
+++ b/examples/tests/test-phasevoc-jack.c
@@ -1,0 +1,79 @@
+/* test sample for phase vocoder 
+ *
+ * this program should start correctly using JACK_START_SERVER=true and
+ * reconstruct each audio input frame perfectly on the corresponding input with
+ * a delay equal to the window size, hop_s.
+ */
+
+#include <unistd.h>  /* pause() */
+#include "aubio.h"
+#include "aubioext.h"
+
+uint_t win_s    = 32; /* window size                       */
+uint_t hop_s    = 8;  /* hop size                          */
+uint_t channels = 4;    /* number of channels                */
+uint_t pos      = 0;    /* frames%dspblocksize for jack loop */
+uint_t usejack    = 1;
+
+fvec_t * in;
+cvec_t * fftgrain;
+fvec_t * out;
+
+aubio_pvoc_t * pv;
+
+aubio_jack_t * jack_setup;
+
+int aubio_process(float **input, float **output, int nframes);
+
+int main(){
+        /* allocate some memory */
+        in       = new_fvec (hop_s, channels); /* input buffer       */
+        fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
+        out      = new_fvec (hop_s, channels); /* output buffer      */
+        /* allocate fft and other memory space */
+        pv = new_aubio_pvoc(win_s,hop_s,channels);
+        /* fill input with some data */
+        printf("initialised\n");
+        /* execute stft */
+        aubio_pvoc_do (pv,in,fftgrain);
+        printf("computed forward\n");
+        /* execute inverse fourier transform */
+        aubio_pvoc_rdo(pv,fftgrain,out);
+        printf("computed backard\n");
+
+        if (usejack) {
+                jack_setup  = new_aubio_jack(channels, channels,
+                                (aubio_process_func_t)aubio_process);
+                aubio_jack_activate(jack_setup);
+                pause(); /* enter main jack loop */
+                aubio_jack_close(jack_setup);
+        }
+        
+        del_aubio_pvoc(pv);
+        printf("memory freed\n");
+        return 0;
+}
+
+int aubio_process(float **input, float **output, int nframes) {
+  uint_t i;       /*channels*/
+  uint_t j;       /*frames*/
+  for (j=0;j<nframes;j++) {
+    for (i=0;i<channels;i++) {
+      /* write input to datanew */
+      fvec_write_sample(in, input[i][j], i, pos);
+      /* put synthnew in output */
+      output[i][j] = fvec_read_sample(out, i, pos);
+    }
+    /*time for fft*/
+    if (pos == hop_s-1) {
+      /* block loop */
+      aubio_pvoc_do (pv,in, fftgrain);
+      //for (i=0;i<fftgrain->length;i++) fftgrain->phas[0][i] *= 2.; 
+      //for (i=0;i<fftgrain->length;i++) fftgrain->phas[0][i] = 0.; 
+      aubio_pvoc_rdo(pv,fftgrain,out);
+      pos = -1;
+    }
+    pos++;
+  }
+  return 0;
+}
--- /dev/null
+++ b/examples/tests/test-phasevoc.c
@@ -1,0 +1,34 @@
+/* test sample for phase vocoder 
+ *
+ * this program should start correctly using JACK_START_SERVER=true and
+ * reconstruct each audio input frame perfectly on the corresponding input with
+ * a delay equal to the window size, hop_s.
+ */
+
+#include "aubio.h"
+
+int main(){
+        uint_t win_s    = 1024; /* window size                       */
+        uint_t hop_s    = 256;  /* hop size                          */
+        uint_t channels = 4;  /* number of channels                */
+        /* allocate some memory */
+        fvec_t * in       = new_fvec (hop_s, channels); /* input buffer       */
+        cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
+        fvec_t * out      = new_fvec (hop_s, channels); /* output buffer      */
+        /* allocate fft and other memory space */
+        aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s,channels);
+        /* fill input with some data */
+        printf("initialised\n");
+        /* execute stft */
+        aubio_pvoc_do (pv,in,fftgrain);
+        printf("computed forward\n");
+        /* execute inverse fourier transform */
+        aubio_pvoc_rdo(pv,fftgrain,out);
+        printf("computed backard\n");
+        del_aubio_pvoc(pv);
+        del_fvec(in);
+        del_cvec(fftgrain);
+        del_fvec(out);
+        printf("memory freed\n");
+        return 0;
+}