Merge branch 'master' of git+ssh://aubio.org/git/aubio/aubio into mono
authorPaul Brossier <piem@piem.org>
Sat, 5 Dec 2009 01:06:42 +0000 (02:06 +0100)
committerPaul Brossier <piem@piem.org>
Sat, 5 Dec 2009 01:06:42 +0000 (02:06 +0100)
106 files changed:
examples/aubiomfcc.c
examples/aubionotes.c
examples/aubioonset.c
examples/aubiopitch.c
examples/aubioquiet.c
examples/aubiotrack.c
examples/sndfileio.c
examples/sndfileio.h
examples/utils.c
examples/utils.h
interfaces/python/aubio-types.h
interfaces/python/aubiomodule.c
interfaces/python/aubiowraphell.h
interfaces/python/gen_pyobject.py
interfaces/python/py-cvec.c
interfaces/python/py-fft.c
interfaces/python/py-filter.c
interfaces/python/py-filterbank.c
interfaces/python/py-fmat.c [new file with mode: 0644]
interfaces/python/py-fvec.c
interfaces/python/py-phasevoc.c
interfaces/python/setup.py
interfaces/python/test_aubio.py
interfaces/python/test_fvec.py [new file with mode: 0644]
src/aubio.h
src/cvec.c
src/cvec.h
src/fmat.c [new file with mode: 0644]
src/fmat.h [new file with mode: 0644]
src/fvec.c
src/fvec.h
src/lvec.c
src/lvec.h
src/mathutils.c
src/mathutils.h
src/onset/onset.c
src/onset/onset.h
src/onset/peakpicker.c
src/onset/peakpicker.h
src/pitch/pitch.c
src/pitch/pitch.h
src/pitch/pitchfcomb.c
src/pitch/pitchfcomb.h
src/pitch/pitchmcomb.c
src/pitch/pitchmcomb.h
src/pitch/pitchschmitt.c
src/pitch/pitchyin.c
src/pitch/pitchyinfft.c
src/spectral/fft.c
src/spectral/fft.h
src/spectral/filterbank.c
src/spectral/filterbank.h
src/spectral/filterbank_mel.c
src/spectral/mfcc.c
src/spectral/phasevoc.c
src/spectral/phasevoc.h
src/spectral/specdesc.c
src/spectral/specdesc.h
src/spectral/statistics.c
src/spectral/tss.c
src/spectral/tss.h
src/tempo/beattracking.c
src/tempo/beattracking.h
src/tempo/tempo.c
src/tempo/tempo.h
src/temporal/a_weighting.c
src/temporal/a_weighting.h
src/temporal/biquad.c
src/temporal/biquad.h
src/temporal/c_weighting.c
src/temporal/c_weighting.h
src/temporal/filter.c
src/temporal/filter.h
src/temporal/resampler.c
src/utils/hist.c
src/utils/hist.h
src/utils/scale.c
src/vecutils.c
swig/aubio.i
tests/src/temporal/test-aweighting.c
tests/src/temporal/test-cweighting.c
tests/src/test-beattracking.c
tests/src/test-biquad.c
tests/src/test-cvec.c
tests/src/test-fft.c
tests/src/test-filter.c
tests/src/test-filterbank.c
tests/src/test-filterbank_mel.c
tests/src/test-fvec.c
tests/src/test-hist.c
tests/src/test-mfcc.c
tests/src/test-onset.c
tests/src/test-onsetdetection.c
tests/src/test-peakpick.c
tests/src/test-phasevoc-jack.c
tests/src/test-phasevoc.c
tests/src/test-pitchdetection.c
tests/src/test-pitchfcomb.c
tests/src/test-pitchmcomb.c
tests/src/test-pitchschmitt.c
tests/src/test-pitchyin.c
tests/src/test-pitchyinfft.c
tests/src/test-resample.c
tests/src/test-scale.c
tests/src/test-tempo.c
tests/src/test-tss.c

index 9390673..161d782 100644 (file)
@@ -32,24 +32,21 @@ uint_t n_coefs = 13;
 unsigned int pos = 0; /*frames%dspblocksize*/
 
 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
-  unsigned int i;       /*channels*/
   unsigned int j;       /*frames*/
   
   for (j=0;j<(unsigned)nframes;j++) {
     if(usejack) {
-      for (i=0;i<channels;i++) {
-        /* write input to datanew */
-        fvec_write_sample(ibuf, input[i][j], i, pos);
-        /* put synthnew in output */
-        output[i][j] = fvec_read_sample(obuf, i, pos);
-      }
+      /* write input to datanew */
+      fvec_write_sample(ibuf, input[0][j], pos);
+      /* put synthnew in output */
+      output[0][j] = fvec_read_sample(obuf, pos);
     }
     /*time for fft*/
     if (pos == overlap_size-1) {         
       /* block loop */
       
       //compute mag spectrum
-      aubio_pvoc_do (pv,ibuf, fftgrain);
+      aubio_pvoc_do (pv, ibuf, fftgrain);
      
       //compute mfccs
       aubio_mfcc_do(mfcc, fftgrain, mfcc_out);
@@ -71,7 +68,7 @@ static void process_print (void) {
       if (output_filename == NULL) {
         outmsg("%f\t",frames*overlap_size/(float)samplerate);
         for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
-            outmsg("%f ", fvec_read_sample (mfcc_out, 0, coef_cnt) );
+            outmsg("%f ", fvec_read_sample (mfcc_out, coef_cnt) );
         }
         outmsg("\n");
       }
@@ -85,14 +82,14 @@ int main(int argc, char **argv) {
   examples_common_init(argc,argv);
 
   /* phase vocoder */
-  pv = new_aubio_pvoc (buffer_size, overlap_size, channels);
+  pv = new_aubio_pvoc (buffer_size, overlap_size);
 
-  fftgrain = new_cvec (buffer_size, channels);
+  fftgrain = new_cvec (buffer_size);
 
   //populating the filter
   mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate);
   
-  mfcc_out = new_fvec(n_coefs,channels);
+  mfcc_out = new_fvec(n_coefs);
   
   //process
   examples_common_process(aubio_process,process_print);
index af888d5..2a97416 100644 (file)
@@ -18,7 +18,7 @@
 
 */
 
-#define AUBIO_UNSTABLE 1 // for fvec_median_channel
+#define AUBIO_UNSTABLE 1 // for fvec_median
 
 #include "utils.h"
 
@@ -49,16 +49,13 @@ void note_append (fvec_t * note_buffer, smpl_t curnote);
 uint_t get_note (fvec_t * note_buffer, fvec_t * note_buffer2);
 
 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
-  unsigned int i;       /*channels*/
   unsigned int j;       /*frames*/
   for (j=0;j<(unsigned)nframes;j++) {
     if(usejack) {
-      for (i=0;i<channels;i++) {
-        /* write input to datanew */
-        fvec_write_sample(ibuf, input[i][j], i, pos);
-        /* put synthnew in output */
-        output[i][j] = fvec_read_sample(obuf, i, pos);
-      }
+      /* write input to datanew */
+      fvec_write_sample(ibuf, input[0][j], pos);
+      /* put synthnew in output */
+      output[0][j] = fvec_read_sample(obuf, pos);
     }
     /*time for fft*/
     if (pos == overlap_size-1) {         
@@ -66,14 +63,14 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
       aubio_onset_do(o, ibuf, onset);
       
       aubio_pitch_do (pitchdet, ibuf, pitch_obuf);
-      pitch = fvec_read_sample(pitch_obuf, 0, 0);
+      pitch = fvec_read_sample(pitch_obuf, 0);
       if(median){
               note_append(note_buffer, pitch);
       }
 
       /* curlevel is negatif or 1 if silence */
       curlevel = aubio_level_detection(ibuf, silence);
-      if (fvec_read_sample(onset, 0, 0)) {
+      if (fvec_read_sample(onset, 0)) {
               /* test for silence */
               if (curlevel == 1.) {
                       if (median) isready = 0;
@@ -91,7 +88,7 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
                       }
 
                       for (pos = 0; pos < overlap_size; pos++){
-                              obuf->data[0][pos] = woodblock->data[0][pos];
+                              obuf->data[pos] = woodblock->data[pos];
                       }
               }
       } else {
@@ -111,7 +108,7 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
                       }
               } // if median
         for (pos = 0; pos < overlap_size; pos++)
-          obuf->data[0][pos] = 0.;
+          obuf->data[pos] = 0.;
       }
       /* end of block loop */
       pos = -1; /* so it will be zero next j loop */
@@ -130,9 +127,9 @@ note_append (fvec_t * note_buffer, smpl_t curnote)
 {
   uint_t i = 0;
   for (i = 0; i < note_buffer->length - 1; i++) {
-    note_buffer->data[0][i] = note_buffer->data[0][i + 1];
+    note_buffer->data[i] = note_buffer->data[i + 1];
   }
-  note_buffer->data[0][note_buffer->length - 1] = curnote;
+  note_buffer->data[note_buffer->length - 1] = curnote;
   return;
 }
 
@@ -141,26 +138,25 @@ get_note (fvec_t * note_buffer, fvec_t * note_buffer2)
 {
   uint_t i;
   for (i = 0; i < note_buffer->length; i++) {
-    note_buffer2->data[0][i] = note_buffer->data[0][i];
+    note_buffer2->data[i] = note_buffer->data[i];
   }
-  return fvec_median_channel (note_buffer2, 0);
+  return fvec_median (note_buffer2);
 }
 
 int main(int argc, char **argv) {
   examples_common_init(argc,argv);
 
-  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels,
-          samplerate);
+  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, samplerate);
   if (threshold != 0.) aubio_onset_set_threshold (o, threshold);
-  onset = new_fvec (1, channels);
+  onset = new_fvec (1);
 
   pitchdet = new_aubio_pitch (pitch_mode, buffer_size * 4,
-          overlap_size, channels, samplerate);
+          overlap_size, samplerate);
   aubio_pitch_set_tolerance (pitchdet, 0.7);
-  pitch_obuf = new_fvec (1, channels);
+  pitch_obuf = new_fvec (1);
   if (median) {
-      note_buffer = new_fvec (median, 1);
-      note_buffer2 = new_fvec (median, 1);
+      note_buffer = new_fvec (median);
+      note_buffer2 = new_fvec (median);
   }
 
   examples_common_process(aubio_process, process_print);
index 36fb8ac..5e23a29 100644 (file)
@@ -30,18 +30,16 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
   unsigned int j;       /*frames*/
   for (j=0;j<(unsigned)nframes;j++) {
     if(usejack) {
-      for (i=0;i<channels;i++) {
-        /* write input to datanew */
-        fvec_write_sample(ibuf, input[i][j], i, pos);
-        /* put synthnew in output */
-        output[i][j] = fvec_read_sample(obuf, i, pos);
-      }
+      /* write input to datanew */
+      fvec_write_sample(ibuf, input[0][j], pos);
+      /* put synthnew in output */
+      output[0][j] = fvec_read_sample(obuf, pos);
     }
     /*time for fft*/
-    if (pos == overlap_size-1) {         
+    if (pos == overlap_size-1) {
       /* block loop */
       aubio_onset_do (o, ibuf, onset);
-      if (fvec_read_sample(onset, 0, 0)) {
+      if ( fvec_read_sample(onset, 0) ) {
         fvec_copy (woodblock, obuf);
       } else {
         fvec_zeros (obuf);
@@ -54,30 +52,31 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
   return 1;
 }
 
-static void process_print (void) {
-      /* output times in seconds, taking back some 
-       * delay to ensure the label is _before_ the
-       * actual onset */
-      if (!verbose && usejack) return;
-      smpl_t onset_found = fvec_read_sample(onset, 0, 0);
-      if (onset_found) {
-        if(frames >= 4) {
-          outmsg("%f\n",(frames - frames_delay + onset_found) 
-                  *overlap_size/(float)samplerate);
-        } else if (frames < frames_delay) {
-          outmsg("%f\n",0.);
-        }
-      }
+static void
+process_print (void)
+{
+  /* output times in seconds, taking back some delay to ensure the label is
+   * _before_ the actual onset */
+  if (!verbose && usejack)
+    return;
+  smpl_t onset_found = fvec_read_sample (onset, 0);
+  if (onset_found) {
+    if (frames >= 4) {
+      outmsg ("%f\n", (frames - frames_delay + onset_found)
+          * overlap_size / (float) samplerate);
+    } else if (frames < frames_delay) {
+      outmsg ("%f\n", 0.);
+    }
+  }
 }
 
 int main(int argc, char **argv) {
   frames_delay = 3;
   examples_common_init(argc,argv);
 
-  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, channels,
-          samplerate);
+  o = new_aubio_onset (onset_mode, buffer_size, overlap_size, samplerate);
   if (threshold != 0.) aubio_onset_set_threshold (o, threshold);
-  onset = new_fvec (1, channels);
+  onset = new_fvec (1);
 
   examples_common_process(aubio_process,process_print);
 
index e9c878b..5ee1db1 100644 (file)
@@ -26,22 +26,19 @@ aubio_pitch_t *o;
 fvec_t *pitch;
 
 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
-  unsigned int i;       /*channels*/
   unsigned int j;       /*frames*/
   for (j=0;j<(unsigned)nframes;j++) {
     if(usejack) {
-      for (i=0;i<channels;i++) {
-        /* write input to datanew */
-        fvec_write_sample(ibuf, input[i][j], i, pos);
-        /* put synthnew in output */
-        output[i][j] = fvec_read_sample(obuf, i, pos);
-      }
+      /* write input to datanew */
+      fvec_write_sample(ibuf, input[0][j], pos);
+      /* put synthnew in output */
+      output[0][j] = fvec_read_sample(obuf, pos);
     }
     /*time for fft*/
     if (pos == overlap_size-1) {         
       /* block loop */
       aubio_pitch_do (o, ibuf, pitch);
-      if (fvec_read_sample(pitch, 0, 0)) {
+      if (fvec_read_sample(pitch, 0)) {
         for (pos = 0; pos < overlap_size; pos++){
           // TODO, play sine at this freq
         }
@@ -58,7 +55,7 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
 
 static void process_print (void) {
       if (!verbose && usejack) return;
-      smpl_t pitch_found = fvec_read_sample(pitch, 0, 0);
+      smpl_t pitch_found = fvec_read_sample(pitch, 0);
       outmsg("%f %f\n",(frames) 
               *overlap_size/(float)samplerate, pitch_found);
 }
@@ -66,9 +63,8 @@ static void process_print (void) {
 int main(int argc, char **argv) {
   examples_common_init(argc,argv);
 
-  o = new_aubio_pitch (onset_mode, buffer_size, overlap_size, channels,
-          samplerate);
-  pitch = new_fvec (1, channels);
+  o = new_aubio_pitch (onset_mode, buffer_size, overlap_size, samplerate);
+  pitch = new_fvec (1);
 
   examples_common_process(aubio_process,process_print);
 
index 0831a2d..c6335b8 100644 (file)
@@ -25,27 +25,24 @@ sint_t wassilence = 1, issilence;
 
 int aubio_process(smpl_t **input, smpl_t **output, int nframes);
 int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
-  unsigned int i;       /*channels*/
   unsigned int j;       /*frames*/
   for (j=0;j<(unsigned)nframes;j++) {
     if(usejack) {
-      for (i=0;i<channels;i++) {
-        /* write input to datanew */
-        fvec_write_sample(ibuf, input[i][j], i, pos);
-        /* put synthnew in output */
-        output[i][j] = fvec_read_sample(obuf, i, pos);
-      }
+      /* write input to datanew */
+      fvec_write_sample(ibuf, input[0][j], pos);
+      /* put synthnew in output */
+      output[0][j] = fvec_read_sample(obuf, pos);
     }
     /*time for fft*/
     if (pos == overlap_size-1) {         
       /* test for silence */
       if (aubio_silence_detection(ibuf, silence)==1) {
-       if (wassilence==1) issilence = 1;
-       else issilence = 2;
+        if (wassilence==1) issilence = 1;
+        else issilence = 2;
         wassilence=1;
       } else { 
-       if (wassilence<=0) issilence = 0;
-       else issilence = -1;
+        if (wassilence<=0) issilence = 0;
+        else issilence = -1;
         wassilence=0;
       }
       /* end of block loop */
index cb333c8..572f6a1 100644 (file)
@@ -28,23 +28,20 @@ smpl_t istactus = 0;
 smpl_t isonset = 0;
 
 static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
-  unsigned int i;       /*channels*/
   unsigned int j;       /*frames*/
   for (j=0;j<(unsigned)nframes;j++) {
     if(usejack) {
-      for (i=0;i<channels;i++) {
-        /* write input to datanew */
-        fvec_write_sample(ibuf, input[i][j], i, pos);
-        /* put synthnew in output */
-        output[i][j] = fvec_read_sample(obuf, i, pos);
-      }
+      /* write input to datanew */
+      fvec_write_sample(ibuf, input[0][j], pos);
+      /* put synthnew in output */
+      output[0][j] = fvec_read_sample(obuf, pos);
     }
     /*time for fft*/
     if (pos == overlap_size-1) {         
       /* block loop */
       aubio_tempo_do (bt,ibuf,tempo_out);
-      istactus = fvec_read_sample (tempo_out, 0, 0);
-      isonset = fvec_read_sample (tempo_out, 0, 1);
+      istactus = fvec_read_sample (tempo_out, 0);
+      isonset = fvec_read_sample (tempo_out, 1);
       if (istactus > 0.) {
         fvec_copy (woodblock, obuf);
       } else {
@@ -75,8 +72,8 @@ int main(int argc, char **argv) {
   /* override default settings */
   examples_common_init(argc,argv);
 
-  tempo_out = new_fvec(2,channels);
-  bt = new_aubio_tempo(onset_mode,buffer_size,overlap_size,channels, samplerate);
+  tempo_out = new_fvec(2);
+  bt = new_aubio_tempo(onset_mode,buffer_size,overlap_size, samplerate);
   if (threshold != 0.) aubio_tempo_set_threshold (bt, threshold);
 
   examples_common_process(aubio_process,process_print);
index 4aae2a1..6e7c24c 100644 (file)
@@ -95,7 +95,7 @@ int aubio_sndfile_open_wo(aubio_sndfile_t * f, const char* inputname) {
 aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * fmodel, const char *outputname) {
         aubio_sndfile_t * f = AUBIO_NEW(aubio_sndfile_t);
         f->samplerate    = fmodel->samplerate;
-        f->channels      = fmodel->channels;
+        f->channels      = 1; //fmodel->channels;
         f->format        = fmodel->format;
         aubio_sndfile_open_wo(f, outputname);
         return f;
@@ -124,7 +124,7 @@ int del_aubio_sndfile(aubio_sndfile_t * f) {
 
 /* read frames from file in data 
  *  return the number of frames actually read */
-int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t * read) {
+int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t ** read) {
         sf_count_t read_frames;
         int i,j, channels = f->channels;
         int nsamples = frames*channels;
@@ -149,7 +149,7 @@ int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t * read) {
 
         /* de-interleaving data  */
         for (i=0; i<channels; i++) {
-                pread = (smpl_t *)fvec_get_channel(read,i);
+                pread = (smpl_t *)fvec_get_data(read[i]);
                 for (j=0; j<aread; j++) {
                         pread[j] = (smpl_t)f->tmpdata[channels*j+i];
                 }
@@ -157,10 +157,49 @@ int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t * read) {
         return aread;
 }
 
+int
+aubio_sndfile_read_mono (aubio_sndfile_t * f, int frames, fvec_t * read)
+{
+  sf_count_t read_frames;
+  int i, j, channels = f->channels;
+  int nsamples = frames * channels;
+  int aread;
+  smpl_t *pread;
+
+  /* allocate data for de/interleaving reallocated when needed. */
+  if (nsamples >= f->size) {
+    AUBIO_ERR ("Maximum aubio_sndfile_read buffer size exceeded.");
+    return -1;
+    /*
+    AUBIO_FREE(f->tmpdata);
+    f->tmpdata = AUBIO_ARRAY(float,nsamples);
+    */
+  }
+  //f->size = nsamples;
+
+  /* do actual reading */
+  read_frames = sf_read_float (f->handle, f->tmpdata, nsamples);
+
+  aread = (int) FLOOR (read_frames / (float) channels);
+
+  /* de-interleaving data  */
+  pread = (smpl_t *) fvec_get_data (read);
+  for (i = 0; i < channels; i++) {
+    for (j = 0; j < aread; j++) {
+      pread[j] += (smpl_t) f->tmpdata[channels * j + i];
+    }
+  }
+  for (j = 0; j < aread; j++) {
+    pread[j] /= (smpl_t)channels;
+  }
+
+  return aread;
+}
+
 /* write 'frames' samples to file from data 
  *   return the number of frames actually written 
  */
-int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t * write) {
+int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t ** write) {
         sf_count_t written_frames = 0;
         int i, j,      channels = f->channels;
         int nsamples = channels*frames;
@@ -179,7 +218,7 @@ int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t * write) {
 
         /* interleaving data  */
         for (i=0; i<channels; i++) {
-                pwrite = (smpl_t *)fvec_get_channel(write,i);
+                pwrite = (smpl_t *)fvec_get_data(write[i]);
                 for (j=0; j<frames; j++) {
                         f->tmpdata[channels*j+i] = (float)pwrite[j];
                 }
index 8e4c458..cfa3d54 100644 (file)
@@ -48,11 +48,11 @@ int aubio_sndfile_open_wo (aubio_sndfile_t * file, const char * outputname);
 /** 
  * Read frames data from file 
  */
-int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read);
+int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t ** read);
 /** 
  * Write data of length frames to file
  */
-int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write);
+int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t ** write);
 /**
  * Close file and delete file object
  */
index a9e77a2..93b4cab 100644 (file)
@@ -60,7 +60,6 @@ smpl_t threshold = 0.0;         // leave unset, only set as asked
 smpl_t silence = -90.;
 uint_t buffer_size = 512;       //1024;
 uint_t overlap_size = 256;      //512;
-uint_t channels = 1;
 uint_t samplerate = 44100;
 
 
@@ -207,7 +206,7 @@ examples_common_init (int argc, char **argv)
   /* parse command line arguments */
   parse_args (argc, argv);
 
-  woodblock = new_fvec (buffer_size, 1);
+  woodblock = new_fvec (overlap_size);
   if (output_filename || usejack) {
     /* dummy assignement to keep egcs happy */
     found_wood = (onsetfile = new_aubio_sndfile_ro (onset_filename)) ||
@@ -220,7 +219,7 @@ examples_common_init (int argc, char **argv)
   }
   if (onsetfile) {
     /* read the output sound once */
-    aubio_sndfile_read (onsetfile, overlap_size, woodblock);
+    aubio_sndfile_read_mono (onsetfile, overlap_size, woodblock);
   }
 
   if (!usejack) {
@@ -232,7 +231,6 @@ examples_common_init (int argc, char **argv)
     }
     if (verbose)
       aubio_sndfile_info (file);
-    channels = aubio_sndfile_channels (file);
     samplerate = aubio_sndfile_samplerate (file);
     if (output_filename != NULL)
       fileout = new_aubio_sndfile_wo (file, output_filename);
@@ -255,8 +253,9 @@ examples_common_init (int argc, char **argv)
   }
 #endif /* HAVE_LASH */
 
-  ibuf = new_fvec (overlap_size, channels);
-  obuf = new_fvec (overlap_size, channels);
+  uint_t i;
+  ibuf = new_fvec (overlap_size);
+  obuf = new_fvec (overlap_size);
 
 }
 
@@ -264,6 +263,7 @@ examples_common_init (int argc, char **argv)
 void
 examples_common_del (void)
 {
+  uint_t i;
   del_fvec (ibuf);
   del_fvec (obuf);
   del_fvec (woodblock);
@@ -282,7 +282,7 @@ examples_common_process (aubio_process_func_t process_func,
 
 #if HAVE_JACK
     debug ("Jack init ...\n");
-    jack_setup = new_aubio_jack (channels, channels,
+    jack_setup = new_aubio_jack (1, 1,
         0, 1, (aubio_process_func_t) process_func);
     debug ("Jack activation ...\n");
     aubio_jack_activate (jack_setup);
@@ -300,12 +300,12 @@ examples_common_process (aubio_process_func_t process_func,
 
     frames = 0;
 
-    while ((signed) overlap_size == aubio_sndfile_read (file, overlap_size,
-            ibuf)) {
-      process_func (ibuf->data, obuf->data, overlap_size);
+    while ((signed) overlap_size ==
+        aubio_sndfile_read_mono (file, overlap_size, ibuf)) {
+      process_func (&ibuf->data, &obuf->data, overlap_size);
       print ();
       if (output_filename != NULL) {
-        aubio_sndfile_write (fileout, overlap_size, obuf);
+        aubio_sndfile_write (fileout, overlap_size, &obuf);
       }
       frames++;
     }
@@ -327,7 +327,7 @@ flush_process (aubio_process_func_t process_func, aubio_print_func_t print)
   uint_t i;
   fvec_zeros(obuf);
   for (i = 0; (signed) i < frames_delay; i++) {
-    process_func (ibuf->data, obuf->data, overlap_size);
+    process_func (&ibuf->data, &obuf->data, overlap_size);
     print ();
   }
 }
index a53f9d3..7fe3419 100644 (file)
@@ -73,7 +73,6 @@ extern int verbose;
 extern int usejack;
 extern uint_t buffer_size;
 extern uint_t overlap_size;
-extern uint_t channels;
 extern uint_t samplerate;
 
 extern fvec_t *ibuf;
index 8d00191..035f69e 100644 (file)
@@ -5,8 +5,8 @@
 #define AUBIO_UNSTABLE 1
 #include <aubio.h>
 
-#define Py_default_vector_length   1024
-#define Py_default_vector_channels 1
+#define Py_default_vector_length 1024
+#define Py_default_vector_height 1
 
 #define Py_aubio_default_samplerate 44100
 
@@ -24,14 +24,12 @@ types different than NPY_FLOAT to and fvec, and therefore creating a copy of
 it. 
 
 */
-#define AUBIO_DO_CASTING 0
 
 typedef struct
 {
   PyObject_HEAD
   fvec_t * o;
   uint_t length;
-  uint_t channels;
 } Py_fvec;
 extern PyTypeObject Py_fvecType;
 extern PyObject *PyAubio_FvecToArray (Py_fvec * self);
@@ -41,6 +39,18 @@ extern Py_fvec *PyAubio_ArrayToFvec (PyObject * self);
 typedef struct
 {
   PyObject_HEAD
+  fmat_t * o;
+  uint_t length;
+  uint_t height;
+} Py_fmat;
+extern PyTypeObject Py_fmatType;
+extern PyObject *PyAubio_FmatToArray (Py_fmat * self);
+extern PyObject *PyAubio_CFmatToArray (fmat_t * self);
+extern Py_fmat *PyAubio_ArrayToFmat (PyObject * self);
+
+typedef struct
+{
+  PyObject_HEAD
   cvec_t * o;
   uint_t length;
   uint_t channels;
index c3b568f..b0f7598 100644 (file)
@@ -121,6 +121,7 @@ init_aubio (void)
   int err;
 
   if ((PyType_Ready (&Py_fvecType) < 0) 
+      || (PyType_Ready (&Py_fmatType) < 0) 
       || (PyType_Ready (&Py_cvecType) < 0) 
       || (PyType_Ready (&Py_filterType) < 0) 
       || (PyType_Ready (&Py_filterbankType) < 0) 
@@ -147,6 +148,8 @@ init_aubio (void)
 
   Py_INCREF (&Py_fvecType);
   PyModule_AddObject (m, "fvec", (PyObject *) & Py_fvecType);
+  Py_INCREF (&Py_fmatType);
+  PyModule_AddObject (m, "fmat", (PyObject *) & Py_fmatType);
   Py_INCREF (&Py_cvecType);
   PyModule_AddObject (m, "cvec", (PyObject *) & Py_cvecType);
   Py_INCREF (&Py_filterType);
index c8fc222..7ccdc09 100644 (file)
@@ -93,7 +93,6 @@ PyTypeObject Py_ ## NAME ## Type = { \
 };
 
 // some more helpers
-#define AUBIO_NEW_VEC(name, type, lengthval, channelsval) \
+#define AUBIO_NEW_VEC(name, type, lengthval) \
   name = (type *) PyObject_New (type, & type ## Type); \
-  name->channels = channelsval; \
   name->length = lengthval;
index 20c12e9..bb6ba6e 100644 (file)
@@ -68,20 +68,20 @@ def get_name(proto):
 # the important bits: the size of the output for each objects. this data should
 # move into the C library at some point.
 defaultsizes = {
-    'resampler':    ('input->length * self->ratio', 'input->channels'),
-    'specdesc':     ('1', 'fftgrain->channels'),
-    'onset':        ('1', 'self->channels'),
-    'pitchyin':     ('1', 'in->channels'),
-    'pitchyinfft':  ('1', 'in->channels'),
-    'pitchschmitt': ('1', 'in->channels'),
-    'pitchmcomb':   ('1', 'self->channels'),
-    'pitchfcomb':   ('1', 'self->channels'),
-    'pitch':        ('1', 'self->channels'),
-    'tss':          ('self->hop_size', 'self->channels'),
-    'mfcc':         ('self->n_coeffs', 'in->channels'),
-    'beattracking': ('self->hop_size', 'self->channels'),
-    'tempo':        ('1', 'self->channels'),
-    'peakpicker':   ('1', 'self->channels'),
+    'resampler':    'input->length * self->ratio',
+    'specdesc':     '1',
+    'onset':        '1',
+    'pitchyin':     '1',
+    'pitchyinfft':  '1',
+    'pitchschmitt': '1',
+    'pitchmcomb':   '1',
+    'pitchfcomb':   '1',
+    'pitch':        '1',
+    'tss':          'self->hop_size',
+    'mfcc':         'self->n_coeffs',
+    'beattracking': 'self->hop_size',
+    'tempo':        '1',
+    'peakpicker':   '1',
 }
 
 # default value for variables
@@ -98,7 +98,6 @@ aubiodefvalue = {
     # and here too
     'hop_size': 'Py_default_vector_length / 2', 
     # these should be alright
-    'channels': 'Py_default_vector_channels', 
     'samplerate': 'Py_aubio_default_samplerate', 
     # now for the non obvious ones
     'n_filters': '40', 
@@ -150,7 +149,10 @@ aubiovectopyobj_new = {
 def gen_new_init(newfunc, name):
     newparams = get_params_types_names(newfunc)
     # self->param1, self->param2, self->param3
-    selfparams = ', self->'.join([p[1] for p in newparams])
+    if len(newparams):
+        selfparams = ', self->'+', self->'.join([p[1] for p in newparams])
+    else:
+        selfparams = '' 
     # "param1", "param2", "param3"
     paramnames = ", ".join(["\""+p[1]+"\"" for p in newparams])
     pyparams = "".join(map(lambda p: aubio2pytypes[p[0]], newparams))
@@ -178,6 +180,7 @@ static char Py_%(name)s_doc[] = "%(name)s object";
 static PyObject *
 Py_%(name)s_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
 {
+  Py_%(name)s *self;
 """ % locals()
     for ptype, pname in newparams:
         initval = aubioinitvalue[ptype]
@@ -185,14 +188,16 @@ Py_%(name)s_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
   %(ptype)s %(pname)s = %(initval)s;
 """ % locals()
     # now the actual PyArg_Parse
-    s += """\
-  Py_%(name)s *self;
+    if len(paramnames):
+        s += """\
   static char *kwlist[] = { %(paramnames)s, NULL };
 
   if (!PyArg_ParseTupleAndKeywords (args, kwds, "|%(pyparams)s", kwlist,
           %(paramrefs)s)) {
     return NULL;
   }
+""" % locals()
+    s += """\
 
   self = (Py_%(name)s *) pytype->tp_alloc (pytype, 0);
 
@@ -237,7 +242,7 @@ Py_%(name)s_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
   return (PyObject *) self;
 }
 
-AUBIO_INIT(%(name)s, self->%(selfparams)s)
+AUBIO_INIT(%(name)s %(selfparams)s)
 
 AUBIO_DEL(%(name)s)
 
@@ -286,10 +291,10 @@ def gen_do(dofunc, name):
         #    "too many output parameters"
         outputvecs = "\n  ".join([aubio2pyaubio[p[0]]+" * " + p[-1] + ";" for p in outputparams])
         outputcreate = "\n  ".join(["""\
-AUBIO_NEW_VEC(%(name)s, %(pytype)s, %(length)s, %(channels)s)
-  %(name)s->o = new_%(autype)s (%(length)s, %(channels)s);""" % \
+AUBIO_NEW_VEC(%(name)s, %(pytype)s, %(length)s)
+  %(name)s->o = new_%(autype)s (%(length)s);""" % \
     {'name': p[-1], 'pytype': aubio2pyaubio[p[0]], 'autype': p[0][:-3],
-        'length': defaultsizes[name][0], 'channels': defaultsizes[name][1]} \
+        'length': defaultsizes[name]} \
         for p in outputparams]) 
         if len(outputparams) > 1:
             returnval = "PyObject *outputs = PyList_New(0);\n"
index 18e386d..9290e7c 100644 (file)
@@ -3,25 +3,24 @@
 /* cvec type definition 
 
 class cvec():
-    def __init__(self, length = 1024, channels = 1):
+    def __init__(self, length = 1024):
         self.length = length 
-        self.channels = channels 
-        self.norm = array(length, channels)
-        self.phas = array(length, channels)
-*/
+        self.norm = array(length)
+        self.phas = array(length)
 
+*/
 
 static char Py_cvec_doc[] = "cvec object";
 
 static PyObject *
 Py_cvec_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
 {
-  int length= 0, channels = 0;
+  int length= 0;
   Py_cvec *self;
-  static char *kwlist[] = { "length", "channels", NULL };
+  static char *kwlist[] = { "length", NULL };
 
-  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
-          &length, &channels)) {
+  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
+          &length)) {
     return NULL;
   }
 
@@ -29,7 +28,6 @@ Py_cvec_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
   self = (Py_cvec *) type->tp_alloc (type, 0);
 
   self->length = Py_default_vector_length / 2 + 1;
-  self->channels = Py_default_vector_channels;
 
   if (self == NULL) {
     return NULL;
@@ -43,21 +41,13 @@ Py_cvec_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
     return NULL;
   }
 
-  if (channels > 0) {
-    self->channels = channels;
-  } else if (channels < 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "can not use negative number of channels");
-    return NULL;
-  }
-
   return (PyObject *) self;
 }
 
 static int
 Py_cvec_init (Py_cvec * self, PyObject * args, PyObject * kwds)
 {
-  self->o = new_cvec ((self->length - 1) * 2, self->channels);
+  self->o = new_cvec ((self->length - 1) * 2);
   if (self->o == NULL) {
     return -1;
   }
@@ -79,16 +69,16 @@ Py_cvec_repr (Py_cvec * self, PyObject * unused)
   PyObject *args = NULL;
   PyObject *result = NULL;
 
-  format = PyString_FromString ("aubio cvec of %d elements with %d channels");
+  format = PyString_FromString ("aubio cvec of %d elements");
   if (format == NULL) {
     goto fail;
   }
 
-  args = Py_BuildValue ("II", self->length, self->channels);
+  args = Py_BuildValue ("I", self->length);
   if (args == NULL) {
     goto fail;
   }
-  //cvec_print ( self->o );
+  cvec_print ( self->o );
 
   result = PyString_Format (format, args);
 
@@ -103,7 +93,10 @@ Py_cvec *
 PyAubio_ArrayToCvec (PyObject *input) {
   PyObject *array;
   Py_cvec *vec;
-  uint_t i;
+  if (input == NULL) {
+    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
+    goto fail;
+  }
   // parsing input object into a Py_cvec
   if (PyObject_TypeCheck (input, &Py_cvecType)) {
     // input is an cvec, nothing else to do
@@ -114,28 +107,18 @@ PyAubio_ArrayToCvec (PyObject *input) {
     if (PyArray_NDIM (input) == 0) {
       PyErr_SetString (PyExc_ValueError, "input array is a scalar");
       goto fail;
-    } else if (PyArray_NDIM (input) > 2) {
+    } else if (PyArray_NDIM (input) > 1) {
       PyErr_SetString (PyExc_ValueError,
-          "input array has more than two dimensions");
+          "input array has more than one dimensions");
       goto fail;
     }
 
     if (!PyArray_ISFLOAT (input)) {
       PyErr_SetString (PyExc_ValueError, "input array should be float");
       goto fail;
-#if AUBIO_DO_CASTING
-    } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
-      // input data type is not float32, casting 
-      array = PyArray_Cast ( (PyArrayObject*) input, AUBIO_NPY_SMPL);
-      if (array == NULL) {
-        PyErr_SetString (PyExc_IndexError, "failed converting to NPY_FLOAT");
-        goto fail;
-      }
-#else
     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
       PyErr_SetString (PyExc_ValueError, "input array should be float32");
       goto fail;
-#endif
     } else {
       // input data type is float32, nothing else to do
       array = input;
@@ -143,29 +126,21 @@ PyAubio_ArrayToCvec (PyObject *input) {
 
     // create a new cvec object
     vec = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType); 
-    if (PyArray_NDIM (array) == 1) {
+    if (PyArray_NDIM (array) != 2) {
       PyErr_SetString (PyExc_ValueError,
-          "input array should be have at least two rows for norm and phas");
+          "input array should be have exactly two rows for norm and phas");
       goto fail;
-    } else if (PyArray_NDIM (array) == 2) {
-      vec->channels = 1;
-      vec->length = PyArray_SIZE (array);
     } else {
-      vec->channels = PyArray_DIM (array, 0) / 2;
-      vec->length = PyArray_DIM (array, 1);
+      vec->length = PyArray_SIZE (array);
     }
 
     // no need to really allocate cvec, just its struct member 
-    // vec->o = new_cvec (vec->length, vec->channels);
+    // vec->o = new_cvec (vec->length);
     vec->o = (cvec_t *)malloc(sizeof(cvec_t));
-    vec->o->length = vec->length; vec->o->channels = vec->channels;
-    vec->o->norm = (smpl_t**)malloc(vec->o->channels * sizeof(smpl_t*));
-    vec->o->phas = (smpl_t**)malloc(vec->o->channels * sizeof(smpl_t*));
-    // hat data[i] point to array line
-    for (i = 0; i < vec->channels; i+=2) {
-      vec->o->norm[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
-      vec->o->phas[i] = (smpl_t *) PyArray_GETPTR1 (array, i+1);
-    }
+    vec->o->length = vec->length;
+    // have norm and phas point to array rows 
+    vec->o->norm = (smpl_t *) PyArray_GETPTR1 (array, 0);
+    vec->o->phas = (smpl_t *) PyArray_GETPTR1 (array, 1);
 
   } else {
     PyErr_SetString (PyExc_ValueError, "can only accept array or cvec as input");
@@ -182,17 +157,14 @@ PyObject *
 PyAubio_CvecToArray (Py_cvec * self)
 {
   PyObject *array = NULL;
-  uint_t i;
   npy_intp dims[] = { self->o->length, 1 };
   PyObject *concat = PyList_New (0), *tmp = NULL;
-  for (i = 0; i < self->channels; i++) {
-    tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm[i]);
-    PyList_Append (concat, tmp);
-    Py_DECREF (tmp);
-    tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas[i]);
-    PyList_Append (concat, tmp);
-    Py_DECREF (tmp);
-  }
+  tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm);
+  PyList_Append (concat, tmp);
+  Py_DECREF (tmp);
+  tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas);
+  PyList_Append (concat, tmp);
+  Py_DECREF (tmp);
   array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2);
   Py_DECREF (concat);
   return array;
@@ -201,36 +173,16 @@ PyAubio_CvecToArray (Py_cvec * self)
 PyObject *
 PyAubio_CvecNormToArray (Py_cvec * self)
 {
-  PyObject *array = NULL;
-  uint_t i;
   npy_intp dims[] = { self->o->length, 1 };
-  PyObject *concat = PyList_New (0), *tmp = NULL;
-  for (i = 0; i < self->channels; i++) {
-    tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm[i]);
-    PyList_Append (concat, tmp);
-    Py_DECREF (tmp);
-  }
-  array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2);
-  Py_DECREF (concat);
-  return array;
+  return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm);
 }
 
 
 PyObject *
 PyAubio_CvecPhasToArray (Py_cvec * self)
 {
-  PyObject *array = NULL;
-  uint_t i;
   npy_intp dims[] = { self->o->length, 1 };
-  PyObject *concat = PyList_New (0), *tmp = NULL;
-  for (i = 0; i < self->channels; i++) {
-    tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas[i]);
-    PyList_Append (concat, tmp);
-    Py_DECREF (tmp);
-  }
-  array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2);
-  Py_DECREF (concat);
-  return array;
+  return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas);
 }
 
 PyObject *
@@ -254,7 +206,6 @@ Py_cvec_get_phas (Py_cvec * self, void *closure)
 static int
 Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
 {
-  uint_t i;
   PyObject * array;
   if (input == NULL) {
     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
@@ -282,36 +233,21 @@ Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
     array = input;
 
     // check input array dimensions
-    if (PyArray_NDIM (array) == 1) {
-      if (vec->channels != 1) {
-          PyErr_SetString (PyExc_ValueError,
-                  "input array should have more than one channel");
-          goto fail;
-      }
+    if (PyArray_NDIM (array) != 1) {
+      PyErr_Format (PyExc_ValueError,
+          "input array has %d dimensions, not 1",
+          PyArray_NDIM (array));
+      goto fail;
+    } else {
       if (vec->o->length != PyArray_SIZE (array)) {
           PyErr_Format (PyExc_ValueError,
                   "input array has length %d, but cvec has length %d",
                   PyArray_SIZE (array), vec->o->length);
           goto fail;
       }
-    } else {
-      if (vec->channels != PyArray_DIM (array, 0)) {
-          PyErr_Format (PyExc_ValueError,
-                  "input array has %d channels, but vector has %d channels",
-                  PyArray_DIM (array, 0), vec->channels);
-          goto fail;
-      }
-      if (vec->o->length != PyArray_DIM (array, 1)) {
-          PyErr_Format (PyExc_ValueError,
-                  "input array has length %d, but vector has length %d",
-                  PyArray_DIM (array, 1), vec->o->length);
-          goto fail;
-      }
     }
 
-    for (i = 0; i < vec->channels; i++) {
-      vec->o->norm[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
-    }
+    vec->o->norm = (smpl_t *) PyArray_GETPTR1 (array, 0);
 
   } else {
     PyErr_SetString (PyExc_ValueError, "can only accept array as input");
@@ -328,7 +264,6 @@ fail:
 static int
 Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure)
 {
-  uint_t i;
   PyObject * array;
   if (input == NULL) {
     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
@@ -356,36 +291,21 @@ Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure)
     array = input;
 
     // check input array dimensions
-    if (PyArray_NDIM (array) == 1) {
-      if (vec->channels != 1) {
-          PyErr_SetString (PyExc_ValueError,
-                  "input array should have more than one channel");
-          goto fail;
-      }
+    if (PyArray_NDIM (array) != 1) {
+      PyErr_Format (PyExc_ValueError,
+          "input array has %d dimensions, not 1",
+          PyArray_NDIM (array));
+      goto fail;
+    } else {
       if (vec->o->length != PyArray_SIZE (array)) {
           PyErr_Format (PyExc_ValueError,
                   "input array has length %d, but cvec has length %d",
                   PyArray_SIZE (array), vec->o->length);
           goto fail;
       }
-    } else {
-      if (vec->channels != PyArray_DIM (array, 0)) {
-          PyErr_Format (PyExc_ValueError,
-                  "input array has %d channels, but vector has %d channels",
-                  PyArray_DIM (array, 0), vec->channels);
-          goto fail;
-      }
-      if (vec->o->length != PyArray_DIM (array, 1)) {
-          PyErr_Format (PyExc_ValueError,
-                  "input array has length %d, but vector has length %d",
-                  PyArray_DIM (array, 1), vec->o->length);
-          goto fail;
-      }
     }
 
-    for (i = 0; i < vec->channels; i++) {
-      vec->o->phas[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
-    }
+    vec->o->phas = (smpl_t *) PyArray_GETPTR1 (array, 0);
 
   } else {
     PyErr_SetString (PyExc_ValueError, "can only accept array as input");
@@ -399,68 +319,10 @@ fail:
   return 1;
 }
 
-static Py_ssize_t
-Py_cvec_getchannels (Py_cvec * self)
-{
-  return self->channels;
-}
-
-static PyObject *
-Py_cvec_getitem (Py_cvec * self, Py_ssize_t index)
-{
-  PyObject *array;
-
-  if (index < 0 || index >= self->channels) {
-    PyErr_SetString (PyExc_IndexError, "no such channel");
-    return NULL;
-  }
-
-  npy_intp dims[] = { self->length, 1 };
-  array = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm[index]);
-  return array;
-}
-
-static int
-Py_cvec_setitem (Py_cvec * self, Py_ssize_t index, PyObject * o)
-{
-  PyObject *array;
-
-  if (index < 0 || index >= self->channels) {
-    PyErr_SetString (PyExc_IndexError, "no such channel");
-    return -1;
-  }
-
-  array = PyArray_FROM_OT (o, NPY_FLOAT);
-  if (array == NULL) {
-    PyErr_SetString (PyExc_ValueError, "should be an array of float");
-    goto fail;
-  }
-
-  if (PyArray_NDIM (array) != 1) {
-    PyErr_SetString (PyExc_ValueError, "should be a one-dimensional array");
-    goto fail;
-  }
-
-  if (PyArray_SIZE (array) != self->length) {
-    PyErr_SetString (PyExc_ValueError,
-        "should be an array of same length as target cvec");
-    goto fail;
-  }
-
-  self->o->norm[index] = (smpl_t *) PyArray_GETPTR1 (array, 0);
-
-  return 0;
-
-fail:
-  return -1;
-}
-
 static PyMemberDef Py_cvec_members[] = {
   // TODO remove READONLY flag and define getter/setter
   {"length", T_INT, offsetof (Py_cvec, length), READONLY,
       "length attribute"},
-  {"channels", T_INT, offsetof (Py_cvec, channels), READONLY,
-      "channels attribute"},
   {NULL}                        /* Sentinel */
 };
 
@@ -480,20 +342,6 @@ static PyGetSetDef Py_cvec_getseters[] = {
   {NULL} /* sentinel */
 };
 
-static PySequenceMethods Py_cvec_tp_as_sequence = {
-  (lenfunc) Py_cvec_getchannels,        /* sq_length         */
-  0,                                    /* sq_concat         */
-  0,                                    /* sq_repeat         */
-  (ssizeargfunc) Py_cvec_getitem,       /* sq_item           */
-  0,                                    /* sq_slice          */
-  (ssizeobjargproc) Py_cvec_setitem,    /* sq_ass_item       */
-  0,                                    /* sq_ass_slice      */
-  0,                                    /* sq_contains       */
-  0,                                    /* sq_inplace_concat */
-  0,                                    /* sq_inplace_repeat */
-};
-
-
 PyTypeObject Py_cvecType = {
   PyObject_HEAD_INIT (NULL)
   0,                            /* ob_size           */
@@ -507,7 +355,7 @@ PyTypeObject Py_cvecType = {
   0,                            /* tp_compare        */
   (reprfunc) Py_cvec_repr,      /* tp_repr           */
   0,                            /* tp_as_number      */
-  &Py_cvec_tp_as_sequence,      /* tp_as_sequence    */
+  0, //&Py_cvec_tp_as_sequence,      /* tp_as_sequence    */
   0,                            /* tp_as_mapping     */
   0,                            /* tp_hash           */
   0,                            /* tp_call           */
index acbeb67..20e8fe5 100644 (file)
@@ -2,18 +2,18 @@
 
 static char Py_fft_doc[] = "fft object";
 
-AUBIO_DECLARE(fft, uint_t win_s; uint_t channels)
+AUBIO_DECLARE(fft, uint_t win_s)
 
 //AUBIO_NEW(fft)
 static PyObject *
 Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
 {
-  int win_s = 0, channels = 0;
+  int win_s = 0;
   Py_fft *self;
-  static char *kwlist[] = { "win_s", "channels", NULL };
+  static char *kwlist[] = { "win_s", NULL };
 
-  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
-          &win_s, &channels)) {
+  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
+          &win_s)) {
     return NULL;
   }
 
@@ -24,7 +24,6 @@ Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
   }
 
   self->win_s = Py_default_vector_length;
-  self->channels = Py_default_vector_channels;
 
   if (self == NULL) {
     return NULL;
@@ -38,19 +37,11 @@ Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
     return NULL;
   }
 
-  if (channels > 0) {
-    self->channels = channels;
-  } else if (channels < 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "can not use negative number of filters");
-    return NULL;
-  }
-
   return (PyObject *) self;
 }
 
 
-AUBIO_INIT(fft, self->win_s, self->channels)
+AUBIO_INIT(fft, self->win_s)
 
 AUBIO_DEL(fft)
 
@@ -72,9 +63,8 @@ Py_fft_do(PyObject * self, PyObject * args)
   }
 
   output = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
-  output->channels = vec->channels;
   output->length = ((Py_fft *) self)->win_s;
-  output->o = new_cvec(((Py_fft *) self)->win_s, vec->channels);
+  output->o = new_cvec(((Py_fft *) self)->win_s);
 
   // compute the function
   aubio_fft_do (((Py_fft *)self)->o, vec->o, output->o);
@@ -86,8 +76,6 @@ Py_fft_do(PyObject * self, PyObject * args)
 AUBIO_MEMBERS_START(fft) 
   {"win_s", T_INT, offsetof (Py_fft, win_s), READONLY,
     "size of the window"},
-  {"channels", T_INT, offsetof (Py_fft, channels), READONLY,
-    "number of channels"},
 AUBIO_MEMBERS_STOP(fft)
 
 static PyObject * 
@@ -108,9 +96,8 @@ Py_fft_rdo(PyObject * self, PyObject * args)
   }
 
   output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
-  output->channels = vec->channels;
   output->length = ((Py_fft *) self)->win_s;
-  output->o = new_fvec(output->length, output->channels);
+  output->o = new_fvec(output->length);
 
   // compute the function
   aubio_fft_rdo (((Py_fft *)self)->o, vec->o, output->o);
index 7f46341..7888b7a 100644 (file)
@@ -5,7 +5,6 @@ typedef struct
   PyObject_HEAD
   aubio_filter_t * o;
   uint_t order;
-  uint_t channels;
 } Py_filter;
 
 static char Py_filter_doc[] = "filter object";
@@ -13,12 +12,12 @@ static char Py_filter_doc[] = "filter object";
 static PyObject *
 Py_filter_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
 {
-  int order= 0, channels = 0;
+  int order= 0;
   Py_filter *self;
-  static char *kwlist[] = { "order", "channels", NULL };
+  static char *kwlist[] = { "order", NULL };
 
   if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
-          &order, &channels)) {
+          &order)) {
     return NULL;
   }
 
@@ -29,7 +28,6 @@ Py_filter_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
   }
 
   self->order = 7;
-  self->channels = Py_default_vector_channels;
 
   if (order > 0) {
     self->order = order;
@@ -39,21 +37,13 @@ Py_filter_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
     return NULL;
   }
 
-  if (channels > 0) {
-    self->channels = channels;
-  } else if (channels < 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "can not use negative number of channels");
-    return NULL;
-  }
-
   return (PyObject *) self;
 }
 
 static int
 Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds)
 {
-  self->o = new_aubio_filter (self->order, self->channels);
+  self->o = new_aubio_filter (self->order);
   if (self->o == NULL) {
     return -1;
   }
@@ -91,11 +81,11 @@ Py_filter_do(PyObject * self, PyObject * args)
   // compute the function
 #if 1
   aubio_filter_do (((Py_filter *)self)->o, vec->o);
-  Py_INCREF(vec);
+  PyArray_INCREF((PyArrayObject*)vec);
   return (PyObject *)vec;
 #else
   Py_fvec *copy = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
-  copy->o = new_fvec(vec->o->length, vec->o->channels);
+  copy->o = new_fvec(vec->o->length);
   aubio_filter_do_outplace (((Py_filter *)self)->o, vec->o, copy->o);
   return (PyObject *)copy;
 #endif
@@ -141,8 +131,6 @@ static PyMemberDef Py_filter_members[] = {
   // TODO remove READONLY flag and define getter/setter
   {"order", T_INT, offsetof (Py_filter, order), READONLY,
       "order of the filter"},
-  {"channels", T_INT, offsetof (Py_filter, channels), READONLY,
-      "number of channels"},
   {NULL}                        /* Sentinel */
 };
 
index f8a1307..95c9421 100644 (file)
@@ -67,9 +67,8 @@ Py_filterbank_do(Py_filterbank * self, PyObject * args)
   }
 
   output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
-  output->channels = vec->channels;
   output->length = self->n_filters;
-  output->o = new_fvec(self->n_filters, vec->channels);
+  output->o = new_fvec(self->n_filters);
 
   // compute the function
   aubio_filterbank_do (self->o, vec->o, output->o);
@@ -137,11 +136,9 @@ Py_filterbank_set_mel_coeffs_slaney (Py_filterbank * self, PyObject *args)
 static PyObject * 
 Py_filterbank_get_coeffs (Py_filterbank * self, PyObject *unused)
 {
-  Py_fvec *output = (Py_fvec *) PyObject_New (Py_fvec, &Py_fvecType);
-  output->channels = self->n_filters;
-  output->length = self->win_s / 2 + 1;
+  Py_fmat *output = (Py_fmat *) PyObject_New (Py_fmat, &Py_fvecType);
   output->o = aubio_filterbank_get_coeffs (self->o);
-  return (PyObject *)PyAubio_FvecToArray(output);
+  return (PyObject *)PyAubio_FmatToArray(output);
 }
 
 static PyMethodDef Py_filterbank_methods[] = {
diff --git a/interfaces/python/py-fmat.c b/interfaces/python/py-fmat.c
new file mode 100644 (file)
index 0000000..92c12c5
--- /dev/null
@@ -0,0 +1,332 @@
+#include "aubio-types.h"
+
+/* fmat type definition 
+
+class fmat():
+    def __init__(self, length = 1024, height = 1):
+        self.length = length 
+        self.height = height 
+        self.data = array(length, height)
+
+*/
+
+static char Py_fmat_doc[] = "fmat object";
+
+static PyObject *
+Py_fmat_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
+{
+  int length= 0, height = 0;
+  Py_fmat *self;
+  static char *kwlist[] = { "length", "height", NULL };
+
+  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
+          &length, &height)) {
+    return NULL;
+  }
+
+
+  self = (Py_fmat *) type->tp_alloc (type, 0);
+
+  self->length = Py_default_vector_length;
+  self->height = Py_default_vector_height;
+
+  if (self == NULL) {
+    return NULL;
+  }
+
+  if (length > 0) {
+    self->length = length;
+  } else if (length < 0) {
+    PyErr_SetString (PyExc_ValueError,
+        "can not use negative number of elements");
+    return NULL;
+  }
+
+  if (height > 0) {
+    self->height = height;
+  } else if (height < 0) {
+    PyErr_SetString (PyExc_ValueError,
+        "can not use negative number of height");
+    return NULL;
+  }
+
+  return (PyObject *) self;
+}
+
+static int
+Py_fmat_init (Py_fmat * self, PyObject * args, PyObject * kwds)
+{
+  self->o = new_fmat (self->length, self->height);
+  if (self->o == NULL) {
+    return -1;
+  }
+
+  return 0;
+}
+
+static void
+Py_fmat_del (Py_fmat * self)
+{
+  del_fmat (self->o);
+  self->ob_type->tp_free ((PyObject *) self);
+}
+
+static PyObject *
+Py_fmat_repr (Py_fmat * self, PyObject * unused)
+{
+  PyObject *format = NULL;
+  PyObject *args = NULL;
+  PyObject *result = NULL;
+
+  format = PyString_FromString ("aubio fmat of %d elements with %d height");
+  if (format == NULL) {
+    goto fail;
+  }
+
+  args = Py_BuildValue ("II", self->length, self->height);
+  if (args == NULL) {
+    goto fail;
+  }
+  fmat_print ( self->o );
+
+  result = PyString_Format (format, args);
+
+fail:
+  Py_XDECREF (format);
+  Py_XDECREF (args);
+
+  return result;
+}
+
+Py_fmat *
+PyAubio_ArrayTofmat (PyObject *input) {
+  PyObject *array;
+  Py_fmat *vec;
+  uint_t i;
+  if (input == NULL) {
+    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
+    goto fail;
+  }
+  // parsing input object into a Py_fmat
+  if (PyObject_TypeCheck (input, &Py_fmatType)) {
+    // input is an fmat, nothing else to do
+    vec = (Py_fmat *) input;
+  } else if (PyArray_Check(input)) {
+
+    // we got an array, convert it to an fmat 
+    if (PyArray_NDIM (input) == 0) {
+      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
+      goto fail;
+    } else if (PyArray_NDIM (input) > 2) {
+      PyErr_SetString (PyExc_ValueError,
+          "input array has more than two dimensions");
+      goto fail;
+    }
+
+    if (!PyArray_ISFLOAT (input)) {
+      PyErr_SetString (PyExc_ValueError, "input array should be float");
+      goto fail;
+    } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
+      PyErr_SetString (PyExc_ValueError, "input array should be float32");
+      goto fail;
+    } else {
+      // input data type is float32, nothing else to do
+      array = input;
+    }
+
+    // create a new fmat object
+    vec = (Py_fmat*) PyObject_New (Py_fmat, &Py_fmatType); 
+    if (PyArray_NDIM (array) == 1) {
+      vec->height = 1;
+      vec->length = PyArray_SIZE (array);
+    } else {
+      vec->height = PyArray_DIM (array, 0);
+      vec->length = PyArray_DIM (array, 1);
+    }
+
+    // no need to really allocate fmat, just its struct member 
+    // vec->o = new_fmat (vec->length, vec->height);
+    vec->o = (fmat_t *)malloc(sizeof(fmat_t));
+    vec->o->length = vec->length; vec->o->height = vec->height;
+    vec->o->data = (smpl_t**)malloc(vec->o->height * sizeof(smpl_t*));
+    // hat data[i] point to array line
+    for (i = 0; i < vec->height; i++) {
+      vec->o->data[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
+    }
+
+  } else {
+    PyErr_SetString (PyExc_ValueError, "can only accept array or fmat as input");
+    return NULL;
+  }
+
+  return vec;
+
+fail:
+  return NULL;
+}
+
+PyObject *
+PyAubio_CfmatToArray (fmat_t * self)
+{
+  PyObject *array = NULL;
+  uint_t i;
+  npy_intp dims[] = { self->length, 1 };
+  PyObject *concat = PyList_New (0), *tmp = NULL;
+  for (i = 0; i < self->height; i++) {
+    tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->data[i]);
+    PyList_Append (concat, tmp);
+    Py_DECREF (tmp);
+  }
+  array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
+  Py_DECREF (concat);
+  return array;
+}
+
+PyObject *
+PyAubio_FmatToArray (Py_fmat * self)
+{
+  PyObject *array = NULL;
+  if (self->height == 1) {
+    npy_intp dims[] = { self->length, 1 };
+    array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[0]);
+  } else {
+    uint_t i;
+    npy_intp dims[] = { self->length, 1 };
+    PyObject *concat = PyList_New (0), *tmp = NULL;
+    for (i = 0; i < self->height; i++) {
+      tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[i]);
+      PyList_Append (concat, tmp);
+      Py_DECREF (tmp);
+    }
+    array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
+    Py_DECREF (concat);
+  }
+  return array;
+}
+
+static Py_ssize_t
+Py_fmat_get_height (Py_fmat * self)
+{
+  return self->height;
+}
+
+static PyObject *
+Py_fmat_getitem (Py_fmat * self, Py_ssize_t index)
+{
+  PyObject *array;
+
+  if (index < 0 || index >= self->height) {
+    PyErr_SetString (PyExc_IndexError, "no such channel");
+    return NULL;
+  }
+
+  npy_intp dims[] = { self->length, 1 };
+  array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[index]);
+  return array;
+}
+
+static int
+Py_fmat_setitem (Py_fmat * self, Py_ssize_t index, PyObject * o)
+{
+  PyObject *array;
+
+  if (index < 0 || index >= self->height) {
+    PyErr_SetString (PyExc_IndexError, "no such channel");
+    return -1;
+  }
+
+  array = PyArray_FROM_OT (o, AUBIO_NPY_SMPL);
+  if (array == NULL) {
+    PyErr_SetString (PyExc_ValueError, "should be an array of float");
+    goto fail;
+  }
+
+  if (PyArray_NDIM (array) != 1) {
+    PyErr_SetString (PyExc_ValueError, "should be a one-dimensional array");
+    goto fail;
+  }
+
+  if (PyArray_SIZE (array) != self->length) {
+    PyErr_SetString (PyExc_ValueError,
+        "should be an array of same length as target fmat");
+    goto fail;
+  }
+
+  self->o->data[index] = (smpl_t *) PyArray_GETPTR1 (array, 0);
+
+  return 0;
+
+fail:
+  return -1;
+}
+
+static PyMemberDef Py_fmat_members[] = {
+  // TODO remove READONLY flag and define getter/setter
+  {"length", T_INT, offsetof (Py_fmat, length), READONLY,
+      "length attribute"},
+  {"height", T_INT, offsetof (Py_fmat, height), READONLY,
+      "height attribute"},
+  {NULL}                        /* Sentinel */
+};
+
+static PyMethodDef Py_fmat_methods[] = {
+  {"__array__", (PyCFunction) PyAubio_FmatToArray, METH_NOARGS,
+      "Returns the vector as a numpy array."},
+  {NULL}
+};
+
+static PySequenceMethods Py_fmat_tp_as_sequence = {
+  (lenfunc) Py_fmat_get_height,        /* sq_length         */
+  0,                                    /* sq_concat         */
+  0,                                    /* sq_repeat         */
+  (ssizeargfunc) Py_fmat_getitem,       /* sq_item           */
+  0,                                    /* sq_slice          */
+  (ssizeobjargproc) Py_fmat_setitem,    /* sq_ass_item       */
+  0,                                    /* sq_ass_slice      */
+  0,                                    /* sq_contains       */
+  0,                                    /* sq_inplace_concat */
+  0,                                    /* sq_inplace_repeat */
+};
+
+
+PyTypeObject Py_fmatType = {
+  PyObject_HEAD_INIT (NULL)
+  0,                            /* ob_size           */
+  "aubio.fmat",                 /* tp_name           */
+  sizeof (Py_fmat),             /* tp_basicsize      */
+  0,                            /* tp_itemsize       */
+  (destructor) Py_fmat_del,     /* tp_dealloc        */
+  0,                            /* tp_print          */
+  0,                            /* tp_getattr        */
+  0,                            /* tp_setattr        */
+  0,                            /* tp_compare        */
+  (reprfunc) Py_fmat_repr,      /* tp_repr           */
+  0,                            /* tp_as_number      */
+  &Py_fmat_tp_as_sequence,      /* tp_as_sequence    */
+  0,                            /* tp_as_mapping     */
+  0,                            /* tp_hash           */
+  0,                            /* tp_call           */
+  0,                            /* tp_str            */
+  0,                            /* tp_getattro       */
+  0,                            /* tp_setattro       */
+  0,                            /* tp_as_buffer      */
+  Py_TPFLAGS_DEFAULT,           /* tp_flags          */
+  Py_fmat_doc,                  /* tp_doc            */
+  0,                            /* tp_traverse       */
+  0,                            /* tp_clear          */
+  0,                            /* tp_richcompare    */
+  0,                            /* tp_weaklistoffset */
+  0,                            /* tp_iter           */
+  0,                            /* tp_iternext       */
+  Py_fmat_methods,              /* tp_methods        */
+  Py_fmat_members,              /* tp_members        */
+  0,                            /* tp_getset         */
+  0,                            /* tp_base           */
+  0,                            /* tp_dict           */
+  0,                            /* tp_descr_get      */
+  0,                            /* tp_descr_set      */
+  0,                            /* tp_dictoffset     */
+  (initproc) Py_fmat_init,      /* tp_init           */
+  0,                            /* tp_alloc          */
+  Py_fmat_new,                  /* tp_new            */
+};
index a625451..fbc38a2 100644 (file)
@@ -3,10 +3,9 @@
 /* fvec type definition 
 
 class fvec():
-    def __init__(self, length = 1024, channels = 1):
+    def __init__(self, length = 1024):
         self.length = length 
-        self.channels = channels 
-        self.data = array(length, channels)
+        self.data = array(length)
 
 */
 
@@ -15,20 +14,18 @@ static char Py_fvec_doc[] = "fvec object";
 static PyObject *
 Py_fvec_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
 {
-  int length= 0, channels = 0;
+  int length= 0;
   Py_fvec *self;
-  static char *kwlist[] = { "length", "channels", NULL };
+  static char *kwlist[] = { "length", NULL };
 
-  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
-          &length, &channels)) {
+  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
+          &length)) {
     return NULL;
   }
 
-
   self = (Py_fvec *) type->tp_alloc (type, 0);
 
   self->length = Py_default_vector_length;
-  self->channels = Py_default_vector_channels;
 
   if (self == NULL) {
     return NULL;
@@ -42,21 +39,13 @@ Py_fvec_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
     return NULL;
   }
 
-  if (channels > 0) {
-    self->channels = channels;
-  } else if (channels < 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "can not use negative number of channels");
-    return NULL;
-  }
-
   return (PyObject *) self;
 }
 
 static int
 Py_fvec_init (Py_fvec * self, PyObject * args, PyObject * kwds)
 {
-  self->o = new_fvec (self->length, self->channels);
+  self->o = new_fvec (self->length);
   if (self->o == NULL) {
     return -1;
   }
@@ -74,16 +63,17 @@ Py_fvec_del (Py_fvec * self)
 static PyObject *
 Py_fvec_repr (Py_fvec * self, PyObject * unused)
 {
+#if 0
   PyObject *format = NULL;
   PyObject *args = NULL;
   PyObject *result = NULL;
 
-  format = PyString_FromString ("aubio fvec of %d elements with %d channels");
+  format = PyString_FromString ("aubio fvec of %d elements");
   if (format == NULL) {
     goto fail;
   }
 
-  args = Py_BuildValue ("II", self->length, self->channels);
+  args = Py_BuildValue ("I", self->length);
   if (args == NULL) {
     goto fail;
   }
@@ -96,13 +86,33 @@ fail:
   Py_XDECREF (args);
 
   return result;
+#endif
+  PyObject *format = NULL;
+  PyObject *args = NULL;
+  PyObject *result = NULL;
+
+  format = PyString_FromString ("%s");
+  if (format == NULL) {
+    goto fail;
+  }
+
+  args = Py_BuildValue ("O", PyAubio_FvecToArray (self));
+  if (args == NULL) {
+    goto fail;
+  }
+
+  result = PyString_Format (format, args);
+fail:
+  Py_XDECREF (format);
+  Py_XDECREF (args);
+
+  return result;
 }
 
 Py_fvec *
 PyAubio_ArrayToFvec (PyObject *input) {
   PyObject *array;
   Py_fvec *vec;
-  uint_t i;
   if (input == NULL) {
     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     goto fail;
@@ -117,28 +127,18 @@ PyAubio_ArrayToFvec (PyObject *input) {
     if (PyArray_NDIM (input) == 0) {
       PyErr_SetString (PyExc_ValueError, "input array is a scalar");
       goto fail;
-    } else if (PyArray_NDIM (input) > 2) {
+    } else if (PyArray_NDIM (input) > 1) {
       PyErr_SetString (PyExc_ValueError,
-          "input array has more than two dimensions");
+          "input array has more than one dimensions");
       goto fail;
     }
 
     if (!PyArray_ISFLOAT (input)) {
       PyErr_SetString (PyExc_ValueError, "input array should be float");
       goto fail;
-#if AUBIO_DO_CASTING
-    } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
-      // input data type is not float32, casting 
-      array = PyArray_Cast ( (PyArrayObject*) input, AUBIO_NPY_SMPL);
-      if (array == NULL) {
-        PyErr_SetString (PyExc_IndexError, "failed converting to AUBIO_NPY_SMPL");
-        goto fail;
-      }
-#else
     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
       PyErr_SetString (PyExc_ValueError, "input array should be float32");
       goto fail;
-#endif
     } else {
       // input data type is float32, nothing else to do
       array = input;
@@ -146,26 +146,19 @@ PyAubio_ArrayToFvec (PyObject *input) {
 
     // create a new fvec object
     vec = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType); 
-    if (PyArray_NDIM (array) == 1) {
-      vec->channels = 1;
-      vec->length = PyArray_SIZE (array);
-    } else {
-      vec->channels = PyArray_DIM (array, 0);
-      vec->length = PyArray_DIM (array, 1);
-    }
+    vec->length = PyArray_SIZE (array);
 
     // no need to really allocate fvec, just its struct member 
-    // vec->o = new_fvec (vec->length, vec->channels);
+    // vec->o = new_fvec (vec->length);
     vec->o = (fvec_t *)malloc(sizeof(fvec_t));
-    vec->o->length = vec->length; vec->o->channels = vec->channels;
-    vec->o->data = (smpl_t**)malloc(vec->o->channels * sizeof(smpl_t*));
-    // hat data[i] point to array line
-    for (i = 0; i < vec->channels; i++) {
-      vec->o->data[i] = (smpl_t *) PyArray_GETPTR1 (array, i);
-    }
+    vec->o->length = vec->length;
+    vec->o->data = (smpl_t *) PyArray_GETPTR1 (array, 0);
 
+  } else if (PyObject_TypeCheck (input, &PyList_Type)) {
+    PyErr_SetString (PyExc_ValueError, "does not convert from list yet");
+    return NULL;
   } else {
-    PyErr_SetString (PyExc_ValueError, "can only accept array or fvec as input");
+    PyErr_SetString (PyExc_ValueError, "can only accept vector or fvec as input");
     return NULL;
   }
 
@@ -178,91 +171,45 @@ fail:
 PyObject *
 PyAubio_CFvecToArray (fvec_t * self)
 {
-  PyObject *array = NULL;
-  uint_t i;
   npy_intp dims[] = { self->length, 1 };
-  PyObject *concat = PyList_New (0), *tmp = NULL;
-  for (i = 0; i < self->channels; i++) {
-    tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->data[i]);
-    PyList_Append (concat, tmp);
-    Py_DECREF (tmp);
-  }
-  array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
-  Py_DECREF (concat);
-  return array;
+  return  PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->data);
 }
 
 PyObject *
 PyAubio_FvecToArray (Py_fvec * self)
 {
   PyObject *array = NULL;
-  if (self->channels == 1) {
-    npy_intp dims[] = { self->length, 1 };
-    array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[0]);
-  } else {
-    uint_t i;
-    npy_intp dims[] = { self->length, 1 };
-    PyObject *concat = PyList_New (0), *tmp = NULL;
-    for (i = 0; i < self->channels; i++) {
-      tmp = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[i]);
-      PyList_Append (concat, tmp);
-      Py_DECREF (tmp);
-    }
-    array = PyArray_FromObject (concat, AUBIO_NPY_SMPL, 2, 2);
-    Py_DECREF (concat);
-  }
+  npy_intp dims[] = { self->length, 1 };
+  array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data);
   return array;
 }
 
-static Py_ssize_t
-Py_fvec_getchannels (Py_fvec * self)
-{
-  return self->channels;
-}
-
 static PyObject *
 Py_fvec_getitem (Py_fvec * self, Py_ssize_t index)
 {
-  PyObject *array;
-
-  if (index < 0 || index >= self->channels) {
-    PyErr_SetString (PyExc_IndexError, "no such channel");
+  if (index < 0 || index >= self->length) {
+    PyErr_SetString (PyExc_IndexError, "no such element");
     return NULL;
   }
 
-  npy_intp dims[] = { self->length, 1 };
-  array = PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->data[index]);
-  return array;
+  return PyFloat_FromDouble (self->o->data[index]);
 }
 
 static int
 Py_fvec_setitem (Py_fvec * self, Py_ssize_t index, PyObject * o)
 {
-  PyObject *array;
-
-  if (index < 0 || index >= self->channels) {
-    PyErr_SetString (PyExc_IndexError, "no such channel");
-    return -1;
-  }
 
-  array = PyArray_FROM_OT (o, AUBIO_NPY_SMPL);
-  if (array == NULL) {
-    PyErr_SetString (PyExc_ValueError, "should be an array of float");
+  if (index < 0 || index >= self->length) {
+    PyErr_SetString (PyExc_IndexError, "no such element");
     goto fail;
   }
 
-  if (PyArray_NDIM (array) != 1) {
-    PyErr_SetString (PyExc_ValueError, "should be a one-dimensional array");
+  if (PyFloat_Check (o)) {
+    PyErr_SetString (PyExc_ValueError, "should be a float");
     goto fail;
   }
 
-  if (PyArray_SIZE (array) != self->length) {
-    PyErr_SetString (PyExc_ValueError,
-        "should be an array of same length as target fvec");
-    goto fail;
-  }
-
-  self->o->data[index] = (smpl_t *) PyArray_GETPTR1 (array, 0);
+  self->o->data[index] = (smpl_t) PyFloat_AsDouble(o);
 
   return 0;
 
@@ -270,12 +217,16 @@ fail:
   return -1;
 }
 
+int
+Py_fvec_get_length (Py_fvec * self)                                                                                                                                     
+{                                                                                                                                                                        
+  return self->length;                                                                                                                                                 
+}
+
 static PyMemberDef Py_fvec_members[] = {
   // TODO remove READONLY flag and define getter/setter
   {"length", T_INT, offsetof (Py_fvec, length), READONLY,
       "length attribute"},
-  {"channels", T_INT, offsetof (Py_fvec, channels), READONLY,
-      "channels attribute"},
   {NULL}                        /* Sentinel */
 };
 
@@ -286,7 +237,7 @@ static PyMethodDef Py_fvec_methods[] = {
 };
 
 static PySequenceMethods Py_fvec_tp_as_sequence = {
-  (lenfunc) Py_fvec_getchannels,        /* sq_length         */
+  (lenfunc) Py_fvec_get_length,        /* sq_length         */
   0,                                    /* sq_concat         */
   0,                                    /* sq_repeat         */
   (ssizeargfunc) Py_fvec_getitem,       /* sq_item           */
index 245152c..24be312 100644 (file)
@@ -2,18 +2,18 @@
 
 static char Py_pvoc_doc[] = "pvoc object";
 
-AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s; uint_t channels)
+AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s)
 
 //AUBIO_NEW(pvoc)
 static PyObject *
 Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
 {
-  int win_s = 0, hop_s = 0, channels = 0;
+  int win_s = 0, hop_s = 0;
   Py_pvoc *self;
-  static char *kwlist[] = { "win_s", "hop_s", "channels", NULL };
+  static char *kwlist[] = { "win_s", "hop_s", NULL };
 
-  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|III", kwlist,
-          &win_s, &hop_s, &channels)) {
+  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
+          &win_s, &hop_s)) {
     return NULL;
   }
 
@@ -25,7 +25,6 @@ Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
 
   self->win_s = Py_default_vector_length;
   self->hop_s = Py_default_vector_length/2;
-  self->channels = Py_default_vector_channels;
 
   if (self == NULL) {
     return NULL;
@@ -47,19 +46,11 @@ Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
     return NULL;
   }
 
-  if (channels > 0) {
-    self->channels = channels;
-  } else if (channels < 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "can not use negative number of filters");
-    return NULL;
-  }
-
   return (PyObject *) self;
 }
 
 
-AUBIO_INIT(pvoc, self->win_s, self->hop_s, self->channels)
+AUBIO_INIT(pvoc, self->win_s, self->hop_s)
 
 AUBIO_DEL(pvoc)
 
@@ -81,9 +72,8 @@ Py_pvoc_do(PyObject * self, PyObject * args)
   }
 
   output = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
-  output->channels = vec->channels;
   output->length = ((Py_pvoc *) self)->win_s;
-  output->o = new_cvec(((Py_pvoc *) self)->win_s, vec->channels);
+  output->o = new_cvec(((Py_pvoc *) self)->win_s);
 
   // compute the function
   aubio_pvoc_do (((Py_pvoc *)self)->o, vec->o, output->o);
@@ -97,8 +87,6 @@ AUBIO_MEMBERS_START(pvoc)
     "size of the window"},
   {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY,
     "size of the hop"},
-  {"channels", T_INT, offsetof (Py_pvoc, channels), READONLY,
-    "number of channels"},
 AUBIO_MEMBERS_STOP(pvoc)
 
 static PyObject * 
@@ -119,9 +107,8 @@ Py_pvoc_rdo(PyObject * self, PyObject * args)
   }
 
   output = (Py_fvec*) PyObject_New (Py_fvec, &Py_fvecType);
-  output->channels = vec->channels;
   output->length = ((Py_pvoc *) self)->hop_s;
-  output->o = new_fvec(output->length, output->channels);
+  output->o = new_fvec(output->length);
 
   // compute the function
   aubio_pvoc_rdo (((Py_pvoc *)self)->o, vec->o, output->o);
index dee021d..a1d9081 100644 (file)
@@ -10,6 +10,7 @@ setup(name="_aubio", version="1.0",
         Extension("_aubio",
             ["aubiomodule.c",
             "py-fvec.c",
+            "py-fmat.c",
             "py-cvec.c",
             "py-filter.c",
             # macroised 
index 6cb1712..0af5956 100644 (file)
@@ -3,126 +3,11 @@ from numpy.testing import assert_equal
 from _aubio import *
 from numpy import array
 
-AUBIO_DO_CASTING = 0
-
 class aubiomodule_test_case(TestCase):
 
   def setUp(self):
     """ try importing aubio """
 
-  def test_vector(self):
-    a = fvec()
-    a.length, a.channels
-    a[0]
-    array(a)
-    a = fvec(10)
-    a = fvec(1, 2)
-    array(a).T
-    a[0] = range(a.length)
-    a[1][0] = 2
-
-  def test_wrong_values(self):
-    self.assertRaises (ValueError, fvec, -10)
-    self.assertRaises (ValueError, fvec, 1, -1)
-  
-    a = fvec(2, 3)
-    self.assertRaises (IndexError, a.__getitem__, 3)
-    self.assertRaises (IndexError, a[0].__getitem__, 2)
-
-  def test_alpha_norm_of_fvec(self):
-    a = fvec(2, 2)
-    self.assertEquals (alpha_norm(a, 1), 0)
-    a[0] = [1, 2] 
-    self.assertEquals (alpha_norm(a, 1), 1.5)
-    a[1] = [1, 2] 
-    self.assertEquals (alpha_norm(a, 1), 3)
-    a[0] = [0, 1]; a[1] = [1, 0]
-    self.assertEquals (alpha_norm(a, 2), 1)
-
-  def test_alpha_norm_of_array_of_float32(self):
-    # check scalar fails
-    a = array(1, dtype = 'float32')
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-    # check 3d array fails
-    a = array([[[1,2],[3,4]]], dtype = 'float32')
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-    # check 1d array
-    a = array(range(10), dtype = 'float32')
-    self.assertEquals (alpha_norm(a, 1), 4.5)
-    # check 2d array
-    a = array([range(10), range(10)], dtype = 'float32')
-    self.assertEquals (alpha_norm(a, 1), 9)
-
-  def test_alpha_norm_of_array_of_int(self):
-    a = array(1, dtype = 'int')
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-    a = array([[[1,2],[3,4]]], dtype = 'int')
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-    a = array(range(10), dtype = 'int')
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-
-  def test_alpha_norm_of_array_of_string (self):
-    a = "hello"
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-
-  def test_zero_crossing_rate(self):
-    a = array([0,1,-1], dtype='float32')
-    self.assertEquals (zero_crossing_rate(a), 1./3 )
-    a = array([0.]*100, dtype='float32')
-    self.assertEquals (zero_crossing_rate(a), 0 )
-    a = array([-1.]*100, dtype='float32')
-    self.assertEquals (zero_crossing_rate(a), 0 )
-    a = array([1.]*100, dtype='float32')
-    self.assertEquals (zero_crossing_rate(a), 0 )
-
-  def test_alpha_norm_of_array_of_float64(self):
-    # check scalar fail
-    a = array(1, dtype = 'float64')
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-    # check 3d array fail
-    a = array([[[1,2],[3,4]]], dtype = 'float64')
-    self.assertRaises (ValueError, alpha_norm, a, 1)
-    if AUBIO_DO_CASTING:
-      # check float64 1d array fail
-      a = array(range(10), dtype = 'float64')
-      self.assertEquals (alpha_norm(a, 1), 4.5)
-      # check float64 2d array fail
-      a = array([range(10), range(10)], dtype = 'float64')
-      self.assertEquals (alpha_norm(a, 1), 9)
-    else:
-      # check float64 1d array fail
-      a = array(range(10), dtype = 'float64')
-      self.assertRaises (ValueError, alpha_norm, a, 1)
-      # check float64 2d array fail
-      a = array([range(10), range(10)], dtype = 'float64')
-      self.assertRaises (ValueError, alpha_norm, a, 1)
-
-  def test_fvec_min_removal_of_array(self):
-    a = array([20,1,19], dtype='float32')
-    b = min_removal(a)
-    assert_equal (array(b), [19, 0, 18])
-    assert_equal (b, [19, 0, 18])
-    assert_equal (a, b)
-    a[0] = 0
-    assert_equal (a, b)
-
-  def test_fvec_min_removal_of_array_float64(self):
-    a = array([20,1,19], dtype='float64')
-    if AUBIO_DO_CASTING:
-      b = min_removal(a)
-      assert_equal (array(b), [19, 0, 18])
-      assert_equal (b, [19, 0, 18])
-      #assert_equal (a, b)
-    else:
-      self.assertRaises (ValueError, min_removal, a)
-      
-  def test_fvec_min_removal_of_fvec(self):
-    a = fvec(3, 1)
-    a[0] = [20, 1, 19]
-    b = min_removal(a)
-    assert_equal (array(b), [19, 0, 18])
-    assert_equal (b, [19, 0, 18])
-    assert_equal (a, b)
 
 if __name__ == '__main__':
   from unittest import main
diff --git a/interfaces/python/test_fvec.py b/interfaces/python/test_fvec.py
new file mode 100644 (file)
index 0000000..ba124e9
--- /dev/null
@@ -0,0 +1,122 @@
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+from _aubio import *
+from numpy import array
+
+class aubio_fvec_test_case(TestCase):
+
+
+    def test_vector_created_with_zeroes(self):
+        a = fvec()
+        assert_equal(array(a), 0.)
+
+    def test_vector_assign_element(self):
+        a = fvec()
+        a[0] = 1
+        assert_equal(a[0], 1)
+
+    def test_vector_assign_element_end(self):
+        a = fvec()
+        a[-1] = 1
+        assert_equal(a[-1], 1)
+        assert_equal(a[a.length-1], 1)
+
+    def test_vector(self):
+        a = fvec()
+        a, a.length
+        a[0]
+        array(a)
+        a = fvec(10)
+        a = fvec(1)
+        array(a).T
+        a[0] = range(a.length)
+
+    def test_wrong_values(self):
+        self.assertRaises (ValueError, fvec, -10)
+  
+        a = fvec(2)
+        self.assertRaises (IndexError, a.__getitem__, 3)
+        self.assertRaises (IndexError, a.__getitem__, 2)
+
+    def test_alpha_norm_of_fvec(self):
+        a = fvec(2)
+        self.assertEquals (alpha_norm(a, 1), 0)
+        a[0] = 1
+        self.assertEquals (alpha_norm(a, 1), 0.5)
+        a[1] = 1
+        self.assertEquals (alpha_norm(a, 1), 1)
+        a = array([0, 1], dtype='float32')
+        from math import sqrt
+        assert_almost_equal (alpha_norm(a, 2), sqrt(2)/2.)
+
+    def test_alpha_norm_of_array_of_float32(self):
+        # check scalar fails
+        a = array(1, dtype = 'float32')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check 2d array fails
+        a = array([[2],[4]], dtype = 'float32')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check 1d array
+        a = array(range(10), dtype = 'float32')
+        self.assertEquals (alpha_norm(a, 1), 4.5)
+
+    def test_alpha_norm_of_array_of_int(self):
+        a = array(1, dtype = 'int')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        a = array([[[1,2],[3,4]]], dtype = 'int')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        a = array(range(10), dtype = 'int')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+
+    def test_alpha_norm_of_array_of_string (self):
+        a = "hello"
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+
+    def test_zero_crossing_rate(self):
+        a = array([0,1,-1], dtype='float32')
+        self.assertEquals (zero_crossing_rate(a), 1./3 )
+        a = array([0.]*100, dtype='float32')
+        self.assertEquals (zero_crossing_rate(a), 0 )
+        a = array([-1.]*100, dtype='float32')
+        self.assertEquals (zero_crossing_rate(a), 0 )
+        a = array([1.]*100, dtype='float32')
+        self.assertEquals (zero_crossing_rate(a), 0 )
+
+    def test_alpha_norm_of_array_of_float64(self):
+        # check scalar fail
+        a = array(1, dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check 3d array fail
+        a = array([[[1,2],[3,4]]], dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check float64 1d array fail
+        a = array(range(10), dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check float64 2d array fail
+        a = array([range(10), range(10)], dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+
+    def test_fvec_min_removal_of_array(self):
+        a = array([20,1,19], dtype='float32')
+        b = min_removal(a)
+        assert_equal (array(b), [19, 0, 18])
+        assert_equal (b, [19, 0, 18])
+        assert_equal (a, b)
+        a[0] = 0
+        assert_equal (a, b)
+
+    def test_fvec_min_removal_of_array_float64(self):
+        a = array([20,1,19], dtype='float64')
+        self.assertRaises (ValueError, min_removal, a)
+
+    def test_fvec_min_removal_of_fvec(self):
+        a = fvec(3)
+        a = array([20, 1, 19], dtype = 'float32')
+        b = min_removal(a)
+        assert_equal (array(b), [19, 0, 18])
+        assert_equal (b, [19, 0, 18])
+        assert_equal (a, b)
+
+if __name__ == '__main__':
+    from unittest import main
+    main()
index bdd2913..e9cf923 100644 (file)
   \subsection vectors Vectors
 
   Two basic structures are being used in aubio: ::fvec_t and ::cvec_t. The
-  ::fvec_t structures are used to store vectors of floating pointer number,
-  optionally on several channels. ::cvec_t are used to store complex number,
-  as two vectors of norm and phase elements, also on several channels.
+  ::fvec_t structures are used to store vectors of floating pointer number.
+  ::cvec_t are used to store complex number, as two vectors of norm and phase
+  elements.
+
   Additionally, the ::lvec_t structure can be used to store floating point
   numbers in double precision. They are mostly used to store filter
   coefficients, to avoid instability.
+
   \subsection objects Available objects
 
   Here is a list of some of the most common objects for aubio:
   \code
 
   // fast Fourier transform (FFT)
-  aubio_fft_t *fft = new_aubio_fft (winsize, channels);
+  aubio_fft_t *fft = new_aubio_fft (winsize);
   // phase vocoder
-  aubio_pvoc_t *pv = new_aubio_pvoc (winsize, stepsize, channels);
-  // onset detection 
-  aubio_onset_t *onset = new_aubio_onset (method, winsize, stepsize, channels, samplerate);
-  // pitch detection 
-  aubio_pitch_t *pitch = new_aubio_pitch (method, winsize, stepsize, channels, samplerate);
+  aubio_pvoc_t *pv = new_aubio_pvoc (winsize, stepsize);
+  // onset detection
+  aubio_onset_t *onset = new_aubio_onset (method, winsize, stepsize, samplerate);
+  // pitch detection
+  aubio_pitch_t *pitch = new_aubio_pitch (method, winsize, stepsize, samplerate);
   // beat tracking
-  aubio_tempo_t *tempo = new_aubio_tempo (method, winsize, stepsize, channels, samplerate);
+  aubio_tempo_t *tempo = new_aubio_tempo (method, winsize, stepsize, samplerate);
 
   \endcode
 
 
   Here is a simple example that creates an A-Weighting filter and applies it to a
   vector.
+
   \code
 
-  // set channels, window size, and sampling rate 
-  uint_t channels = 2, winsize = 1024, sr = 44100;
+  // set window size, and sampling rate
+  uint_t winsize = 1024, sr = 44100;
   // create a vector
-  fvec_t *this_buffer = new_fvec (winsize, channels);
+  fvec_t *this_buffer = new_fvec (winsize);
   // create the a-weighting filter
-  aubio_filter_t *this_filter = new_aubio_filter_a_weighting (channels, sr);
-  
+  aubio_filter_t *this_filter = new_aubio_filter_a_weighting (sr);
+
   while (running) {
     // here some code to put some data in this_buffer
     // ...
     // apply the filter, in place
     aubio_filter_do (this_filter, this_buffer);
 
-    // here some code to get some data from this_buffer 
+    // here some code to get some data from this_buffer
     // ...
   }
-  
+
   // and free the structures
   del_aubio_filter (this_filter);
   del_fvec (this_buffer);
   your own.
 
   \section download Download
+
   Latest versions, further documentation, examples, wiki, and mailing lists can
   be found at http://aubio.org .
+
  */
 
 #ifndef AUBIO_H
 /** @file aubio.h Global aubio include file.
 
   Programmers just need to include this file as:
+
   @code
     #include <aubio/aubio.h>
   @endcode
+
  */
 
 #ifdef __cplusplus
@@ -157,6 +157,7 @@ extern "C"
 #include "fvec.h"
 #include "cvec.h"
 #include "lvec.h"
+#include "fmat.h"
 #include "musicutils.h"
 #include "temporal/resampler.h"
 #include "temporal/filter.h"
index 877cca3..b1b31f4 100644 (file)
 #include "aubio_priv.h"
 #include "cvec.h"
 
-cvec_t * new_cvec( uint_t length, uint_t channels) {
+cvec_t * new_cvec( uint_t length) {
   cvec_t * s = AUBIO_NEW(cvec_t);
-  uint_t i,j;
-  s->channels = channels;
+  uint_t j;
   s->length = length/2 + 1;
-  s->norm = AUBIO_ARRAY(smpl_t*,s->channels);
-  s->phas = AUBIO_ARRAY(smpl_t*,s->channels);
-  for (i=0; i< s->channels; i++) {
-    s->norm[i] = AUBIO_ARRAY(smpl_t,s->length);
-    s->phas[i] = AUBIO_ARRAY(smpl_t,s->length);
-    for (j=0; j< s->length; j++) {
-      s->norm[i][j]=0.;
-      s->phas[i][j]=0.;
-    }
+  s->norm = AUBIO_ARRAY(smpl_t,s->length);
+  s->phas = AUBIO_ARRAY(smpl_t,s->length);
+  for (j=0; j< s->length; j++) {
+    s->norm[j]=0.;
+    s->phas[j]=0.;
   }
   return s;
 }
 
 void del_cvec(cvec_t *s) {
-  uint_t i;
-  for (i=0; i<s->channels; i++) {
-    AUBIO_FREE(s->norm[i]);
-    AUBIO_FREE(s->phas[i]);
-  }
   AUBIO_FREE(s->norm);
   AUBIO_FREE(s->phas);
   AUBIO_FREE(s);
 }
 
-void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
-  s->norm[channel][position] = data;
-}
-void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
-  s->phas[channel][position] = data;
-}
-smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
-  return s->norm[channel][position];
+void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) {
+  s->norm[position] = data;
 }
-smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
-  return s->phas[channel][position];
+void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) {
+  s->phas[position] = data;
 }
-void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
-  s->norm[channel] = data;
+smpl_t cvec_read_norm(cvec_t *s, uint_t position) {
+  return s->norm[position];
 }
-void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
-  s->phas[channel] = data;
+smpl_t cvec_read_phas(cvec_t *s, uint_t position) {
+  return s->phas[position];
 }
-smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
-  return s->norm[channel];
-}
-smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
-  return s->phas[channel];
-}
-smpl_t ** cvec_get_norm(cvec_t *s) {
+smpl_t * cvec_get_norm(cvec_t *s) {
   return s->norm;
 }
-smpl_t ** cvec_get_phas(cvec_t *s) {
+smpl_t * cvec_get_phas(cvec_t *s) {
   return s->phas;
 }
 
 /* helper functions */
 
 void cvec_print(cvec_t *s) {
-  uint_t i,j;
-  for (i=0; i< s->channels; i++) {
-    AUBIO_MSG("norm: ");
-    for (j=0; j< s->length; j++) {
-      AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[i][j]);
-    }
-    AUBIO_MSG("\n");
-    AUBIO_MSG("phas: ");
-    for (j=0; j< s->length; j++) {
-      AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[i][j]);
-    }
-    AUBIO_MSG("\n");
+  uint_t j;
+  AUBIO_MSG("norm: ");
+  for (j=0; j< s->length; j++) {
+    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[j]);
+  }
+  AUBIO_MSG("\n");
+  AUBIO_MSG("phas: ");
+  for (j=0; j< s->length; j++) {
+    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[j]);
   }
+  AUBIO_MSG("\n");
 }
 
 void cvec_set(cvec_t *s, smpl_t val) {
-  uint_t i,j;
-  for (i=0; i< s->channels; i++) {
-    for (j=0; j< s->length; j++) {
-      s->norm[i][j] = val;
-    }
+  uint_t j;
+  for (j=0; j< s->length; j++) {
+    s->norm[j] = val;
   }
 }
 
index ff6d2b6..4dc307c 100644 (file)
@@ -38,24 +38,22 @@ extern "C" {
 /** Buffer for complex data */
 typedef struct {
   uint_t length;   /**< length of buffer = (requested length)/2 + 1 */
-  uint_t channels; /**< number of channels */
-  smpl_t **norm;   /**< norm array of size [length] * [channels] */
-  smpl_t **phas;   /**< phase array of size [length] * [channels] */
+  smpl_t *norm;   /**< norm array of size [length] */
+  smpl_t *phas;   /**< phase array of size [length] */
 } cvec_t;
 
 /** cvec_t buffer creation function
 
   This function creates a cvec_t structure holding two arrays of size
-  [length/2+1] * channels, corresponding to the norm and phase values of the
+  [length/2+1], corresponding to the norm and phase values of the
   spectral frame. The length stored in the structure is the actual size of both
   arrays, not the length of the complex and symetrical vector, specified as
   creation argument.
 
   \param length the length of the buffer to create
-  \param channels the number of channels in the buffer
 
 */
-cvec_t * new_cvec(uint_t length, uint_t channels);
+cvec_t * new_cvec(uint_t length);
 /** cvec_t buffer deletion function
 
   \param s buffer to delete as returned by new_cvec()
@@ -65,99 +63,49 @@ void del_cvec(cvec_t *s);
 /** write norm value in a complex buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->norm[channel][position]. Its purpose
+  result can be obtained by assigning vec->norm[position]. Its purpose
   is to access these values from wrappers, as created by swig.
 
   \param s vector to write to 
-  \param data norm value to write in s->norm[channel][position]
-  \param channel channel to write to 
+  \param data norm value to write in s->norm[position]
   \param position sample position to write to
 
 */
-void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
+void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
 /** write phase value in a complex buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->phas[channel][position]. Its purpose
+  result can be obtained by assigning vec->phas[position]. Its purpose
   is to access these values from wrappers, as created by swig.
 
   \param s vector to write to
-  \param data phase value to write in s->phas[channel][position]
-  \param channel channel to write to
+  \param data phase value to write in s->phas[position]
   \param position sample position to write to
 
 */
-void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
+void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
 /** read norm value from a complex buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained with vec->norm[channel][position]. Its purpose is to
+  result can be obtained with vec->norm[position]. Its purpose is to
   access these values from wrappers, as created by swig.
 
   \param s vector to read from
-  \param channel channel to read from
   \param position sample position to read from
 
 */
-smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
+smpl_t cvec_read_norm(cvec_t *s, uint_t position);
 /** read phase value from a complex buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained with vec->phas[channel][position]. Its purpose is to
+  result can be obtained with vec->phas[position]. Its purpose is to
   access these values from wrappers, as created by swig.
 
   \param s vector to read from
-  \param channel channel to read from
   \param position sample position to read from
 
 */
-smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
-/** write norm channel in a complex buffer
-
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->norm[channel]. Its purpose is to
-  access these values from wrappers, as created by swig.
-
-  \param s vector to write to
-  \param data norm vector of [length] samples to write in s->norm[channel]
-  \param channel channel to write to
-
-*/
-void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
-/** write phase channel in a complex buffer
-
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->phas[channel]. Its purpose is to
-  access these values from wrappers, as created by swig.
-
-  \param s vector to write to
-  \param data phase vector of [length] samples to write in s->phas[channel]
-  \param channel channel to write to
-
-*/
-void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
-/** read norm channel from a complex buffer
-
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained with vec->norm[channel]. Its purpose is to access
-  these values from wrappers, as created by swig.
-
-  \param s vector to read from 
-  \param channel channel to read from
-
-*/
-smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
-/** write phase channel in a complex buffer
-
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained with vec->phas[channel]. Its purpose is to access
-  these values from wrappers, as created by swig.
-
-  \param s vector to read from 
-  \param channel channel to read from 
-
-*/
-smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
+smpl_t cvec_read_phas(cvec_t *s, uint_t position);
 /** read norm data from a complex buffer
 
   Note that this function is not used in the aubio library, since the same
@@ -167,7 +115,7 @@ smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
   \param s vector to read from
 
 */
-smpl_t ** cvec_get_norm(cvec_t *s);
+smpl_t * cvec_get_norm(cvec_t *s);
 /** read phase data from a complex buffer
 
   Note that this function is not used in the aubio library, since the same
@@ -177,7 +125,7 @@ smpl_t ** cvec_get_norm(cvec_t *s);
   \param s vector to read from
 
 */
-smpl_t ** cvec_get_phas(cvec_t *s);
+smpl_t * cvec_get_phas(cvec_t *s);
 
 /** print out cvec data 
 
diff --git a/src/fmat.c b/src/fmat.c
new file mode 100644 (file)
index 0000000..a92b8c6
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+  Copyright (C) 2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "aubio_priv.h"
+#include "fmat.h"
+
+fmat_t * new_fmat (uint_t length, uint_t height) {
+  fmat_t * s = AUBIO_NEW(fmat_t);
+  uint_t i,j;
+  s->height = height;
+  s->length = length;
+  s->data = AUBIO_ARRAY(smpl_t*,s->height);
+  for (i=0; i< s->height; i++) {
+    s->data[i] = AUBIO_ARRAY(smpl_t, s->length);
+    for (j=0; j< s->length; j++) {
+      s->data[i][j]=0.;
+    }
+  }
+  return s;
+}
+
+void del_fmat (fmat_t *s) {
+  uint_t i;
+  for (i=0; i<s->height; i++) {
+    AUBIO_FREE(s->data[i]);
+  }
+  AUBIO_FREE(s->data);
+  AUBIO_FREE(s);
+}
+
+void fmat_write_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position) {
+  s->data[channel][position] = data;
+}
+smpl_t fmat_read_sample(fmat_t *s, uint_t channel, uint_t position) {
+  return s->data[channel][position];
+}
+void fmat_put_channel(fmat_t *s, smpl_t * data, uint_t channel) {
+  s->data[channel] = data;
+}
+smpl_t * fmat_get_channel(fmat_t *s, uint_t channel) {
+  return s->data[channel];
+}
+
+smpl_t ** fmat_get_data(fmat_t *s) {
+  return s->data;
+}
+
+/* helper functions */
+
+void fmat_print(fmat_t *s) {
+  uint_t i,j;
+  for (i=0; i< s->height; i++) {
+    for (j=0; j< s->length; j++) {
+      AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[i][j]);
+    }
+    AUBIO_MSG("\n");
+  }
+}
+
+void fmat_set(fmat_t *s, smpl_t val) {
+  uint_t i,j;
+  for (i=0; i< s->height; i++) {
+    for (j=0; j< s->length; j++) {
+      s->data[i][j] = val;
+    }
+  }
+}
+
+void fmat_zeros(fmat_t *s) {
+  fmat_set(s, 0.);
+}
+
+void fmat_ones(fmat_t *s) {
+  fmat_set(s, 1.);
+}
+
+void fmat_rev(fmat_t *s) {
+  uint_t i,j;
+  for (i=0; i< s->height; i++) {
+    for (j=0; j< FLOOR(s->length/2); j++) {
+      ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]);
+    }
+  }
+}
+
+void fmat_weight(fmat_t *s, fmat_t *weight) {
+  uint_t i,j;
+  uint_t length = MIN(s->length, weight->length);
+  for (i=0; i< s->height; i++) {
+    for (j=0; j< length; j++) {
+      s->data[i][j] *= weight->data[0][j];
+    }
+  }
+}
+
+void fmat_copy(fmat_t *s, fmat_t *t) {
+  uint_t i,j;
+  uint_t height = MIN(s->height, t->height);
+  uint_t length = MIN(s->length, t->length);
+  if (s->height != t->height) {
+    AUBIO_ERR("warning, trying to copy %d rows to %d rows \n", 
+            s->height, t->height);
+  }
+  if (s->length != t->length) {
+    AUBIO_ERR("warning, trying to copy %d columns to %d columns\n", 
+            s->length, t->length);
+  }
+  for (i=0; i< height; i++) {
+    for (j=0; j< length; j++) {
+      t->data[i][j] = s->data[i][j];
+    }
+  }
+}
+
diff --git a/src/fmat.h b/src/fmat.h
new file mode 100644 (file)
index 0000000..855b2ad
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+  Copyright (C) 2009 Paul Brossier <piem@aubio.org>
+
+  This file is part of aubio.
+
+  aubio is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  aubio is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FMAT_H
+#define _FMAT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \file
+
+  Real buffers
+
+  This file specifies the fmat_t type, which is used in aubio to store real
+  valued arrays.
+
+*/
+
+/** Buffer for real data */
+typedef struct {
+  uint_t length;   /**< length of buffer */
+  uint_t height; /**< number of channels */
+  smpl_t **data;   /**< data array of size [length] * [channels] */
+} fmat_t;
+
+/** fmat_t buffer creation function
+
+  \param length the length of the buffer to create
+  \param channels the number of channels in the buffer
+
+*/
+fmat_t * new_fmat(uint_t length, uint_t channels);
+/** fmat_t buffer deletion function
+
+  \param s buffer to delete as returned by new_fmat()
+
+*/
+void del_fmat(fmat_t *s);
+/** read sample value in a buffer
+
+  Note that this function is not used in the aubio library, since the same
+  result can be obtained using vec->data[channel][position]. Its purpose is to
+  access these values from wrappers, as created by swig.
+
+  \param s vector to read from
+  \param channel channel to read from
+  \param position sample position to read from 
+
+*/
+smpl_t fmat_read_sample(fmat_t *s, uint_t channel, uint_t position);
+/** write sample value in a buffer
+
+  Note that this function is not used in the aubio library, since the same
+  result can be obtained by assigning vec->data[channel][position]. Its purpose
+  is to access these values from wrappers, as created by swig.
+
+  \param s vector to write to 
+  \param data value to write in s->data[channel][position]
+  \param channel channel to write to 
+  \param position sample position to write to 
+
+*/
+void  fmat_write_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position);
+/** read channel vector from a buffer
+
+  Note that this function is not used in the aubio library, since the same
+  result can be obtained with vec->data[channel]. Its purpose is to access
+  these values from wrappers, as created by swig.
+
+  \param s vector to read from
+  \param channel channel to read from
+
+*/
+smpl_t * fmat_get_channel(fmat_t *s, uint_t channel);
+/** write channel vector into a buffer
+
+  Note that this function is not used in the aubio library, since the same
+  result can be obtained by assigning vec->data[channel]. Its purpose is to
+  access these values from wrappers, as created by swig.
+
+  \param s vector to write to 
+  \param data vector of [length] values to write
+  \param channel channel to write to 
+
+*/
+void fmat_put_channel(fmat_t *s, smpl_t * data, uint_t channel);
+/** read data from a buffer
+
+  Note that this function is not used in the aubio library, since the same
+  result can be obtained with vec->data. Its purpose is to access these values
+  from wrappers, as created by swig.
+
+  \param s vector to read from
+
+*/
+smpl_t ** fmat_get_data(fmat_t *s);
+
+/** print out fmat data 
+
+  \param s vector to print out 
+
+*/
+void fmat_print(fmat_t *s);
+
+/** set all elements to a given value
+
+  \param s vector to modify
+  \param val value to set elements to
+
+*/
+void fmat_set(fmat_t *s, smpl_t val);
+
+/** set all elements to zero 
+
+  \param s vector to modify
+
+*/
+void fmat_zeros(fmat_t *s);
+
+/** set all elements to ones 
+
+  \param s vector to modify
+
+*/
+void fmat_ones(fmat_t *s);
+
+/** revert order of vector elements
+
+  \param s vector to revert
+
+*/
+void fmat_rev(fmat_t *s);
+
+/** apply weight to vector
+
+  If the weight vector is longer than s, only the first elements are used. If
+  the weight vector is shorter than s, the last elements of s are not weighted.
+
+  \param s vector to weight
+  \param weight weighting coefficients
+
+*/
+void fmat_weight(fmat_t *s, fmat_t *weight);
+
+/** make a copy of a matrix 
+
+  \param s source vector
+  \param t vector to copy to
+
+*/
+void fmat_copy(fmat_t *s, fmat_t *t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FMAT_H */
index 23a57a7..e559bfc 100644 (file)
 #include "aubio_priv.h"
 #include "fvec.h"
 
-fvec_t * new_fvec( uint_t length, uint_t channels) {
+fvec_t * new_fvec( uint_t length) {
   fvec_t * s = AUBIO_NEW(fvec_t);
-  uint_t i,j;
-  s->channels = channels;
+  uint_t j;
   s->length = length;
-  s->data = AUBIO_ARRAY(smpl_t*,s->channels);
-  for (i=0; i< s->channels; i++) {
-    s->data[i] = AUBIO_ARRAY(smpl_t, s->length);
-    for (j=0; j< s->length; j++) {
-      s->data[i][j]=0.;
-    }
+  s->data = AUBIO_ARRAY(smpl_t, s->length);
+  for (j=0; j< s->length; j++) {
+    s->data[j]=0.;
   }
   return s;
 }
 
 void del_fvec(fvec_t *s) {
-  uint_t i;
-  for (i=0; i<s->channels; i++) {
-    AUBIO_FREE(s->data[i]);
-  }
   AUBIO_FREE(s->data);
   AUBIO_FREE(s);
 }
 
-void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position) {
-  s->data[channel][position] = data;
-}
-smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position) {
-  return s->data[channel][position];
-}
-void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel) {
-  s->data[channel] = data;
+void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position) {
+  s->data[position] = data;
 }
-smpl_t * fvec_get_channel(fvec_t *s, uint_t channel) {
-  return s->data[channel];
+
+smpl_t fvec_read_sample(fvec_t *s, uint_t position) {
+  return s->data[position];
 }
 
-smpl_t ** fvec_get_data(fvec_t *s) {
+smpl_t * fvec_get_data(fvec_t *s) {
   return s->data;
 }
 
 /* helper functions */
 
 void fvec_print(fvec_t *s) {
-  uint_t i,j;
-  for (i=0; i< s->channels; i++) {
-    for (j=0; j< s->length; j++) {
-      AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[i][j]);
-    }
-    AUBIO_MSG("\n");
+  uint_t j;
+  for (j=0; j< s->length; j++) {
+    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[j]);
   }
+  AUBIO_MSG("\n");
 }
 
 void fvec_set(fvec_t *s, smpl_t val) {
-  uint_t i,j;
-  for (i=0; i< s->channels; i++) {
-    for (j=0; j< s->length; j++) {
-      s->data[i][j] = val;
-    }
+  uint_t j;
+  for (j=0; j< s->length; j++) {
+    s->data[j] = val;
   }
 }
 
@@ -92,40 +75,29 @@ void fvec_ones(fvec_t *s) {
 }
 
 void fvec_rev(fvec_t *s) {
-  uint_t i,j;
-  for (i=0; i< s->channels; i++) {
-    for (j=0; j< FLOOR(s->length/2); j++) {
-      ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]);
-    }
+  uint_t j;
+  for (j=0; j< FLOOR(s->length/2); j++) {
+    ELEM_SWAP(s->data[j], s->data[s->length-1-j]);
   }
 }
 
 void fvec_weight(fvec_t *s, fvec_t *weight) {
-  uint_t i,j;
+  uint_t j;
   uint_t length = MIN(s->length, weight->length);
-  for (i=0; i< s->channels; i++) {
-    for (j=0; j< length; j++) {
-      s->data[i][j] *= weight->data[0][j];
-    }
+  for (j=0; j< length; j++) {
+    s->data[j] *= weight->data[j];
   }
 }
 
 void fvec_copy(fvec_t *s, fvec_t *t) {
-  uint_t i,j;
-  uint_t channels = MIN(s->channels, t->channels);
+  uint_t j;
   uint_t length = MIN(s->length, t->length);
-  if (s->channels != t->channels) {
-    AUBIO_ERR("warning, trying to copy %d channels to %d channels\n", 
-            s->channels, t->channels);
-  }
   if (s->length != t->length) {
-    AUBIO_ERR("warning, trying to copy %d elements to %d elements \n", 
+    AUBIO_WRN("trying to copy %d elements to %d elements \n", 
             s->length, t->length);
   }
-  for (i=0; i< channels; i++) {
-    for (j=0; j< length; j++) {
-      t->data[i][j] = s->data[i][j];
-    }
+  for (j=0; j< length; j++) {
+    t->data[j] = s->data[j];
   }
 }
 
index c13fdc2..e08814e 100644 (file)
@@ -37,17 +37,15 @@ extern "C" {
 /** Buffer for real data */
 typedef struct {
   uint_t length;   /**< length of buffer */
-  uint_t channels; /**< number of channels */
-  smpl_t **data;   /**< data array of size [length] * [channels] */
+  smpl_t *data;   /**< data array of size [length] */
 } fvec_t;
 
 /** fvec_t buffer creation function
 
   \param length the length of the buffer to create
-  \param channels the number of channels in the buffer
 
 */
-fvec_t * new_fvec(uint_t length, uint_t channels);
+fvec_t * new_fvec(uint_t length);
 /** fvec_t buffer deletion function
 
   \param s buffer to delete as returned by new_fvec()
@@ -57,51 +55,27 @@ void del_fvec(fvec_t *s);
 /** read sample value in a buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained using vec->data[channel][position]. Its purpose is to
+  result can be obtained using vec->data[position]. Its purpose is to
   access these values from wrappers, as created by swig.
 
   \param s vector to read from
-  \param channel channel to read from
   \param position sample position to read from 
 
 */
-smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position);
+smpl_t fvec_read_sample(fvec_t *s, uint_t position);
 /** write sample value in a buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->data[channel][position]. Its purpose
+  result can be obtained by assigning vec->data[position]. Its purpose
   is to access these values from wrappers, as created by swig.
 
   \param s vector to write to 
-  \param data value to write in s->data[channel][position]
-  \param channel channel to write to 
+  \param data value to write in s->data[position]
   \param position sample position to write to 
 
 */
-void  fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position);
-/** read channel vector from a buffer
+void  fvec_write_sample(fvec_t *s, smpl_t data, uint_t position);
 
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained with vec->data[channel]. Its purpose is to access
-  these values from wrappers, as created by swig.
-
-  \param s vector to read from
-  \param channel channel to read from
-
-*/
-smpl_t * fvec_get_channel(fvec_t *s, uint_t channel);
-/** write channel vector into a buffer
-
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->data[channel]. Its purpose is to
-  access these values from wrappers, as created by swig.
-
-  \param s vector to write to 
-  \param data vector of [length] values to write
-  \param channel channel to write to 
-
-*/
-void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);
 /** read data from a buffer
 
   Note that this function is not used in the aubio library, since the same
@@ -111,7 +85,7 @@ void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);
   \param s vector to read from
 
 */
-smpl_t ** fvec_get_data(fvec_t *s);
+smpl_t * fvec_get_data(fvec_t *s);
 
 /** print out fvec data 
 
index 1f3234f..4fb40cd 100644 (file)
 #include "aubio_priv.h"
 #include "lvec.h"
 
-lvec_t * new_lvec( uint_t length, uint_t channels) {
+lvec_t * new_lvec( uint_t length) {
   lvec_t * s = AUBIO_NEW(lvec_t);
-  uint_t i,j;
-  s->channels = channels;
+  uint_t j;
   s->length = length;
-  s->data = AUBIO_ARRAY(lsmp_t*,s->channels);
-  for (i=0; i< s->channels; i++) {
-    s->data[i] = AUBIO_ARRAY(lsmp_t, s->length);
-    for (j=0; j< s->length; j++) {
-      s->data[i][j]=0.;
-    }
+  s->data = AUBIO_ARRAY(lsmp_t, s->length);
+  for (j=0; j< s->length; j++) {
+    s->data[j]=0.;
   }
   return s;
 }
 
 void del_lvec(lvec_t *s) {
-  uint_t i;
-  for (i=0; i<s->channels; i++) {
-    AUBIO_FREE(s->data[i]);
-  }
   AUBIO_FREE(s->data);
   AUBIO_FREE(s);
 }
 
-void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t channel, uint_t position) {
-  s->data[channel][position] = data;
-}
-lsmp_t lvec_read_sample(lvec_t *s, uint_t channel, uint_t position) {
-  return s->data[channel][position];
-}
-void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel) {
-  s->data[channel] = data;
+void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position) {
+  s->data[position] = data;
 }
-lsmp_t * lvec_get_channel(lvec_t *s, uint_t channel) {
-  return s->data[channel];
+lsmp_t lvec_read_sample(lvec_t *s, uint_t position) {
+  return s->data[position];
 }
 
-lsmp_t ** lvec_get_data(lvec_t *s) {
+lsmp_t * lvec_get_data(lvec_t *s) {
   return s->data;
 }
 
 /* helper functions */
 
 void lvec_print(lvec_t *s) {
-  uint_t i,j;
-  for (i=0; i< s->channels; i++) {
-    for (j=0; j< s->length; j++) {
-      AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[i][j]);
-    }
-    AUBIO_MSG("\n");
+  uint_t j;
+  for (j=0; j< s->length; j++) {
+    AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[j]);
   }
+  AUBIO_MSG("\n");
 }
 
 void lvec_set(lvec_t *s, smpl_t val) {
-  uint_t i,j;
-  for (i=0; i< s->channels; i++) {
-    for (j=0; j< s->length; j++) {
-      s->data[i][j] = val;
-    }
+  uint_t j;
+  for (j=0; j< s->length; j++) {
+    s->data[j] = val;
   }
 }
 
index 5273ea3..94fc8c6 100644 (file)
@@ -38,17 +38,15 @@ extern "C" {
 /** Buffer for real data in double precision */
 typedef struct {
   uint_t length;   /**< length of buffer */
-  uint_t channels; /**< number of channels */
-  lsmp_t **data;   /**< data array of size [length] * [channels] */
+  lsmp_t *data;   /**< data array of size [length] */
 } lvec_t;
 
 /** lvec_t buffer creation function
 
   \param length the length of the buffer to create
-  \param channels the number of channels in the buffer
 
 */
-lvec_t * new_lvec(uint_t length, uint_t channels);
+lvec_t * new_lvec(uint_t length);
 /** lvec_t buffer deletion function
 
   \param s buffer to delete as returned by new_lvec()
@@ -58,51 +56,27 @@ void del_lvec(lvec_t *s);
 /** read sample value in a buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained using vec->data[channel][position]. Its purpose is to
+  result can be obtained using vec->data[position]. Its purpose is to
   access these values from wrappers, as created by swig.
 
   \param s vector to read from
-  \param channel channel to read from
   \param position sample position to read from 
 
 */
-lsmp_t lvec_read_sample(lvec_t *s, uint_t channel, uint_t position);
+lsmp_t lvec_read_sample(lvec_t *s, uint_t position);
 /** write sample value in a buffer
 
   Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->data[channel][position]. Its purpose
+  result can be obtained by assigning vec->data[position]. Its purpose
   is to access these values from wrappers, as created by swig.
 
   \param s vector to write to 
-  \param data value to write in s->data[channel][position]
-  \param channel channel to write to 
+  \param data value to write in s->data[position]
   \param position sample position to write to 
 
 */
-void  lvec_write_sample(lvec_t *s, lsmp_t data, uint_t channel, uint_t position);
-/** read channel vector from a buffer
+void  lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position);
 
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained with vec->data[channel]. Its purpose is to access
-  these values from wrappers, as created by swig.
-
-  \param s vector to read from
-  \param channel channel to read from
-
-*/
-lsmp_t * lvec_get_channel(lvec_t *s, uint_t channel);
-/** write channel vector into a buffer
-
-  Note that this function is not used in the aubio library, since the same
-  result can be obtained by assigning vec->data[channel]. Its purpose is to
-  access these values from wrappers, as created by swig.
-
-  \param s vector to write to 
-  \param data vector of [length] values to write
-  \param channel channel to write to 
-
-*/
-void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel);
 /** read data from a buffer
 
   Note that this function is not used in the aubio library, since the same
@@ -112,7 +86,7 @@ void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel);
   \param s vector to read from
 
 */
-lsmp_t ** lvec_get_data(lvec_t *s);
+lsmp_t * lvec_get_data(lvec_t *s);
 
 /** print out lvec data 
 
index 6ff973b..d443fc1 100644 (file)
@@ -45,9 +45,8 @@ typedef enum
 fvec_t *
 new_aubio_window (char_t * window_type, uint_t size)
 {
-  // create fvec of size x 1 channel
-  fvec_t * win = new_fvec( size, 1);
-  smpl_t * w = win->data[0];
+  fvec_t * win = new_fvec (size);
+  smpl_t * w = win->data;
   uint_t i;
   aubio_window_type wintype;
   if (strcmp (window_type, "rectangle") == 0)
@@ -133,33 +132,21 @@ aubio_unwrap2pi (smpl_t phase)
 smpl_t
 fvec_mean (fvec_t * s)
 {
-  uint_t i, j;
-  smpl_t tmp = 0.0;
-  for (i = 0; i < s->channels; i++)
-    for (j = 0; j < s->length; j++)
-      tmp += s->data[i][j];
-  return tmp / (smpl_t) (s->length);
-}
-
-smpl_t
-fvec_mean_channel (fvec_t * s, uint_t i)
-{
   uint_t j;
   smpl_t tmp = 0.0;
-  for (j = 0; j < s->length; j++)
-      tmp += s->data[i][j];
+  for (j = 0; j < s->length; j++) {
+    tmp += s->data[j];
+  }
   return tmp / (smpl_t) (s->length);
 }
 
 smpl_t
 fvec_sum (fvec_t * s)
 {
-  uint_t i, j;
+  uint_t j;
   smpl_t tmp = 0.0;
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length; j++) {
-      tmp += s->data[i][j];
-    }
+  for (j = 0; j < s->length; j++) {
+    tmp += s->data[j];
   }
   return tmp;
 }
@@ -167,12 +154,10 @@ fvec_sum (fvec_t * s)
 smpl_t
 fvec_max (fvec_t * s)
 {
-  uint_t i, j;
+  uint_t j;
   smpl_t tmp = 0.0;
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length; j++) {
-      tmp = (tmp > s->data[i][j]) ? tmp : s->data[i][j];
-    }
+  for (j = 0; j < s->length; j++) {
+    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
   }
   return tmp;
 }
@@ -180,12 +165,10 @@ fvec_max (fvec_t * s)
 smpl_t
 fvec_min (fvec_t * s)
 {
-  uint_t i, j;
-  smpl_t tmp = s->data[0][0];
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length; j++) {
-      tmp = (tmp < s->data[i][j]) ? tmp : s->data[i][j];
-    }
+  uint_t j;
+  smpl_t tmp = s->data[0];
+  for (j = 0; j < s->length; j++) {
+    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
   }
   return tmp;
 }
@@ -193,13 +176,11 @@ fvec_min (fvec_t * s)
 uint_t
 fvec_min_elem (fvec_t * s)
 {
-  uint_t i, j, pos = 0.;
-  smpl_t tmp = s->data[0][0];
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length; j++) {
-      pos = (tmp < s->data[i][j]) ? pos : j;
-      tmp = (tmp < s->data[i][j]) ? tmp : s->data[i][j];
-    }
+  uint_t j, pos = 0.;
+  smpl_t tmp = s->data[0];
+  for (j = 0; j < s->length; j++) {
+    pos = (tmp < s->data[j]) ? pos : j;
+    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
   }
   return pos;
 }
@@ -207,13 +188,11 @@ fvec_min_elem (fvec_t * s)
 uint_t
 fvec_max_elem (fvec_t * s)
 {
-  uint_t i, j, pos = 0;
+  uint_t j, pos = 0;
   smpl_t tmp = 0.0;
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length; j++) {
-      pos = (tmp > s->data[i][j]) ? pos : j;
-      tmp = (tmp > s->data[i][j]) ? tmp : s->data[i][j];
-    }
+  for (j = 0; j < s->length; j++) {
+    pos = (tmp > s->data[j]) ? pos : j;
+    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
   }
   return pos;
 }
@@ -221,11 +200,9 @@ fvec_max_elem (fvec_t * s)
 void
 fvec_shift (fvec_t * s)
 {
-  uint_t i, j;
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length / 2; j++) {
-      ELEM_SWAP (s->data[i][j], s->data[i][j + s->length / 2]);
-    }
+  uint_t j;
+  for (j = 0; j < s->length / 2; j++) {
+    ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
   }
 }
 
@@ -233,11 +210,9 @@ smpl_t
 fvec_local_energy (fvec_t * f)
 {
   smpl_t energy = 0.;
-  uint_t i, j;
-  for (i = 0; i < f->channels; i++) {
-    for (j = 0; j < f->length; j++) {
-      energy += SQR (f->data[i][j]);
-    }
+  uint_t j;
+  for (j = 0; j < f->length; j++) {
+    energy += SQR (f->data[j]);
   }
   return energy;
 }
@@ -246,11 +221,9 @@ smpl_t
 fvec_local_hfc (fvec_t * v)
 {
   smpl_t hfc = 0.;
-  uint_t i, j;
-  for (i = 0; i < v->channels; i++) {
-    for (j = 0; j < v->length; j++) {
-      hfc += (i + 1) * v->data[i][j];
-    }
+  uint_t j;
+  for (j = 0; j < v->length; j++) {
+    hfc += (j + 1) * v->data[j];
   }
   return hfc;
 }
@@ -265,12 +238,10 @@ fvec_min_removal (fvec_t * v)
 smpl_t
 fvec_alpha_norm (fvec_t * o, smpl_t alpha)
 {
-  uint_t i, j;
+  uint_t j;
   smpl_t tmp = 0.;
-  for (i = 0; i < o->channels; i++) {
-    for (j = 0; j < o->length; j++) {
-      tmp += POW (ABS (o->data[i][j]), alpha);
-    }
+  for (j = 0; j < o->length; j++) {
+    tmp += POW (ABS (o->data[j]), alpha);
   }
   return POW (tmp / o->length, 1. / alpha);
 }
@@ -278,40 +249,36 @@ fvec_alpha_norm (fvec_t * o, smpl_t alpha)
 void
 fvec_alpha_normalise (fvec_t * o, smpl_t alpha)
 {
-  uint_t i, j;
+  uint_t j;
   smpl_t norm = fvec_alpha_norm (o, alpha);
-  for (i = 0; i < o->channels; i++) {
-    for (j = 0; j < o->length; j++) {
-      o->data[i][j] /= norm;
-    }
+  for (j = 0; j < o->length; j++) {
+    o->data[j] /= norm;
   }
 }
 
 void
 fvec_add (fvec_t * o, smpl_t val)
 {
-  uint_t i, j;
-  for (i = 0; i < o->channels; i++) {
-    for (j = 0; j < o->length; j++) {
-      o->data[i][j] += val;
-    }
+  uint_t j;
+  for (j = 0; j < o->length; j++) {
+    o->data[j] += val;
   }
 }
 
 void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp,
-    uint_t post, uint_t pre, uint_t channel) {
-  uint_t length = vec->length, i=channel, j;
+    uint_t post, uint_t pre) {
+  uint_t length = vec->length, j;
   for (j=0;j<length;j++) {
-    vec->data[i][j] -= fvec_moving_thres(vec, tmp, post, pre, j, i);
+    vec->data[j] -= fvec_moving_thres(vec, tmp, post, pre, j);
   }
 }
 
 smpl_t
 fvec_moving_thres (fvec_t * vec, fvec_t * tmpvec,
-    uint_t post, uint_t pre, uint_t pos, uint_t channel)
+    uint_t post, uint_t pre, uint_t pos)
 {
-  uint_t i = channel, k;
-  smpl_t *medar = (smpl_t *) tmpvec->data[i];
+  uint_t k;
+  smpl_t *medar = (smpl_t *) tmpvec->data;
   uint_t win_length = post + pre + 1;
   uint_t length = vec->length;
   /* post part of the buffer does not exist */
@@ -319,24 +286,24 @@ fvec_moving_thres (fvec_t * vec, fvec_t * tmpvec,
     for (k = 0; k < post + 1 - pos; k++)
       medar[k] = 0.;            /* 0-padding at the beginning */
     for (k = post + 1 - pos; k < win_length; k++)
-      medar[k] = vec->data[0][k + pos - post];
+      medar[k] = vec->data[k + pos - post];
     /* the buffer is fully defined */
   } else if (pos + pre < length) {
     for (k = 0; k < win_length; k++)
-      medar[k] = vec->data[0][k + pos - post];
+      medar[k] = vec->data[k + pos - post];
     /* pre part of the buffer does not exist */
   } else {
     for (k = 0; k < length - pos + post; k++)
-      medar[k] = vec->data[0][k + pos - post];
+      medar[k] = vec->data[k + pos - post];
     for (k = length - pos + post; k < win_length; k++)
       medar[k] = 0.;            /* 0-padding at the end */
   }
-  return fvec_median_channel (tmpvec, i);
+  return fvec_median (tmpvec);
 }
 
-smpl_t fvec_median_channel (fvec_t * input, uint_t channel) {
+smpl_t fvec_median (fvec_t * input) {
   uint_t n = input->length;
-  smpl_t * arr = (smpl_t *) input->data[channel];
+  smpl_t * arr = (smpl_t *) input->data;
   uint_t low, high ;
   uint_t median;
   uint_t middle, ll, hh;
@@ -385,24 +352,23 @@ smpl_t fvec_median_channel (fvec_t * input, uint_t channel) {
   }
 }
 
-smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t i) {
+smpl_t fvec_quadint (fvec_t * x, uint_t pos) {
   smpl_t s0, s1, s2;
   uint_t x0 = (pos < 1) ? pos : pos - 1;
   uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
-  if (x0 == pos) return (x->data[i][pos] <= x->data[i][x2]) ? pos : x2;
-  if (x2 == pos) return (x->data[i][pos] <= x->data[i][x0]) ? pos : x0;
-  s0 = x->data[i][x0];
-  s1 = x->data[i][pos];
-  s2 = x->data[i][x2];
+  if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
+  if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
+  s0 = x->data[x0];
+  s1 = x->data[pos];
+  s2 = x->data[x2];
   return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0);
 }
 
 uint_t fvec_peakpick(fvec_t * onset, uint_t pos) {
-  uint_t i=0, tmp=0;
-  /*for (i=0;i<onset->channels;i++)*/
-  tmp = (onset->data[i][pos] > onset->data[i][pos-1]
-      &&  onset->data[i][pos] > onset->data[i][pos+1]
-      &&  onset->data[i][pos] > 0.);
+  uint_t tmp=0;
+  tmp = (onset->data[pos] > onset->data[pos-1]
+      &&  onset->data[pos] > onset->data[pos+1]
+      &&  onset->data[pos] > 0.);
   return tmp;
 }
 
@@ -511,19 +477,19 @@ aubio_level_detection (fvec_t * o, smpl_t threshold)
 smpl_t
 aubio_zero_crossing_rate (fvec_t * input)
 {
-  uint_t i = 0, j;
+  uint_t j;
   uint_t zcr = 0;
   for (j = 1; j < input->length; j++) {
     // previous was strictly negative
-    if (input->data[i][j - 1] < 0.) {
+    if (input->data[j - 1] < 0.) {
       // current is positive or null
-      if (input->data[i][j] >= 0.) {
+      if (input->data[j] >= 0.) {
         zcr += 1;
       }
       // previous was positive or null
     } else {
       // current is strictly negative
-      if (input->data[i][j] < 0.) {
+      if (input->data[j] < 0.) {
         zcr += 1;
       }
     }
@@ -534,19 +500,17 @@ aubio_zero_crossing_rate (fvec_t * input)
 void
 aubio_autocorr (fvec_t * input, fvec_t * output)
 {
-  uint_t i, j, k, length = input->length;
+  uint_t i, j, length = input->length;
   smpl_t *data, *acf;
   smpl_t tmp = 0;
-  for (k = 0; k < input->channels; k++) {
-    data = input->data[k];
-    acf = output->data[k];
-    for (i = 0; i < length; i++) {
-      tmp = 0.;
-      for (j = i; j < length; j++) {
-        tmp += data[j - i] * data[j];
-      }
-      acf[i] = tmp / (smpl_t) (length - i);
+  data = input->data;
+  acf = output->data;
+  for (i = 0; i < length; i++) {
+    tmp = 0.;
+    for (j = i; j < length; j++) {
+      tmp += data[j - i] * data[j];
     }
+    acf[i] = tmp / (smpl_t) (length - i);
   }
 }
 
index 9c545e0..ebec009 100644 (file)
@@ -41,16 +41,6 @@ extern "C" {
 */
 smpl_t fvec_mean (fvec_t * s);
 
-/** compute the mean of a vector channel
-
-  \param s vector to compute mean from
-  \param i channel to compute mean from
-
-  \return the mean of v
-
-*/
-smpl_t fvec_mean_channel (fvec_t * s, uint_t i);
-
 /** find the max of a vector
 
   \param s vector to get the max from
@@ -204,7 +194,7 @@ pre elements after pos.
 
 */
 smpl_t fvec_moving_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre,
-    uint_t pos, uint_t channel);
+    uint_t pos);
 
 /** apply adaptive threshold to a vector
 
@@ -217,8 +207,7 @@ moving median threshold computed at p.
   \param pre length of anti-causal part to take after pos
 
 */
-void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre, 
-    uint_t channel);
+void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre);
 
 /** returns the median of a vector 
 
@@ -231,15 +220,14 @@ Devillard's implementation, available at http://ndevilla.free.fr/median/median/
 and in the Public Domain.
 
   \param v vector to get median from
-  \param channel channel to get median from
 
   \return the median of v
  
 */
-smpl_t fvec_median_channel (fvec_t * v, uint_t channel);
+smpl_t fvec_median (fvec_t * v);
 
 /** finds exact peak index by quadratic interpolation*/
-smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t channel);
+smpl_t fvec_quadint (fvec_t * x, uint_t pos);
 
 /** Quadratic interpolation using Lagrange polynomial.
  
index fee3374..b556345 100644 (file)
@@ -47,17 +47,11 @@ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset)
 {
   smpl_t isonset = 0;
   smpl_t wasonset = 0;
-  uint_t i;
   aubio_pvoc_do (o->pv,input, o->fftgrain);
   aubio_specdesc_do (o->od,o->fftgrain, o->of);
-  /*if (usedoubled) {
-    aubio_specdesc_do (o2,fftgrain, onset2);
-    onset->data[0][0] *= onset2->data[0][0];
-  }*/
   aubio_peakpicker_do(o->pp, o->of, onset);
-  for (i = 0; i < input->channels; i++) {
-  isonset = onset->data[i][0];
-  wasonset = o->wasonset->data[i][0];
+  isonset = onset->data[0];
+  wasonset = o->wasonset->data[0];
   if (isonset > 0.) {
     if (aubio_silence_detection(input, o->silence)==1) {
       isonset  = 0;
@@ -73,9 +67,8 @@ void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset)
   } else {
     wasonset++;
   }
-  o->wasonset->data[i][0] = wasonset;
-  onset->data[i][0] = isonset;
-  }
+  o->wasonset->data[0] = wasonset;
+  onset->data[0] = isonset;
   return;
 }
 
@@ -97,25 +90,25 @@ uint_t aubio_onset_set_minioi(aubio_onset_t * o, uint_t minioi) {
 
 /* Allocate memory for an onset detection */
 aubio_onset_t * new_aubio_onset (char_t * onset_mode, 
-    uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate)
+    uint_t buf_size, uint_t hop_size, uint_t samplerate)
 {
   aubio_onset_t * o = AUBIO_NEW(aubio_onset_t);
   /** set some default parameter */
   o->threshold = 0.3;
   o->minioi    = 4;
   o->silence   = -70;
-  o->wasonset  = new_fvec(1, channels);
+  o->wasonset  = new_fvec(1);
   o->samplerate = samplerate;
   o->hop_size = hop_size;
-  o->pv = new_aubio_pvoc(buf_size, hop_size, channels);
-  o->pp = new_aubio_peakpicker(channels);
+  o->pv = new_aubio_pvoc(buf_size, hop_size);
+  o->pp = new_aubio_peakpicker();
   aubio_peakpicker_set_threshold (o->pp, o->threshold);
-  o->od = new_aubio_specdesc(onset_mode,buf_size,channels);
-  o->fftgrain = new_cvec(buf_size,channels);
-  o->of = new_fvec(1, channels);
+  o->od = new_aubio_specdesc(onset_mode,buf_size);
+  o->fftgrain = new_cvec(buf_size);
+  o->of = new_fvec(1);
   /*if (usedoubled)    {
-    o2 = new_aubio_specdesc(onset_type2,buffer_size,channels);
-    onset2 = new_fvec(1 , channels);
+    o2 = new_aubio_specdesc(onset_type2,buffer_size);
+    onset2 = new_fvec(1);
   }*/
   return o;
 }
index 8c1d7f9..ffae869 100644 (file)
@@ -49,12 +49,11 @@ typedef struct _aubio_onset_t aubio_onset_t;
   \param method onset detection type as specified in specdesc.h
   \param buf_size buffer size for phase vocoder
   \param hop_size hop size for phase vocoder
-  \param channels number of channels 
   \param samplerate sampling rate of the input signal 
 
 */
 aubio_onset_t * new_aubio_onset (char_t * method, 
-    uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
+    uint_t buf_size, uint_t hop_size, uint_t samplerate);
 
 /** execute onset detection
 
index 71985de..010c9a6 100644 (file)
@@ -27,7 +27,7 @@
 #include "onset/peakpicker.h"
 
 /** function pointer to thresholding function */
-typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input, uint_t channel);
+typedef smpl_t (*aubio_thresholdfn_t)(fvec_t *input);
 /** function pointer to peak-picking function */
 typedef uint_t (*aubio_pickerfn_t)(fvec_t *input, uint_t pos);
 
@@ -68,9 +68,6 @@ struct _aubio_peakpicker_t
         /** scratch pad for biquad and median */
   fvec_t *scratch;
 
-  /** number of channels to analyse */
-  uint_t channels;
-
         /** \bug should be used to calculate filter coefficients */
   /* cutoff: low-pass filter cutoff [0.34, 1] */
   /* smpl_t cutoff; */
@@ -96,42 +93,38 @@ aubio_peakpicker_do (aubio_peakpicker_t * p, fvec_t * onset, fvec_t * out)
   fvec_t *scratch = p->scratch;
   smpl_t mean = 0., median = 0.;
   uint_t length = p->win_post + p->win_pre + 1;
-  uint_t i, j = 0;
-
-  for (i = 0; i < p->channels; i++) {
-    /* store onset in onset_keep */
-    /* shift all elements but last, then write last */
-    for (j = 0; j < length - 1; j++) {
-      onset_keep->data[i][j] = onset_keep->data[i][j + 1];
-      onset_proc->data[i][j] = onset_keep->data[i][j];
-    }
-    onset_keep->data[i][length - 1] = onset->data[i][0];
-    onset_proc->data[i][length - 1] = onset->data[i][0];
+  uint_t j = 0;
+
+  /* store onset in onset_keep */
+  /* shift all elements but last, then write last */
+  for (j = 0; j < length - 1; j++) {
+    onset_keep->data[j] = onset_keep->data[j + 1];
+    onset_proc->data[j] = onset_keep->data[j];
   }
+  onset_keep->data[length - 1] = onset->data[0];
+  onset_proc->data[length - 1] = onset->data[0];
 
   /* filter onset_proc */
   /** \bug filtfilt calculated post+pre times, should be only once !? */
   aubio_filter_do_filtfilt (p->biquad, onset_proc, scratch);
 
-  for (i = 0; i < p->channels; i++) {
-    /* calculate mean and median for onset_proc */
-    mean = fvec_mean_channel (onset_proc, i);
-    /* copy to scratch */
-    for (j = 0; j < length; j++)
-      scratch->data[i][j] = onset_proc->data[i][j];
-    median = p->thresholdfn (scratch, i);
-
-    /* shift peek array */
-    for (j = 0; j < 3 - 1; j++)
-      onset_peek->data[i][j] = onset_peek->data[i][j + 1];
-    /* calculate new tresholded value */
-    thresholded->data[i][0] =
-        onset_proc->data[i][p->win_post] - median - mean * p->threshold;
-    onset_peek->data[i][2] = thresholded->data[i][0];
-    out->data[i][0] = (p->pickerfn) (onset_peek, 1);
-    if (out->data[i][0]) {
-      out->data[i][0] = fvec_quadint (onset_peek, 1, i);
-    }
+  /* calculate mean and median for onset_proc */
+  mean = fvec_mean (onset_proc);
+  /* copy to scratch */
+  for (j = 0; j < length; j++)
+    scratch->data[j] = onset_proc->data[j];
+  median = p->thresholdfn (scratch);
+
+  /* shift peek array */
+  for (j = 0; j < 3 - 1; j++)
+    onset_peek->data[j] = onset_peek->data[j + 1];
+  /* calculate new tresholded value */
+  thresholded->data[0] =
+      onset_proc->data[p->win_post] - median - mean * p->threshold;
+  onset_peek->data[2] = thresholded->data[0];
+  out->data[0] = (p->pickerfn) (onset_peek, 1);
+  if (out->data[0]) {
+    out->data[0] = fvec_quadint (onset_peek, 1);
   }
 }
 
@@ -172,29 +165,27 @@ aubio_peakpicker_get_thresholdfn (aubio_peakpicker_t * p)
 }
 
 aubio_peakpicker_t *
-new_aubio_peakpicker (uint_t channels)
+new_aubio_peakpicker ()
 {
   aubio_peakpicker_t *t = AUBIO_NEW (aubio_peakpicker_t);
   t->threshold = 0.1;           /* 0.0668; 0.33; 0.082; 0.033; */
   t->win_post = 5;
   t->win_pre = 1;
-  //channels = 1;
-  t->channels = channels;
 
-  t->thresholdfn = (aubio_thresholdfn_t) (fvec_median_channel); /* (fvec_mean); */
+  t->thresholdfn = (aubio_thresholdfn_t) (fvec_median); /* (fvec_mean); */
   t->pickerfn = (aubio_pickerfn_t) (fvec_peakpick);
 
-  t->scratch = new_fvec (t->win_post + t->win_pre + 1, channels);
-  t->onset_keep = new_fvec (t->win_post + t->win_pre + 1, channels);
-  t->onset_proc = new_fvec (t->win_post + t->win_pre + 1, channels);
-  t->onset_peek = new_fvec (3, channels);
-  t->thresholded = new_fvec (1, channels);
+  t->scratch = new_fvec (t->win_post + t->win_pre + 1);
+  t->onset_keep = new_fvec (t->win_post + t->win_pre + 1);
+  t->onset_proc = new_fvec (t->win_post + t->win_pre + 1);
+  t->onset_peek = new_fvec (3);
+  t->thresholded = new_fvec (1);
 
   /* cutoff: low-pass filter with cutoff reduced frequency at 0.34
      generated with octave butter function: [b,a] = butter(2, 0.34);
    */
   t->biquad = new_aubio_filter_biquad (0.15998789, 0.31997577, 0.15998789,
-      -0.59488894, 0.23484048, channels);
+      -0.59488894, 0.23484048);
 
   return t;
 }
index 3f46ce7..74fdfff 100644 (file)
@@ -35,7 +35,7 @@ extern "C" {
 typedef struct _aubio_peakpicker_t aubio_peakpicker_t;
 
 /** peak-picker creation function */
-aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels);
+aubio_peakpicker_t * new_aubio_peakpicker(void);
 /** real time peak picking function */
 void aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * in, fvec_t * out);
 /** destroy peak picker structure */
index fd1944d..3861d05 100644 (file)
@@ -113,7 +113,7 @@ freqconvpass (smpl_t f, uint_t srate UNUSED, uint_t bufsize UNUSED)
 
 aubio_pitch_t *
 new_aubio_pitch (char_t * pitch_mode,
-    uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate)
+    uint_t bufsize, uint_t hopsize, uint_t samplerate)
 {
   aubio_pitch_t *p = AUBIO_NEW (aubio_pitch_t);
   aubio_pitch_type pitch_type;
@@ -141,30 +141,30 @@ new_aubio_pitch (char_t * pitch_mode,
   p->bufsize = bufsize;
   switch (p->type) {
     case aubio_pitcht_yin:
-      p->buf = new_fvec (bufsize, channels);
+      p->buf = new_fvec (bufsize);
       p->yin = new_aubio_pitchyin (bufsize);
       p->callback = aubio_pitch_do_yin;
       aubio_pitchyin_set_tolerance (p->yin, 0.15);
       break;
     case aubio_pitcht_mcomb:
-      p->pv = new_aubio_pvoc (bufsize, hopsize, channels);
-      p->fftgrain = new_cvec (bufsize, channels);
-      p->mcomb = new_aubio_pitchmcomb (bufsize, hopsize, channels);
-      p->filter = new_aubio_filter_c_weighting (samplerate, channels);
+      p->pv = new_aubio_pvoc (bufsize, hopsize);
+      p->fftgrain = new_cvec (bufsize);
+      p->mcomb = new_aubio_pitchmcomb (bufsize, hopsize);
+      p->filter = new_aubio_filter_c_weighting (samplerate);
       p->callback = aubio_pitch_do_mcomb;
       break;
     case aubio_pitcht_fcomb:
-      p->buf = new_fvec (bufsize, channels);
-      p->fcomb = new_aubio_pitchfcomb (bufsize, hopsize, channels);
+      p->buf = new_fvec (bufsize);
+      p->fcomb = new_aubio_pitchfcomb (bufsize, hopsize);
       p->callback = aubio_pitch_do_fcomb;
       break;
     case aubio_pitcht_schmitt:
-      p->buf = new_fvec (bufsize, channels);
+      p->buf = new_fvec (bufsize);
       p->schmitt = new_aubio_pitchschmitt (bufsize);
       p->callback = aubio_pitch_do_schmitt;
       break;
     case aubio_pitcht_yinfft:
-      p->buf = new_fvec (bufsize, channels);
+      p->buf = new_fvec (bufsize);
       p->yinfft = new_aubio_pitchyinfft (bufsize);
       p->callback = aubio_pitch_do_yinfft;
       aubio_pitchyinfft_set_tolerance (p->yinfft, 0.85);
@@ -210,17 +210,13 @@ del_aubio_pitch (aubio_pitch_t * p)
 void
 aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf)
 {
-  uint_t i, j = 0, overlap_size = 0;
+  uint_t j = 0, overlap_size = 0;
   overlap_size = p->buf->length - ibuf->length;
-  for (i = 0; i < p->buf->channels; i++) {
-    for (j = 0; j < overlap_size; j++) {
-      p->buf->data[i][j] = p->buf->data[i][j + ibuf->length];
-    }
+  for (j = 0; j < overlap_size; j++) {
+    p->buf->data[j] = p->buf->data[j + ibuf->length];
   }
-  for (i = 0; i < ibuf->channels; i++) {
-    for (j = 0; j < ibuf->length; j++) {
-      p->buf->data[i][j + overlap_size] = ibuf->data[i][j];
-    }
+  for (j = 0; j < ibuf->length; j++) {
+    p->buf->data[j + overlap_size] = ibuf->data[j];
   }
 }
 
@@ -282,41 +278,32 @@ aubio_pitch_set_tolerance (aubio_pitch_t * p, smpl_t tol)
 void
 aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)
 {
-  uint_t i;
   p->callback (p, ibuf, obuf);
-  for (i = 0; i < obuf->channels; i++) {
-    p->freqconv (obuf->data[i][0], p->srate, p->bufsize);
-  }
+  obuf->data[0] = p->freqconv (obuf->data[0], p->srate, p->bufsize);
 }
 
 void
 aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)
 {
-  uint_t i;
   aubio_filter_do (p->filter, ibuf);
   aubio_pvoc_do (p->pv, ibuf, p->fftgrain);
   aubio_pitchmcomb_do (p->mcomb, p->fftgrain, obuf);
-  for (i = 0; i < obuf->channels; i++) {
-    obuf->data[i][0] = aubio_bintofreq (obuf->data[i][0], p->srate, p->bufsize);
-  }
+  obuf->data[0] = aubio_bintofreq (obuf->data[0], p->srate, p->bufsize);
 }
 
 void
 aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)
 {
   smpl_t pitch = 0.;
-  uint_t i;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchyin_do (p->yin, p->buf, obuf);
-  for (i = 0; i < obuf->channels; i++) {
-    pitch = obuf->data[i][0];
-    if (pitch > 0) {
-      pitch = p->srate / (pitch + 0.);
-    } else {
-      pitch = 0.;
-    }
-    obuf->data[i][0] = pitch;
+  pitch = obuf->data[0];
+  if (pitch > 0) {
+    pitch = p->srate / (pitch + 0.);
+  } else {
+    pitch = 0.;
   }
+  obuf->data[0] = pitch;
 }
 
 
@@ -324,45 +311,36 @@ void
 aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)
 {
   smpl_t pitch = 0.;
-  uint_t i;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchyinfft_do (p->yinfft, p->buf, obuf);
-  for (i = 0; i < obuf->channels; i++) {
-    pitch = obuf->data[i][0];
-    if (pitch > 0) {
-      pitch = p->srate / (pitch + 0.);
-    } else {
-      pitch = 0.;
-    }
-    obuf->data[i][0] = pitch;
+  pitch = obuf->data[0];
+  if (pitch > 0) {
+    pitch = p->srate / (pitch + 0.);
+  } else {
+    pitch = 0.;
   }
+  obuf->data[0] = pitch;
 }
 
 void
 aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)
 {
-  uint_t i;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchfcomb_do (p->fcomb, p->buf, out);
-  for (i = 0; i < out->channels; i++) {
-    out->data[i][0] = aubio_bintofreq (out->data[i][0], p->srate, p->bufsize);
-  }
+  out->data[0] = aubio_bintofreq (out->data[0], p->srate, p->bufsize);
 }
 
 void
 aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)
 {
   smpl_t period, pitch = 0.;
-  uint_t i;
   aubio_pitch_slideblock (p, ibuf);
   aubio_pitchschmitt_do (p->schmitt, p->buf, out);
-  for (i = 0; i < out->channels; i++) {
-    period = out->data[i][0];
-    if (period > 0) {
-      pitch = p->srate / period;
-    } else {
-      pitch = 0.;
-    }
-    out->data[i][0] = pitch;
+  period = out->data[0];
+  if (period > 0) {
+    pitch = p->srate / period;
+  } else {
+    pitch = 0.;
   }
+  out->data[0] = pitch;
 }
index 8427050..b00c45a 100644 (file)
@@ -40,8 +40,8 @@ typedef struct _aubio_pitch_t aubio_pitch_t;
 /** execute pitch detection on an input signal frame
 
   \param o pitch detection object as returned by new_aubio_pitch()
-  \param in input signal of size [hop_size x channels]
-  \param out output pitch candidates of size [1 x channels]
+  \param in input signal of size [hop_size]
+  \param out output pitch candidates of size [1]
 
 */
 void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, fvec_t * out);
@@ -66,12 +66,11 @@ void del_aubio_pitch (aubio_pitch_t * o);
   \param method set pitch detection algorithm
   \param buf_size size of the input buffer to analyse
   \param hop_size step size between two consecutive analysis instant
-  \param channels number of channels to analyse
   \param samplerate sampling rate of the signal
 
 */
 aubio_pitch_t *new_aubio_pitch (char_t * method,
-    uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
+    uint_t buf_size, uint_t hop_size, uint_t samplerate);
 
 /** set the output unit of the pitch detection object 
 
index 2cf2758..83bc6b1 100644 (file)
@@ -48,15 +48,15 @@ struct _aubio_pitchfcomb_t
 };
 
 aubio_pitchfcomb_t *
-new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t channels)
+new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize)
 {
   aubio_pitchfcomb_t *p = AUBIO_NEW (aubio_pitchfcomb_t);
   p->fftSize = bufsize;
   p->stepSize = hopsize;
-  p->winput = new_fvec (bufsize, 1);
-  p->fftOut = new_cvec (bufsize, 1);
-  p->fftLastPhase = new_fvec (bufsize, channels);
-  p->fft = new_aubio_fft (bufsize, 1);
+  p->winput = new_fvec (bufsize);
+  p->fftOut = new_cvec (bufsize);
+  p->fftLastPhase = new_fvec (bufsize);
+  p->fft = new_aubio_fft (bufsize);
   p->win = new_aubio_window ("hanning", bufsize);
   return p;
 }
@@ -65,69 +65,66 @@ new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t channels)
 void
 aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, fvec_t * output)
 {
-  uint_t i, k, l, maxharm = 0;
+  uint_t k, l, maxharm = 0;
   smpl_t phaseDifference = TWO_PI * (smpl_t) p->stepSize / (smpl_t) p->fftSize;
   aubio_fpeak_t peaks[MAX_PEAKS];
 
-  for (i = 0; i < input->channels; i++) {
-
-    for (k = 0; k < MAX_PEAKS; k++) {
-      peaks[k].db = -200.;
-      peaks[k].bin = 0.;
-    }
+  for (k = 0; k < MAX_PEAKS; k++) {
+    peaks[k].db = -200.;
+    peaks[k].bin = 0.;
+  }
 
-    for (k = 0; k < input->length; k++) {
-      p->winput->data[0][k] = p->win->data[0][k] * input->data[i][k];
-    }
-    aubio_fft_do (p->fft, p->winput, p->fftOut);
+  for (k = 0; k < input->length; k++) {
+    p->winput->data[k] = p->win->data[k] * input->data[k];
+  }
+  aubio_fft_do (p->fft, p->winput, p->fftOut);
 
-    for (k = 0; k <= p->fftSize / 2; k++) {
-      smpl_t
-          magnitude =
-          20. * LOG10 (2. * p->fftOut->norm[0][k] / (smpl_t) p->fftSize),
-          phase = p->fftOut->phas[0][k], tmp, bin;
+  for (k = 0; k <= p->fftSize / 2; k++) {
+    smpl_t
+        magnitude =
+        20. * LOG10 (2. * p->fftOut->norm[k] / (smpl_t) p->fftSize),
+        phase = p->fftOut->phas[k], tmp, bin;
 
-      /* compute phase difference */
-      tmp = phase - p->fftLastPhase->data[i][k];
-      p->fftLastPhase->data[i][k] = phase;
+    /* compute phase difference */
+    tmp = phase - p->fftLastPhase->data[k];
+    p->fftLastPhase->data[k] = phase;
 
-      /* subtract expected phase difference */
-      tmp -= (smpl_t) k *phaseDifference;
+    /* subtract expected phase difference */
+    tmp -= (smpl_t) k *phaseDifference;
 
-      /* map delta phase into +/- Pi interval */
-      tmp = aubio_unwrap2pi (tmp);
+    /* map delta phase into +/- Pi interval */
+    tmp = aubio_unwrap2pi (tmp);
 
-      /* get deviation from bin frequency from the +/- Pi interval */
-      tmp = p->fftSize / (smpl_t) p->stepSize * tmp / (TWO_PI);
+    /* get deviation from bin frequency from the +/- Pi interval */
+    tmp = p->fftSize / (smpl_t) p->stepSize * tmp / (TWO_PI);
 
-      /* compute the k-th partials' true bin */
-      bin = (smpl_t) k + tmp;
+    /* compute the k-th partials' true bin */
+    bin = (smpl_t) k + tmp;
 
-      if (bin > 0.0 && magnitude > peaks[0].db) {       // && magnitude < 0) {
-        memmove (peaks + 1, peaks, sizeof (aubio_fpeak_t) * (MAX_PEAKS - 1));
-        peaks[0].bin = bin;
-        peaks[0].db = magnitude;
-      }
+    if (bin > 0.0 && magnitude > peaks[0].db) {       // && magnitude < 0) {
+      memmove (peaks + 1, peaks, sizeof (aubio_fpeak_t) * (MAX_PEAKS - 1));
+      peaks[0].bin = bin;
+      peaks[0].db = magnitude;
     }
+  }
 
-    k = 0;
-    for (l = 1; l < MAX_PEAKS && peaks[l].bin > 0.0; l++) {
-      sint_t harmonic;
-      for (harmonic = 5; harmonic > 1; harmonic--) {
-        if (peaks[0].bin / peaks[l].bin < harmonic + .02 &&
-            peaks[0].bin / peaks[l].bin > harmonic - .02) {
-          if (harmonic > (sint_t) maxharm && peaks[0].db < peaks[l].db / 2) {
-            maxharm = harmonic;
-            k = l;
-          }
+  k = 0;
+  for (l = 1; l < MAX_PEAKS && peaks[l].bin > 0.0; l++) {
+    sint_t harmonic;
+    for (harmonic = 5; harmonic > 1; harmonic--) {
+      if (peaks[0].bin / peaks[l].bin < harmonic + .02 &&
+          peaks[0].bin / peaks[l].bin > harmonic - .02) {
+        if (harmonic > (sint_t) maxharm && peaks[0].db < peaks[l].db / 2) {
+          maxharm = harmonic;
+          k = l;
         }
       }
     }
-    output->data[i][0] = peaks[k].bin;
-    /* quick hack to clean output a bit */
-    if (peaks[k].bin > 5000.)
-      output->data[i][0] = 0.;
   }
+  output->data[0] = peaks[k].bin;
+  /* quick hack to clean output a bit */
+  if (peaks[k].bin > 5000.)
+    output->data[0] = 0.;
 }
 
 void
index 9880c90..14c27c9 100644 (file)
@@ -56,11 +56,9 @@ void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input,
  
   \param buf_size size of the input buffer to analyse 
   \param hop_size step size between two consecutive analysis instant 
-  \param channels number of channels to detect pitch on
  
 */
-aubio_pitchfcomb_t *new_aubio_pitchfcomb (uint_t buf_size, uint_t hop_size,
-    uint_t channels);
+aubio_pitchfcomb_t *new_aubio_pitchfcomb (uint_t buf_size, uint_t hop_size);
 
 /** deletion of the pitch detection object
  
index d49625f..892ad3f 100644 (file)
@@ -103,42 +103,40 @@ struct _aubio_spectralcandidate_t
 void
 aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output)
 {
-  uint_t i, j;
+  uint_t j;
   smpl_t instfreq;
   fvec_t *newmag = (fvec_t *) p->newmag;
   //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta;
   /* copy incoming grain to newmag */
-  for (i = 0; i < fftgrain->channels; i++) {
-    for (j = 0; j < newmag->length; j++)
-      newmag->data[0][j] = fftgrain->norm[i][j];
-    /* detect only if local energy > 10. */
-    //if (fvec_local_energy(newmag)>10.) {
-    //hfc = fvec_local_hfc(newmag); //not used
-    aubio_pitchmcomb_spectral_pp (p, newmag);
-    aubio_pitchmcomb_combdet (p, newmag);
-    //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand);
-    //return p->candidates[p->goodcandidate]->ebin;
-    j = (uint_t) FLOOR (p->candidates[p->goodcandidate]->ebin + .5);
-    instfreq = aubio_unwrap2pi (fftgrain->phas[i][j]
-        - p->theta->data[i][j] - j * p->phasediff);
-    instfreq *= p->phasefreq;
-    /* store phase for next run */
-    for (j = 0; j < p->theta->length; j++) {
-      p->theta->data[i][j] = fftgrain->phas[i][j];
-    }
-    //return p->candidates[p->goodcandidate]->ebin;
-    output->data[i][0] =
-        FLOOR (p->candidates[p->goodcandidate]->ebin + .5) + instfreq;
-    /*} else {
-       return -1.;
-       } */
+  for (j = 0; j < newmag->length; j++)
+    newmag->data[j] = fftgrain->norm[j];
+  /* detect only if local energy > 10. */
+  //if (fvec_local_energy(newmag)>10.) {
+  //hfc = fvec_local_hfc(newmag); //not used
+  aubio_pitchmcomb_spectral_pp (p, newmag);
+  aubio_pitchmcomb_combdet (p, newmag);
+  //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand);
+  //return p->candidates[p->goodcandidate]->ebin;
+  j = (uint_t) FLOOR (p->candidates[p->goodcandidate]->ebin + .5);
+  instfreq = aubio_unwrap2pi (fftgrain->phas[j]
+      - p->theta->data[j] - j * p->phasediff);
+  instfreq *= p->phasefreq;
+  /* store phase for next run */
+  for (j = 0; j < p->theta->length; j++) {
+    p->theta->data[j] = fftgrain->phas[j];
   }
+  //return p->candidates[p->goodcandidate]->ebin;
+  output->data[0] =
+      FLOOR (p->candidates[p->goodcandidate]->ebin + .5) + instfreq;
+  /*} else {
+     return -1.;
+     } */
 }
 
 uint_t
 aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands)
 {
-  uint_t i = 0, j;
+  uint_t j;
   uint_t k;
   fvec_t *newmag = (fvec_t *) p->newmag;
   aubio_spectralcandidate_t **scands =
@@ -146,7 +144,7 @@ aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands)
   //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta;
   /* copy incoming grain to newmag */
   for (j = 0; j < newmag->length; j++)
-    newmag->data[i][j] = fftgrain->norm[i][j];
+    newmag->data[j] = fftgrain->norm[j];
   /* detect only if local energy > 10. */
   if (fvec_local_energy (newmag) > 10.) {
     /* hfc = fvec_local_hfc(newmag); do not use */
@@ -171,17 +169,17 @@ aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag)
 {
   fvec_t *mag = (fvec_t *) p->scratch;
   fvec_t *tmp = (fvec_t *) p->scratch2;
-  uint_t i = 0, j;
+  uint_t j;
   uint_t length = mag->length;
   /* copy newmag to mag (scracth) */
   for (j = 0; j < length; j++) {
-    mag->data[i][j] = newmag->data[i][j];
+    mag->data[j] = newmag->data[j];
   }
   fvec_min_removal (mag);       /* min removal          */
   fvec_alpha_normalise (mag, p->alpha); /* alpha normalisation  */
   /* skipped *//* low pass filtering   */
   /** \bug fvec_moving_thres may write out of bounds */
-  fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre, i);      /* adaptative threshold */
+  fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre);      /* adaptative threshold */
   fvec_add (mag, -p->threshold);        /* fixed threshold      */
   {
     aubio_spectralpeak_t *peaks = (aubio_spectralpeak_t *) p->peaks;
@@ -189,7 +187,7 @@ aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag)
     /*  return bin and ebin */
     count = aubio_pitchmcomb_quadpick (peaks, mag);
     for (j = 0; j < count; j++)
-      peaks[j].mag = newmag->data[i][peaks[j].bin];
+      peaks[j].mag = newmag->data[peaks[j].bin];
     /* reset non peaks */
     for (j = count; j < length; j++)
       peaks[j].mag = 0.;
@@ -260,7 +258,7 @@ aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag)
       if (17. * xx < candidate[l]->ecomb[k]) {
         candidate[l]->ecomb[k] = peaks[position].ebin;
         candidate[l]->ene +=    /* ecomb rounded to nearest int */
-            POW (newmag->data[0][(uint_t) FLOOR (candidate[l]->ecomb[k] + .5)],
+            POW (newmag->data[(uint_t) FLOOR (candidate[l]->ecomb[k] + .5)],
             0.25);
         candidate[l]->len += 1. / curlen;
       } else
@@ -289,16 +287,15 @@ aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag)
 uint_t
 aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, fvec_t * X)
 {
-  uint_t i, j, ispeak, count = 0;
-  for (i = 0; i < X->channels; i++)
-    for (j = 1; j < X->length - 1; j++) {
-      ispeak = fvec_peakpick (X, j);
-      if (ispeak) {
-        count += ispeak;
-        spectral_peaks[count - 1].bin = j;
-        spectral_peaks[count - 1].ebin = fvec_quadint (X, j, i) - 1.;
-      }
+  uint_t j, ispeak, count = 0;
+  for (j = 1; j < X->length - 1; j++) {
+    ispeak = fvec_peakpick (X, j);
+    if (ispeak) {
+      count += ispeak;
+      spectral_peaks[count - 1].bin = j;
+      spectral_peaks[count - 1].ebin = fvec_quadint (X, j) - 1.;
     }
+  }
   return count;
 }
 
@@ -363,7 +360,7 @@ aubio_pitchmcomb_sort_cand_freq (aubio_spectralcandidate_t ** candidates,
 }
 
 aubio_pitchmcomb_t *
-new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize, uint_t channels)
+new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize)
 {
   aubio_pitchmcomb_t *p = AUBIO_NEW (aubio_pitchmcomb_t);
   /* bug: should check if size / 8 > post+pre+1 */
@@ -385,13 +382,13 @@ new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize, uint_t channels)
   //p->pickerfn = quadpick;
   //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348);
   /* allocate temp memory */
-  p->newmag = new_fvec (spec_size, 1);
+  p->newmag = new_fvec (spec_size);
   /* array for median */
-  p->scratch = new_fvec (spec_size, 1);
+  p->scratch = new_fvec (spec_size);
   /* array for phase */
-  p->theta = new_fvec (spec_size, channels);
+  p->theta = new_fvec (spec_size);
   /* array for adaptative threshold */
-  p->scratch2 = new_fvec (p->win_post + p->win_pre + 1, 1);
+  p->scratch2 = new_fvec (p->win_post + p->win_pre + 1);
   /* array of spectral peaks */
   p->peaks = AUBIO_ARRAY (aubio_spectralpeak_t, spec_size);
   for (i = 0; i < spec_size; i++) {
index c17b0b0..a183f16 100644 (file)
@@ -56,12 +56,10 @@ void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain,
  
   \param buf_size size of the input buffer to analyse 
   \param hop_size step size between two consecutive analysis instant 
-  \param channels number of channels to analyse
   \param samplerate sampling rate of the signal 
  
 */
-aubio_pitchmcomb_t *new_aubio_pitchmcomb (uint_t buf_size, uint_t hop_size,
-    uint_t channels);
+aubio_pitchmcomb_t *new_aubio_pitchmcomb (uint_t buf_size, uint_t hop_size);
 
 /** deletion of the pitch detection object
  
index 4aed314..f061cc8 100644 (file)
@@ -50,13 +50,11 @@ void
 aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * input,
     fvec_t * output)
 {
-  uint_t i, j;
-  for (i = 0; i < input->channels; i++) {
-    for (j = 0; j < input->length; j++) {
-      p->buf[j] = input->data[i][j] * 32768.;
-    }
-    output->data[i][0] = aubio_schmittS16LE (p, input->length, p->buf);
+  uint_t j;
+  for (j = 0; j < input->length; j++) {
+    p->buf[j] = input->data[j] * 32768.;
   }
+  output->data[0] = aubio_schmittS16LE (p, input->length, p->buf);
 }
 
 smpl_t
index 73907a9..1d309fa 100644 (file)
@@ -64,7 +64,7 @@ aubio_pitchyin_t *
 new_aubio_pitchyin (uint_t bufsize)
 {
   aubio_pitchyin_t *o = AUBIO_NEW (aubio_pitchyin_t);
-  o->yin = new_fvec (bufsize / 2, 1);
+  o->yin = new_fvec (bufsize / 2);
   o->tol = 0.15;
   return o;
 }
@@ -80,17 +80,15 @@ del_aubio_pitchyin (aubio_pitchyin_t * o)
 void
 aubio_pitchyin_diff (fvec_t * input, fvec_t * yin)
 {
-  uint_t c, j, tau;
+  uint_t j, tau;
   smpl_t tmp;
-  for (c = 0; c < input->channels; c++) {
-    for (tau = 0; tau < yin->length; tau++) {
-      yin->data[c][tau] = 0.;
-    }
-    for (tau = 1; tau < yin->length; tau++) {
-      for (j = 0; j < yin->length; j++) {
-        tmp = input->data[c][j] - input->data[c][j + tau];
-        yin->data[c][tau] += SQR (tmp);
-      }
+  for (tau = 0; tau < yin->length; tau++) {
+    yin->data[tau] = 0.;
+  }
+  for (tau = 1; tau < yin->length; tau++) {
+    for (j = 0; j < yin->length; j++) {
+      tmp = input->data[j] - input->data[j + tau];
+      yin->data[tau] += SQR (tmp);
     }
   }
 }
@@ -99,28 +97,26 @@ aubio_pitchyin_diff (fvec_t * input, fvec_t * yin)
 void
 aubio_pitchyin_getcum (fvec_t * yin)
 {
-  uint_t c, tau;
+  uint_t tau;
   smpl_t tmp;
-  for (c = 0; c < yin->channels; c++) {
-    tmp = 0.;
-    yin->data[c][0] = 1.;
-    //AUBIO_DBG("%f\t",yin->data[c][0]);
-    for (tau = 1; tau < yin->length; tau++) {
-      tmp += yin->data[c][tau];
-      yin->data[c][tau] *= tau / tmp;
-      //AUBIO_DBG("%f\t",yin->data[c][tau]);
-    }
-    //AUBIO_DBG("\n");
+  tmp = 0.;
+  yin->data[0] = 1.;
+  //AUBIO_DBG("%f\t",yin->data[0]);
+  for (tau = 1; tau < yin->length; tau++) {
+    tmp += yin->data[tau];
+    yin->data[tau] *= tau / tmp;
+    //AUBIO_DBG("%f\t",yin->data[tau]);
   }
+  //AUBIO_DBG("\n");
 }
 
 uint_t
 aubio_pitchyin_getpitch (fvec_t * yin)
 {
-  uint_t c = 0, tau = 1;
+  uint_t tau = 1;
   do {
-    if (yin->data[c][tau] < 0.1) {
-      while (yin->data[c][tau + 1] < yin->data[c][tau]) {
+    if (yin->data[tau] < 0.1) {
+      while (yin->data[tau + 1] < yin->data[tau]) {
         tau++;
       }
       return tau;
@@ -138,31 +134,28 @@ aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * input, fvec_t * out)
 {
   smpl_t tol = o->tol;
   fvec_t *yin = o->yin;
-  uint_t c, j, tau = 0;
+  uint_t j, tau = 0;
   sint_t period;
   smpl_t tmp = 0., tmp2 = 0.;
-  for (c = 0; c < input->channels; c++) {
-    yin->data[c][0] = 1.;
-    for (tau = 1; tau < yin->length; tau++) {
-      yin->data[c][tau] = 0.;
-      for (j = 0; j < yin->length; j++) {
-        tmp = input->data[c][j] - input->data[c][j + tau];
-        yin->data[c][tau] += SQR (tmp);
-      }
-      tmp2 += yin->data[c][tau];
-      yin->data[c][tau] *= tau / tmp2;
-      period = tau - 3;
-      if (tau > 4 && (yin->data[c][period] < tol) &&
-          (yin->data[c][period] < yin->data[c][period + 1])) {
-        out->data[c][0] = fvec_quadint (yin, period, c);
-        goto beach;
-      }
+  yin->data[0] = 1.;
+  for (tau = 1; tau < yin->length; tau++) {
+    yin->data[tau] = 0.;
+    for (j = 0; j < yin->length; j++) {
+      tmp = input->data[j] - input->data[j + tau];
+      yin->data[tau] += SQR (tmp);
+    }
+    tmp2 += yin->data[tau];
+    yin->data[tau] *= tau / tmp2;
+    period = tau - 3;
+    if (tau > 4 && (yin->data[period] < tol) &&
+        (yin->data[period] < yin->data[period + 1])) {
+      out->data[0] = fvec_quadint (yin, period);
+      goto beach;
     }
-    out->data[c][0] = fvec_quadint (yin, fvec_min_elem (yin), c);
-  beach:
-    continue;
   }
-  //return 0;
+  out->data[0] = fvec_quadint (yin, fvec_min_elem (yin));
+beach:
+  return;
 }
 
 uint_t
index 0111f31..e8c2757 100644 (file)
@@ -55,42 +55,40 @@ aubio_pitchyinfft_t *
 new_aubio_pitchyinfft (uint_t bufsize)
 {
   aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t);
-  p->winput = new_fvec (bufsize, 1);
-  p->fft = new_aubio_fft (bufsize, 1);
-  p->fftout = new_cvec (bufsize, 1);
-  p->sqrmag = new_fvec (bufsize, 1);
-  p->res = new_cvec (bufsize, 1);
-  p->yinfft = new_fvec (bufsize / 2 + 1, 1);
+  p->winput = new_fvec (bufsize);
+  p->fft = new_aubio_fft (bufsize);
+  p->fftout = new_cvec (bufsize);
+  p->sqrmag = new_fvec (bufsize);
+  p->res = new_cvec (bufsize);
+  p->yinfft = new_fvec (bufsize / 2 + 1);
   p->tol = 0.85;
   p->win = new_aubio_window ("hanningz", bufsize);
-  p->weight = new_fvec (bufsize / 2 + 1, 1);
-  {
-    uint_t i = 0, j = 1;
-    smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
-    for (i = 0; i < p->weight->length; i++) {
-      freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) 44100.;
-      while (freq > freqs[j]) {
-        j += 1;
-      }
-      a0 = weight[j - 1];
-      f0 = freqs[j - 1];
-      a1 = weight[j];
-      f1 = freqs[j];
-      if (f0 == f1) {           // just in case
-        p->weight->data[0][i] = a0;
-      } else if (f0 == 0) {     // y = ax+b
-        p->weight->data[0][i] = (a1 - a0) / f1 * freq + a0;
-      } else {
-        p->weight->data[0][i] = (a1 - a0) / (f1 - f0) * freq +
-            (a0 - (a1 - a0) / (f1 / f0 - 1.));
-      }
-      while (freq > freqs[j]) {
-        j += 1;
-      }
-      //AUBIO_DBG("%f\n",p->weight->data[0][i]);
-      p->weight->data[0][i] = DB2LIN (p->weight->data[0][i]);
-      //p->weight->data[0][i] = SQRT(DB2LIN(p->weight->data[0][i]));
+  p->weight = new_fvec (bufsize / 2 + 1);
+  uint_t i = 0, j = 1;
+  smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
+  for (i = 0; i < p->weight->length; i++) {
+    freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) 44100.;
+    while (freq > freqs[j]) {
+      j += 1;
     }
+    a0 = weight[j - 1];
+    f0 = freqs[j - 1];
+    a1 = weight[j];
+    f1 = freqs[j];
+    if (f0 == f1) {           // just in case
+      p->weight->data[i] = a0;
+    } else if (f0 == 0) {     // y = ax+b
+      p->weight->data[i] = (a1 - a0) / f1 * freq + a0;
+    } else {
+      p->weight->data[i] = (a1 - a0) / (f1 - f0) * freq +
+          (a0 - (a1 - a0) / (f1 / f0 - 1.));
+    }
+    while (freq > freqs[j]) {
+      j += 1;
+    }
+    //AUBIO_DBG("%f\n",p->weight->data[i]);
+    p->weight->data[i] = DB2LIN (p->weight->data[i]);
+    //p->weight->data[i] = SQRT(DB2LIN(p->weight->data[i]));
   }
   return p;
 }
@@ -98,60 +96,58 @@ new_aubio_pitchyinfft (uint_t bufsize)
 void
 aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output)
 {
-  uint_t i, tau, l;
+  uint_t tau, l;
   uint_t halfperiod;
   smpl_t tmp, sum;
   cvec_t *res = (cvec_t *) p->res;
   fvec_t *yin = (fvec_t *) p->yinfft;
-  for (i = 0; i < input->channels; i++) {
-    l = 0;
-    tmp = 0.;
-    sum = 0.;
-    for (l = 0; l < input->length; l++) {
-      p->winput->data[0][l] = p->win->data[0][l] * input->data[i][l];
-    }
-    aubio_fft_do (p->fft, p->winput, p->fftout);
-    for (l = 0; l < p->fftout->length; l++) {
-      p->sqrmag->data[0][l] = SQR (p->fftout->norm[0][l]);
-      p->sqrmag->data[0][l] *= p->weight->data[0][l];
-    }
-    for (l = 1; l < p->fftout->length; l++) {
-      p->sqrmag->data[0][(p->fftout->length - 1) * 2 - l] =
-          SQR (p->fftout->norm[0][l]);
-      p->sqrmag->data[0][(p->fftout->length - 1) * 2 - l] *=
-          p->weight->data[0][l];
-    }
-    for (l = 0; l < p->sqrmag->length / 2 + 1; l++) {
-      sum += p->sqrmag->data[0][l];
-    }
-    sum *= 2.;
-    aubio_fft_do (p->fft, p->sqrmag, res);
-    yin->data[0][0] = 1.;
-    for (tau = 1; tau < yin->length; tau++) {
-      yin->data[0][tau] = sum - res->norm[0][tau] * COS (res->phas[0][tau]);
-      tmp += yin->data[0][tau];
-      yin->data[0][tau] *= tau / tmp;
-    }
-    tau = fvec_min_elem (yin);
-    if (yin->data[0][tau] < p->tol) {
-      /* no interpolation */
-      //return tau;
-      /* 3 point quadratic interpolation */
-      //return fvec_quadint_min(yin,tau,1);
-      /* additional check for (unlikely) octave doubling in higher frequencies */
-      if (tau > 35) {
-        output->data[i][0] = fvec_quadint (yin, tau, i);
-      } else {
-        /* should compare the minimum value of each interpolated peaks */
-        halfperiod = FLOOR (tau / 2 + .5);
-        if (yin->data[0][halfperiod] < p->tol)
-          output->data[i][0] = fvec_quadint (yin, halfperiod, i);
-        else
-          output->data[i][0] = fvec_quadint (yin, tau, i);
-      }
+  l = 0;
+  tmp = 0.;
+  sum = 0.;
+  for (l = 0; l < input->length; l++) {
+    p->winput->data[l] = p->win->data[l] * input->data[l];
+  }
+  aubio_fft_do (p->fft, p->winput, p->fftout);
+  for (l = 0; l < p->fftout->length; l++) {
+    p->sqrmag->data[l] = SQR (p->fftout->norm[l]);
+    p->sqrmag->data[l] *= p->weight->data[l];
+  }
+  for (l = 1; l < p->fftout->length; l++) {
+    p->sqrmag->data[(p->fftout->length - 1) * 2 - l] =
+        SQR (p->fftout->norm[l]);
+    p->sqrmag->data[(p->fftout->length - 1) * 2 - l] *=
+        p->weight->data[l];
+  }
+  for (l = 0; l < p->sqrmag->length / 2 + 1; l++) {
+    sum += p->sqrmag->data[l];
+  }
+  sum *= 2.;
+  aubio_fft_do (p->fft, p->sqrmag, res);
+  yin->data[0] = 1.;
+  for (tau = 1; tau < yin->length; tau++) {
+    yin->data[tau] = sum - res->norm[tau] * COS (res->phas[tau]);
+    tmp += yin->data[tau];
+    yin->data[tau] *= tau / tmp;
+  }
+  tau = fvec_min_elem (yin);
+  if (yin->data[tau] < p->tol) {
+    /* no interpolation */
+    //return tau;
+    /* 3 point quadratic interpolation */
+    //return fvec_quadint_min(yin,tau,1);
+    /* additional check for (unlikely) octave doubling in higher frequencies */
+    if (tau > 35) {
+      output->data[0] = fvec_quadint (yin, tau);
     } else {
-      output->data[i][0] = 0.;
+      /* should compare the minimum value of each interpolated peaks */
+      halfperiod = FLOOR (tau / 2 + .5);
+      if (yin->data[halfperiod] < p->tol)
+        output->data[0] = fvec_quadint (yin, halfperiod);
+      else
+        output->data[0] = fvec_quadint (yin, tau);
     }
+  } else {
+    output->data[0] = 0.;
   }
 }
 
index f718dca..a4cab25 100644 (file)
@@ -74,7 +74,6 @@ typedef FFTW_TYPE fft_data_t;
 
 struct _aubio_fft_t {
   uint_t winsize;
-  uint_t channels;
   uint_t fft_size;
   real_t *in, *out;
   fftw_plan pfw, pbw;
@@ -82,15 +81,14 @@ struct _aubio_fft_t {
   fvec_t * compspec;
 };
 
-aubio_fft_t * new_aubio_fft(uint_t winsize, uint_t channels) {
+aubio_fft_t * new_aubio_fft(uint_t winsize) {
   aubio_fft_t * s = AUBIO_NEW(aubio_fft_t);
   uint_t i;
   s->winsize  = winsize;
-  s->channels = channels;
   /* allocate memory */
   s->in       = AUBIO_ARRAY(real_t,winsize);
   s->out      = AUBIO_ARRAY(real_t,winsize);
-  s->compspec = new_fvec(winsize,channels);
+  s->compspec = new_fvec(winsize);
   /* create plans */
 #ifdef HAVE_COMPLEX_H
   s->fft_size = winsize/2 + 1;
@@ -135,47 +133,43 @@ void aubio_fft_rdo(aubio_fft_t * s, cvec_t * spectrum, fvec_t * output) {
 }
 
 void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) {
-  uint_t i, j;
-  for (i = 0; i < s->channels; i++) {
-    for (j=0; j < s->winsize; j++) {
-      s->in[j] = input->data[i][j];
-    }
-    fftw_execute(s->pfw);
+  uint_t j;
+  for (j=0; j < s->winsize; j++) {
+    s->in[j] = input->data[j];
+  }
+  fftw_execute(s->pfw);
 #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]);
-      compspec->data[i][compspec->length - j] = IMAG(s->specdata[j]);
-    }
-    compspec->data[i][s->fft_size-1] = REAL(s->specdata[s->fft_size-1]);
+  compspec->data[0] = REAL(s->specdata[0]);
+  for (j = 1; j < s->fft_size -1 ; j++) {
+    compspec->data[j] = REAL(s->specdata[j]);
+    compspec->data[compspec->length - j] = IMAG(s->specdata[j]);
+  }
+  compspec->data[s->fft_size-1] = REAL(s->specdata[s->fft_size-1]);
 #else
-    for (j = 0; j < s->fft_size; j++) {
-      compspec->data[i][j] = s->specdata[j];
-    }
-#endif
+  for (j = 0; j < s->fft_size; j++) {
+    compspec->data[j] = s->specdata[j];
   }
+#endif
 }
 
 void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) {
-  uint_t i, j;
+  uint_t j;
   const smpl_t renorm = 1./(smpl_t)s->winsize;
-  for (i = 0; i < compspec->channels; i++) {
 #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] + 
-        I * compspec->data[i][compspec->length - j];
-    }
-    s->specdata[s->fft_size - 1] = compspec->data[i][s->fft_size - 1];
+  s->specdata[0] = compspec->data[0];
+  for (j=1; j < s->fft_size - 1; j++) {
+    s->specdata[j] = compspec->data[j] + 
+      I * compspec->data[compspec->length - j];
+  }
+  s->specdata[s->fft_size - 1] = compspec->data[s->fft_size - 1];
 #else
-    for (j=0; j < s->fft_size; j++) {
-      s->specdata[j] = compspec->data[i][j];
-    }
+  for (j=0; j < s->fft_size; j++) {
+    s->specdata[j] = compspec->data[j];
+  }
 #endif
-    fftw_execute(s->pbw);
-    for (j = 0; j < output->length; j++) {
-      output->data[i][j] = s->out[j]*renorm;
-    }
+  fftw_execute(s->pbw);
+  for (j = 0; j < output->length; j++) {
+    output->data[j] = s->out[j]*renorm;
   }
 }
 
@@ -190,54 +184,46 @@ void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec) {
 }
 
 void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) {
-  uint_t i, j;
-  for (i = 0; i < spectrum->channels; i++) {
-    if (compspec->data[i][0] < 0) {
-      spectrum->phas[i][0] = PI;
-    } else {
-      spectrum->phas[i][0] = 0.;
-    }
-    for (j=1; j < spectrum->length - 1; j++) {
-      spectrum->phas[i][j] = ATAN2(compspec->data[i][compspec->length-j],
-          compspec->data[i][j]);
-    }
-    if (compspec->data[i][compspec->length/2] < 0) {
-      spectrum->phas[i][spectrum->length - 1] = PI;
-    } else {
-      spectrum->phas[i][spectrum->length - 1] = 0.;
-    }
+  uint_t j;
+  if (compspec->data[0] < 0) {
+    spectrum->phas[0] = PI;
+  } else {
+    spectrum->phas[0] = 0.;
+  }
+  for (j=1; j < spectrum->length - 1; j++) {
+    spectrum->phas[j] = ATAN2(compspec->data[compspec->length-j],
+        compspec->data[j]);
+  }
+  if (compspec->data[compspec->length/2] < 0) {
+    spectrum->phas[spectrum->length - 1] = PI;
+  } else {
+    spectrum->phas[spectrum->length - 1] = 0.;
   }
 }
 
 void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum) {
-  uint_t i, j = 0;
-  for (i = 0; i < spectrum->channels; i++) {
-    spectrum->norm[i][0] = ABS(compspec->data[i][0]);
-    for (j=1; j < spectrum->length - 1; j++) {
-      spectrum->norm[i][j] = SQRT(SQR(compspec->data[i][j]) 
-          + SQR(compspec->data[i][compspec->length - j]) );
-    }
-    spectrum->norm[i][spectrum->length-1] = 
-      ABS(compspec->data[i][compspec->length/2]);
+  uint_t j = 0;
+  spectrum->norm[0] = ABS(compspec->data[0]);
+  for (j=1; j < spectrum->length - 1; j++) {
+    spectrum->norm[j] = SQRT(SQR(compspec->data[j]) 
+        + SQR(compspec->data[compspec->length - j]) );
   }
+  spectrum->norm[spectrum->length-1] = 
+    ABS(compspec->data[compspec->length/2]);
 }
 
 void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec) {
-  uint_t i, j;
-  for (i = 0; i < compspec->channels; i++) {
-    for (j = 1; j < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; j++) {
-      compspec->data[i][compspec->length - j] =
-        spectrum->norm[i][j]*SIN(spectrum->phas[i][j]);
-    }
+  uint_t j;
+  for (j = 1; j < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; j++) {
+    compspec->data[compspec->length - j] =
+      spectrum->norm[j]*SIN(spectrum->phas[j]);
   }
 }
 
 void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec) {
-  uint_t i, j;
-  for (i = 0; i < compspec->channels; i++) {
-    for (j = 0; j < compspec->length / 2 + 1; j++) {
-      compspec->data[i][j] = 
-        spectrum->norm[i][j]*COS(spectrum->phas[i][j]);
-    }
+  uint_t j;
+  for (j = 0; j < compspec->length / 2 + 1; j++) {
+    compspec->data[j] = 
+      spectrum->norm[j]*COS(spectrum->phas[j]);
   }
 }
index 27b6467..3ae4be8 100644 (file)
@@ -44,10 +44,9 @@ typedef struct _aubio_fft_t aubio_fft_t;
 /** create new FFT computation object
 
   \param size length of the FFT
-  \param channels number of channels
 
 */
-aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels);
+aubio_fft_t * new_aubio_fft (uint_t size);
 /** delete FFT object 
 
   \param s fft object as returned by new_aubio_fft
index 4a077c9..13d7f6e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "aubio_priv.h"
 #include "fvec.h"
+#include "fmat.h"
 #include "cvec.h"
 #include "spectral/filterbank.h"
 #include "mathutils.h"
@@ -30,7 +31,7 @@ struct _aubio_filterbank_t
 {
   uint_t win_s;
   uint_t n_filters;
-  fvec_t *filters;
+  fmat_t *filters;
 };
 
 aubio_filterbank_t *
@@ -41,8 +42,8 @@ new_aubio_filterbank (uint_t n_filters, uint_t win_s)
   fb->win_s = win_s;
   fb->n_filters = n_filters;
 
-  /* allocate filter tables, an fvec of length win_s and of filter_cnt channel */
-  fb->filters = new_fvec (win_s / 2 + 1, n_filters);
+  /* allocate filter tables, a matrix of length win_s and of height n_filters */
+  fb->filters = new_fmat (win_s / 2 + 1, n_filters);
 
   return fb;
 }
@@ -50,48 +51,43 @@ new_aubio_filterbank (uint_t n_filters, uint_t win_s)
 void
 del_aubio_filterbank (aubio_filterbank_t * fb)
 {
-  del_fvec (fb->filters);
+  del_fmat (fb->filters);
   AUBIO_FREE (fb);
 }
 
 void
 aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out)
 {
-  uint_t i, j, fn;
+  uint_t j, fn;
 
   /* apply filter to all input channel, provided out has enough channels */
-  uint_t max_channels = MIN (in->channels, out->channels);
   uint_t max_filters = MIN (f->n_filters, out->length);
   uint_t max_length = MIN (in->length, f->filters->length);
 
   /* reset all values in output vector */
   fvec_zeros (out);
 
-  /* apply filters on all channels */
-  for (i = 0; i < max_channels; i++) {
+  /* for each filter */
+  for (fn = 0; fn < max_filters; fn++) {
 
-    /* for each filter */
-    for (fn = 0; fn < max_filters; fn++) {
-
-      /* for each sample */
-      for (j = 0; j < max_length; j++) {
-        out->data[i][fn] += in->norm[i][j] * f->filters->data[fn][j];
-      }
+    /* for each sample */
+    for (j = 0; j < max_length; j++) {
+      out->data[fn] += in->norm[j] * f->filters->data[fn][j];
     }
   }
 
   return;
 }
 
-fvec_t *
+fmat_t *
 aubio_filterbank_get_coeffs (aubio_filterbank_t * f)
 {
   return f->filters;
 }
 
 uint_t
-aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fvec_t * filters)
+aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filter_coeffs)
 {
-  fvec_copy(filters, f->filters);
+  fmat_copy(filter_coeffs, f->filters);
   return 0;
 }
index 29cbdf0..0799dc2 100644 (file)
@@ -62,12 +62,12 @@ void del_aubio_filterbank (aubio_filterbank_t * fb);
 */
 void aubio_filterbank_do (aubio_filterbank_t * fb, cvec_t * in, fvec_t * out);
 
-/** return a pointer to the fvec object containing all filter coefficients 
+/** return a pointer to the matrix object containing all filter coefficients 
 
   \param f filterbank object to get coefficients from
 
  */
-fvec_t *aubio_filterbank_get_coeffs (aubio_filterbank_t * f);
+fmat_t *aubio_filterbank_get_coeffs (aubio_filterbank_t * f);
 
 /** copy filter coefficients to the filterbank
 
@@ -75,7 +75,7 @@ fvec_t *aubio_filterbank_get_coeffs (aubio_filterbank_t * f);
   \param filters filter bank coefficients to copy from
 
  */
-uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fvec_t * filters);
+uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filters);
 
 #ifdef __cplusplus
 }
index 1658073..7e16bd2 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "aubio_priv.h"
+#include "fmat.h"
 #include "fvec.h"
 #include "cvec.h"
 #include "spectral/filterbank.h"
@@ -30,8 +31,8 @@ aubio_filterbank_set_triangle_bands (aubio_filterbank_t * fb,
     fvec_t * freqs, smpl_t samplerate)
 {
 
-  fvec_t *filters = aubio_filterbank_get_coeffs (fb);
-  uint_t n_filters = filters->channels, win_s = filters->length;
+  fmat_t *filters = aubio_filterbank_get_coeffs (fb);
+  uint_t n_filters = filters->height, win_s = filters->length;
 
   uint_t fn;                    /* filter counter */
   uint_t bin;                   /* bin counter */
@@ -48,52 +49,52 @@ aubio_filterbank_set_triangle_bands (aubio_filterbank_t * fb,
         n_filters, freqs->length - 2);
   }
 
-  if (freqs->data[0][freqs->length - 1] > samplerate / 2) {
+  if (freqs->data[freqs->length - 1] > samplerate / 2) {
     AUBIO_WRN ("Nyquist frequency is %fHz, but highest frequency band ends at \
-%fHz\n", samplerate / 2, freqs->data[0][freqs->length - 1]);
+%fHz\n", samplerate / 2, freqs->data[freqs->length - 1]);
   }
 
   /* convenience reference to lower/center/upper frequency for each triangle */
-  fvec_t *lower_freqs = new_fvec (n_filters, 1);
-  fvec_t *upper_freqs = new_fvec (n_filters, 1);
-  fvec_t *center_freqs = new_fvec (n_filters, 1);
+  fvec_t *lower_freqs = new_fvec (n_filters);
+  fvec_t *upper_freqs = new_fvec (n_filters);
+  fvec_t *center_freqs = new_fvec (n_filters);
 
   /* height of each triangle */
-  fvec_t *triangle_heights = new_fvec (n_filters, 1);
+  fvec_t *triangle_heights = new_fvec (n_filters);
 
   /* lookup table of each bin frequency in hz */
-  fvec_t *fft_freqs = new_fvec (win_s, 1);
+  fvec_t *fft_freqs = new_fvec (win_s);
 
   /* fill up the lower/center/upper */
   for (fn = 0; fn < n_filters; fn++) {
-    lower_freqs->data[0][fn] = freqs->data[0][fn];
-    center_freqs->data[0][fn] = freqs->data[0][fn + 1];
-    upper_freqs->data[0][fn] = freqs->data[0][fn + 2];
+    lower_freqs->data[fn] = freqs->data[fn];
+    center_freqs->data[fn] = freqs->data[fn + 1];
+    upper_freqs->data[fn] = freqs->data[fn + 2];
   }
 
   /* compute triangle heights so that each triangle has unit area */
   for (fn = 0; fn < n_filters; fn++) {
-    triangle_heights->data[0][fn] =
-        2. / (upper_freqs->data[0][fn] - lower_freqs->data[0][fn]);
+    triangle_heights->data[fn] =
+        2. / (upper_freqs->data[fn] - lower_freqs->data[fn]);
   }
 
   /* fill fft_freqs lookup table, which assigns the frequency in hz to each bin */
   for (bin = 0; bin < win_s; bin++) {
-    fft_freqs->data[0][bin] =
+    fft_freqs->data[bin] =
         aubio_bintofreq (bin, samplerate, (win_s - 1) * 2);
   }
 
   /* zeroing of all filters */
-  fvec_zeros (filters);
+  fmat_zeros (filters);
 
-  if (fft_freqs->data[0][1] >= lower_freqs->data[0][0]) {
+  if (fft_freqs->data[1] >= lower_freqs->data[0]) {
     /* - 1 to make sure we don't miss the smallest power of two */
     uint_t min_win_s =
-        (uint_t) FLOOR (samplerate / lower_freqs->data[0][0]) - 1;
+        (uint_t) FLOOR (samplerate / lower_freqs->data[0]) - 1;
     AUBIO_WRN ("Lowest frequency bin (%.2fHz) is higher than lowest frequency \
 band (%.2f-%.2fHz). Consider increasing the window size from %d to %d.\n",
-        fft_freqs->data[0][1], lower_freqs->data[0][0],
-        upper_freqs->data[0][0], (win_s - 1) * 2,
+        fft_freqs->data[1], lower_freqs->data[0],
+        upper_freqs->data[0], (win_s - 1) * 2,
         aubio_next_power_of_two (min_win_s));
   }
 
@@ -102,8 +103,8 @@ band (%.2f-%.2fHz). Consider increasing the window size from %d to %d.\n",
 
     /* skip first elements */
     for (bin = 0; bin < win_s - 1; bin++) {
-      if (fft_freqs->data[0][bin] <= lower_freqs->data[0][fn] &&
-          fft_freqs->data[0][bin + 1] > lower_freqs->data[0][fn]) {
+      if (fft_freqs->data[bin] <= lower_freqs->data[fn] &&
+          fft_freqs->data[bin + 1] > lower_freqs->data[fn]) {
         bin++;
         break;
       }
@@ -111,15 +112,15 @@ band (%.2f-%.2fHz). Consider increasing the window size from %d to %d.\n",
 
     /* compute positive slope step size */
     smpl_t riseInc =
-        triangle_heights->data[0][fn] /
-        (center_freqs->data[0][fn] - lower_freqs->data[0][fn]);
+        triangle_heights->data[fn] /
+        (center_freqs->data[fn] - lower_freqs->data[fn]);
 
     /* compute coefficients in positive slope */
     for (; bin < win_s - 1; bin++) {
       filters->data[fn][bin] =
-          (fft_freqs->data[0][bin] - lower_freqs->data[0][fn]) * riseInc;
+          (fft_freqs->data[bin] - lower_freqs->data[fn]) * riseInc;
 
-      if (fft_freqs->data[0][bin + 1] >= center_freqs->data[0][fn]) {
+      if (fft_freqs->data[bin + 1] >= center_freqs->data[fn]) {
         bin++;
         break;
       }
@@ -127,19 +128,19 @@ band (%.2f-%.2fHz). Consider increasing the window size from %d to %d.\n",
 
     /* compute negative slope step size */
     smpl_t downInc =
-        triangle_heights->data[0][fn] /
-        (upper_freqs->data[0][fn] - center_freqs->data[0][fn]);
+        triangle_heights->data[fn] /
+        (upper_freqs->data[fn] - center_freqs->data[fn]);
 
     /* compute coefficents in negative slope */
     for (; bin < win_s - 1; bin++) {
       filters->data[fn][bin] +=
-          (upper_freqs->data[0][fn] - fft_freqs->data[0][bin]) * downInc;
+          (upper_freqs->data[fn] - fft_freqs->data[bin]) * downInc;
 
       if (filters->data[fn][bin] < 0.) {
         filters->data[fn][bin] = 0.;
       }
 
-      if (fft_freqs->data[0][bin + 1] >= upper_freqs->data[0][fn])
+      if (fft_freqs->data[bin + 1] >= upper_freqs->data[fn])
         break;
     }
     /* nothing else to do */
@@ -175,17 +176,17 @@ aubio_filterbank_set_mel_coeffs_slaney (aubio_filterbank_t * fb,
   uint_t fn;                    /* filter counter */
 
   /* buffers to compute filter frequencies */
-  fvec_t *freqs = new_fvec (n_filters + 2, 1);
+  fvec_t *freqs = new_fvec (n_filters + 2);
 
   /* first step: fill all the linear filter frequencies */
   for (fn = 0; fn < linearFilters; fn++) {
-    freqs->data[0][fn] = lowestFrequency + fn * linearSpacing;
+    freqs->data[fn] = lowestFrequency + fn * linearSpacing;
   }
-  smpl_t lastlinearCF = freqs->data[0][fn - 1];
+  smpl_t lastlinearCF = freqs->data[fn - 1];
 
   /* second step: fill all the log filter frequencies */
   for (fn = 0; fn < logFilters + 2; fn++) {
-    freqs->data[0][fn + linearFilters] =
+    freqs->data[fn + linearFilters] =
         lastlinearCF * (POW (logSpacing, fn + 1));
   }
 
index 6172b53..71c5dae 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "aubio_priv.h"
 #include "fvec.h"
+#include "fmat.h"
 #include "cvec.h"
 #include "mathutils.h"
 #include "vecutils.h"
@@ -39,7 +40,7 @@ struct _aubio_mfcc_t
   uint_t n_coefs;           /** number of coefficients (<= n_filters/2 +1) */
   aubio_filterbank_t *fb;   /** filter bank */
   fvec_t *in_dct;           /** input buffer for dct * [fb->n_filters] */
-  fvec_t *dct_coeffs;       /** DCT transform n_filters * n_coeffs */
+  fmat_t *dct_coeffs;       /** DCT transform n_filters * n_coeffs */
 };
 
 
@@ -63,9 +64,9 @@ new_aubio_mfcc (uint_t win_s, uint_t n_filters, uint_t n_coefs,
   aubio_filterbank_set_mel_coeffs_slaney (mfcc->fb, samplerate);
 
   /* allocating buffers */
-  mfcc->in_dct = new_fvec (n_filters, 1);
+  mfcc->in_dct = new_fvec (n_filters);
 
-  mfcc->dct_coeffs = new_fvec (n_coefs, n_filters);
+  mfcc->dct_coeffs = new_fmat (n_coefs, n_filters);
 
   /* compute DCT transform dct_coeffs[i][j] as
      cos ( j * (i+.5) * PI / n_filters ) */
@@ -99,7 +100,7 @@ del_aubio_mfcc (aubio_mfcc_t * mf)
 void
 aubio_mfcc_do (aubio_mfcc_t * mf, cvec_t * in, fvec_t * out)
 {
-  uint_t i, j, k;
+  uint_t j, k;
 
   /* compute filterbank */
   aubio_filterbank_do (mf->fb, in, mf->in_dct);
@@ -114,12 +115,10 @@ aubio_mfcc_do (aubio_mfcc_t * mf, cvec_t * in, fvec_t * out)
   fvec_zeros(out);
 
   /* compute discrete cosine transform */
-  for (i = 0; i < out->channels; i++) {
-    for (j = 0; j < mf->n_filters; j++) {
-      for (k = 0; k < mf->n_coefs; k++) {
-        out->data[i][k] += mf->in_dct->data[i][j]
-            * mf->dct_coeffs->data[j][k];
-      }
+  for (j = 0; j < mf->n_filters; j++) {
+    for (k = 0; k < mf->n_coefs; k++) {
+      out->data[k] += mf->in_dct->data[j]
+          * mf->dct_coeffs->data[j][k];
     }
   }
 
index cb8343f..ef934ed 100644 (file)
@@ -29,7 +29,6 @@
 struct _aubio_pvoc_t {
   uint_t win_s;       /** grain length */
   uint_t hop_s;       /** overlap step */
-  uint_t channels;    /** number of channels */
   aubio_fft_t * fft;  /** fft object */
   fvec_t * synth;     /** cur output grain [win_s] */
   fvec_t * synthold;  /** last input frame [win_s-hop_s] */
@@ -48,12 +47,9 @@ static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold,
     smpl_t * synthnew, uint_t win_s, uint_t hop_s);
 
 void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) {
-  uint_t i;
-  for (i=0; i<pv->channels; i++) {
-    /* slide  */
-    aubio_pvoc_swapbuffers(pv->data->data[i],pv->dataold->data[i],
-        datanew->data[i],pv->win_s,pv->hop_s);
-  }
+  /* slide  */
+  aubio_pvoc_swapbuffers(pv->data->data,pv->dataold->data,
+      datanew->data,pv->win_s,pv->hop_s);
   /* windowing */
   fvec_weight(pv->data, pv->w);
   /* shift */
@@ -63,18 +59,15 @@ void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) {
 }
 
 void aubio_pvoc_rdo(aubio_pvoc_t *pv,cvec_t * fftgrain, fvec_t * synthnew) {
-  uint_t i;
   /* calculate rfft */
   aubio_fft_rdo(pv->fft,fftgrain,pv->synth);
   /* unshift */
   fvec_shift(pv->synth);
-  for (i=0; i<pv->channels; i++) {
-    aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i],
-        synthnew->data[i],pv->win_s,pv->hop_s);
-  }
+  aubio_pvoc_addsynth(pv->synth->data,pv->synthold->data,
+      synthnew->data,pv->win_s,pv->hop_s);
 }
 
-aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) {
+aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s) {
   aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t);
 
   /* if (win_s < 2*hop_s) {
@@ -87,18 +80,17 @@ aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) {
     hop_s = win_s / 2;
   }
 
-  pv->fft      = new_aubio_fft(win_s,channels);
+  pv->fft      = new_aubio_fft (win_s);
 
   /* remember old */
-  pv->data     = new_fvec (win_s, channels);
-  pv->synth    = new_fvec (win_s, channels);
+  pv->data     = new_fvec (win_s);
+  pv->synth    = new_fvec (win_s);
 
   /* new input output */
-  pv->dataold  = new_fvec  (win_s-hop_s, channels);
-  pv->synthold = new_fvec (win_s-hop_s, channels);
+  pv->dataold  = new_fvec  (win_s-hop_s);
+  pv->synthold = new_fvec (win_s-hop_s);
   pv->w        = new_aubio_window ("hanningz", win_s);
 
-  pv->channels = channels;
   pv->hop_s    = hop_s;
   pv->win_s    = win_s;
 
index 3008a50..17f85d4 100644 (file)
@@ -25,7 +25,7 @@
   This object implements a phase vocoder. The spectral frames are computed
   using a HanningZ window and a swapped version of the signal to simplify the
   phase relationships across frames. The window sizes and overlap are specified
-  at creation time. Multiple channels are fully supported.
+  at creation time.
 
 */
 
@@ -43,10 +43,9 @@ typedef struct _aubio_pvoc_t aubio_pvoc_t;
 
   \param win_s size of analysis buffer (and length the FFT transform)
   \param hop_s step size between two consecutive analysis
-  \param channels number of channels
 
 */
-aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels);
+aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s);
 /** delete phase vocoder object
 
   \param pv phase vocoder object as returned by new_aubio_pvoc
@@ -56,7 +55,7 @@ void del_aubio_pvoc(aubio_pvoc_t *pv);
 
 /** compute spectral frame
   
-  This function accepts an input vector of size [channels]x[hop_s]. The
+  This function accepts an input vector of size [hop_s]. The
   analysis buffer is rotated and filled with the new data. After windowing of
   this signal window, the Fourier transform is computed and returned in
   fftgrain as two vectors, magnitude and phase.
@@ -70,7 +69,7 @@ void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t *in, cvec_t * fftgrain);
 /** compute signal from spectral frame
 
   This function takes an input spectral frame fftgrain of size
-  [channels]x[buf_s] and computes its inverse Fourier transform. Overlap-add
+  [buf_s] and computes its inverse Fourier transform. Overlap-add
   synthesis is then computed using the previously synthetised frames, and the
   output stored in out.
   
@@ -93,12 +92,6 @@ uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv);
 
 */
 uint_t aubio_pvoc_get_hop(aubio_pvoc_t* pv);
-/** get channel number
-  \param pv phase vocoder to get the number of channels from
-
-*/
-uint_t aubio_pvoc_get_channels(aubio_pvoc_t* pv);
 
 #ifdef __cplusplus
 }
index 838188e..aabfcd9 100644 (file)
@@ -88,49 +88,43 @@ struct _aubio_specdesc_t {
 /* Energy based onset detection function */
 void aubio_specdesc_energy  (aubio_specdesc_t *o UNUSED,
     cvec_t * fftgrain, fvec_t * onset) {
-  uint_t i,j;
-  for (i=0;i<fftgrain->channels;i++) {
-    onset->data[i][0] = 0.;
-    for (j=0;j<fftgrain->length;j++) {
-      onset->data[i][0] += SQR(fftgrain->norm[i][j]);
-    }
+  uint_t j;
+  onset->data[0] = 0.;
+  for (j=0;j<fftgrain->length;j++) {
+    onset->data[0] += SQR(fftgrain->norm[j]);
   }
 }
 
 /* High Frequency Content onset detection function */
 void aubio_specdesc_hfc(aubio_specdesc_t *o UNUSED,
     cvec_t * fftgrain, fvec_t * onset){
-  uint_t i,j;
-  for (i=0;i<fftgrain->channels;i++) {
-    onset->data[i][0] = 0.;
-    for (j=0;j<fftgrain->length;j++) {
-      onset->data[i][0] += (j+1)*fftgrain->norm[i][j];
-    }
+  uint_t j;
+  onset->data[0] = 0.;
+  for (j=0;j<fftgrain->length;j++) {
+    onset->data[0] += (j+1)*fftgrain->norm[j];
   }
 }
 
 
 /* Complex Domain Method onset detection function */
 void aubio_specdesc_complex (aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset) {
-  uint_t i, j;
+  uint_t j;
   uint_t nbins = fftgrain->length;
-  for (i=0;i<fftgrain->channels; i++)  {
-    onset->data[i][0] = 0.;
-    for (j=0;j<nbins; j++)  {
-      // compute the predicted phase
-      o->dev1->data[i][j] = 2. * o->theta1->data[i][j] - o->theta2->data[i][j];
-      // compute the euclidean distance in the complex domain
-      // sqrt ( r_1^2 + r_2^2 - 2 * r_1 * r_2 * \cos ( \phi_1 - \phi_2 ) )
-      onset->data[i][0] +=
-        SQRT (ABS (SQR (o->oldmag->data[i][j]) + SQR (fftgrain->norm[i][j])
-              - 2. * o->oldmag->data[i][j] * fftgrain->norm[i][j]
-              * COS (o->dev1->data[i][j] - fftgrain->phas[i][j])));
-      /* swap old phase data (need to remember 2 frames behind)*/
-      o->theta2->data[i][j] = o->theta1->data[i][j];
-      o->theta1->data[i][j] = fftgrain->phas[i][j];
-      /* swap old magnitude data (1 frame is enough) */
-      o->oldmag->data[i][j] = fftgrain->norm[i][j];
-    }
+  onset->data[0] = 0.;
+  for (j=0;j<nbins; j++)  {
+    // compute the predicted phase
+    o->dev1->data[j] = 2. * o->theta1->data[j] - o->theta2->data[j];
+    // compute the euclidean distance in the complex domain
+    // sqrt ( r_1^2 + r_2^2 - 2 * r_1 * r_2 * \cos ( \phi_1 - \phi_2 ) )
+    onset->data[0] +=
+      SQRT (ABS (SQR (o->oldmag->data[j]) + SQR (fftgrain->norm[j])
+            - 2. * o->oldmag->data[j] * fftgrain->norm[j]
+            * COS (o->dev1->data[j] - fftgrain->phas[j])));
+    /* swap old phase data (need to remember 2 frames behind)*/
+    o->theta2->data[j] = o->theta1->data[j];
+    o->theta1->data[j] = fftgrain->phas[j];
+    /* swap old magnitude data (1 frame is enough) */
+    o->oldmag->data[j] = fftgrain->norm[j];
   }
 }
 
@@ -138,51 +132,48 @@ void aubio_specdesc_complex (aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * on
 /* Phase Based Method onset detection function */
 void aubio_specdesc_phase(aubio_specdesc_t *o, 
     cvec_t * fftgrain, fvec_t * onset){
-  uint_t i, j;
+  uint_t j;
   uint_t nbins = fftgrain->length;
-  for (i=0;i<fftgrain->channels; i++)  {
-    onset->data[i][0] = 0.0;
-    o->dev1->data[i][0]=0.;
-    for ( j=0;j<nbins; j++ )  {
-      o->dev1->data[i][j] = 
-        aubio_unwrap2pi(
-            fftgrain->phas[i][j]
-            -2.0*o->theta1->data[i][j]
-            +o->theta2->data[i][j]);
-      if ( o->threshold < fftgrain->norm[i][j] )
-        o->dev1->data[i][j] = ABS(o->dev1->data[i][j]);
-      else 
-        o->dev1->data[i][j] = 0.0;
-      /* keep a track of the past frames */
-      o->theta2->data[i][j] = o->theta1->data[i][j];
-      o->theta1->data[i][j] = fftgrain->phas[i][j];
-    }
-    /* apply o->histogram */
-    aubio_hist_dyn_notnull(o->histog,o->dev1);
-    /* weight it */
-    aubio_hist_weight(o->histog);
-    /* its mean is the result */
-    onset->data[i][0] = aubio_hist_mean(o->histog);  
-    //onset->data[i][0] = fvec_mean(o->dev1);
+  onset->data[0] = 0.0;
+  o->dev1->data[0]=0.;
+  for ( j=0;j<nbins; j++ )  {
+    o->dev1->data[j] = 
+      aubio_unwrap2pi(
+          fftgrain->phas[j]
+          -2.0*o->theta1->data[j]
+          +o->theta2->data[j]);
+    if ( o->threshold < fftgrain->norm[j] )
+      o->dev1->data[j] = ABS(o->dev1->data[j]);
+    else 
+      o->dev1->data[j] = 0.0;
+    /* keep a track of the past frames */
+    o->theta2->data[j] = o->theta1->data[j];
+    o->theta1->data[j] = fftgrain->phas[j];
   }
+  /* apply o->histogram */
+  aubio_hist_dyn_notnull(o->histog,o->dev1);
+  /* weight it */
+  aubio_hist_weight(o->histog);
+  /* its mean is the result */
+  onset->data[0] = aubio_hist_mean(o->histog);  
+  //onset->data[0] = fvec_mean(o->dev1);
 }
 
 /* Spectral difference method onset detection function */
 void aubio_specdesc_specdiff(aubio_specdesc_t *o,
     cvec_t * fftgrain, fvec_t * onset){
-  uint_t i, j;
+  uint_t j;
   uint_t nbins = fftgrain->length;
-  for (i=0;i<fftgrain->channels; i++)  {
-    onset->data[i][0] = 0.0;
+    onset->data[0] = 0.0;
     for (j=0;j<nbins; j++)  {
-      o->dev1->data[i][j] = SQRT(
-          ABS(SQR( fftgrain->norm[i][j])
-            - SQR(o->oldmag->data[i][j])));
-      if (o->threshold < fftgrain->norm[i][j] )
-        o->dev1->data[i][j] = ABS(o->dev1->data[i][j]);
+      o->dev1->data[j] = SQRT(
+          ABS(SQR( fftgrain->norm[j])
+            - SQR(o->oldmag->data[j])));
+      if (o->threshold < fftgrain->norm[j] )
+        o->dev1->data[j] = ABS(o->dev1->data[j]);
       else 
-        o->dev1->data[i][j] = 0.0;
-      o->oldmag->data[i][j] = fftgrain->norm[i][j];
+        o->dev1->data[j] = 0.0;
+      o->oldmag->data[j] = fftgrain->norm[j];
     }
 
     /* apply o->histogram (act somewhat as a low pass on the
@@ -191,52 +182,44 @@ void aubio_specdesc_specdiff(aubio_specdesc_t *o,
     /* weight it */
     aubio_hist_weight(o->histog);
     /* its mean is the result */
-    onset->data[i][0] = aubio_hist_mean(o->histog);  
-
-  }
+    onset->data[0] = aubio_hist_mean(o->histog);  
 }
 
 /* Kullback Liebler onset detection function
  * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 
  * negative (1.+) and infinite values (+1.e-10) */
 void aubio_specdesc_kl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){
-  uint_t i,j;
-  for (i=0;i<fftgrain->channels;i++) {
-    onset->data[i][0] = 0.;
+  uint_t j;
+    onset->data[0] = 0.;
     for (j=0;j<fftgrain->length;j++) {
-      onset->data[i][0] += fftgrain->norm[i][j]
-        *LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
-      o->oldmag->data[i][j] = fftgrain->norm[i][j];
+      onset->data[0] += fftgrain->norm[j]
+        *LOG(1.+fftgrain->norm[j]/(o->oldmag->data[j]+1.e-10));
+      o->oldmag->data[j] = fftgrain->norm[j];
     }
-    if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
-  }
+    if (isnan(onset->data[0])) onset->data[0] = 0.;
 }
 
 /* Modified Kullback Liebler onset detection function
  * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 
  * negative (1.+) and infinite values (+1.e-10) */
 void aubio_specdesc_mkl(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){
-  uint_t i,j;
-  for (i=0;i<fftgrain->channels;i++) {
-    onset->data[i][0] = 0.;
+  uint_t j;
+    onset->data[0] = 0.;
     for (j=0;j<fftgrain->length;j++) {
-      onset->data[i][0] += LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10));
-      o->oldmag->data[i][j] = fftgrain->norm[i][j];
+      onset->data[0] += LOG(1.+fftgrain->norm[j]/(o->oldmag->data[j]+1.e-10));
+      o->oldmag->data[j] = fftgrain->norm[j];
     }
-    if (isnan(onset->data[i][0])) onset->data[i][0] = 0.;
-  }
+    if (isnan(onset->data[0])) onset->data[0] = 0.;
 }
 
 /* Spectral flux */
 void aubio_specdesc_specflux(aubio_specdesc_t *o, cvec_t * fftgrain, fvec_t * onset){ 
-  uint_t i, j;
-  for (i=0;i<fftgrain->channels;i++) {
-    onset->data[i][0] = 0.;
-    for (j=0;j<fftgrain->length;j++) {
-      if (fftgrain->norm[i][j] > o->oldmag->data[i][j])
-        onset->data[i][0] += fftgrain->norm[i][j] - o->oldmag->data[i][j];
-      o->oldmag->data[i][j] = fftgrain->norm[i][j];
-    }
+  uint_t j;
+  onset->data[0] = 0.;
+  for (j=0;j<fftgrain->length;j++) {
+    if (fftgrain->norm[j] > o->oldmag->data[j])
+      onset->data[0] += fftgrain->norm[j] - o->oldmag->data[j];
+    o->oldmag->data[j] = fftgrain->norm[j];
   }
 }
 
@@ -251,8 +234,7 @@ aubio_specdesc_do (aubio_specdesc_t *o, cvec_t * fftgrain,
  * depending on the choosen type, allocate memory as needed
  */
 aubio_specdesc_t * 
-new_aubio_specdesc (char_t * onset_mode, 
-    uint_t size, uint_t channels){
+new_aubio_specdesc (char_t * onset_mode, uint_t size){
   aubio_specdesc_t * o = AUBIO_NEW(aubio_specdesc_t);
   uint_t rsize = size/2+1;
   aubio_specdesc_type onset_type;
@@ -302,28 +284,28 @@ new_aubio_specdesc (char_t * onset_mode,
       break;
       /* the other approaches will need some more memory spaces */
     case aubio_onset_complex:
-      o->oldmag = new_fvec(rsize,channels);
-      o->dev1   = new_fvec(rsize,channels);
-      o->theta1 = new_fvec(rsize,channels);
-      o->theta2 = new_fvec(rsize,channels);
+      o->oldmag = new_fvec(rsize);
+      o->dev1   = new_fvec(rsize);
+      o->theta1 = new_fvec(rsize);
+      o->theta2 = new_fvec(rsize);
       break;
     case aubio_onset_phase:
-      o->dev1   = new_fvec(rsize,channels);
-      o->theta1 = new_fvec(rsize,channels);
-      o->theta2 = new_fvec(rsize,channels);
-      o->histog = new_aubio_hist(0.0, PI, 10, channels);
+      o->dev1   = new_fvec(rsize);
+      o->theta1 = new_fvec(rsize);
+      o->theta2 = new_fvec(rsize);
+      o->histog = new_aubio_hist(0.0, PI, 10);
       o->threshold = 0.1;
       break;
     case aubio_onset_specdiff:
-      o->oldmag = new_fvec(rsize,channels);
-      o->dev1   = new_fvec(rsize,channels);
-      o->histog = new_aubio_hist(0.0, PI, 10, channels);
+      o->oldmag = new_fvec(rsize);
+      o->dev1   = new_fvec(rsize);
+      o->histog = new_aubio_hist(0.0, PI, 10);
       o->threshold = 0.1;
       break;
     case aubio_onset_kl:
     case aubio_onset_mkl:
     case aubio_onset_specflux:
-      o->oldmag = new_fvec(rsize,channels);
+      o->oldmag = new_fvec(rsize);
       break;
     default:
       break;
index af1722a..c867d1f 100644 (file)
@@ -24,7 +24,7 @@
  
   All of the following spectral description functions take as arguments the FFT
   of a windowed signal (as created with aubio_pvoc). They output one smpl_t per
-  buffer and per channel (stored in a vector of size [channels]x[1]).
+  buffer (stored in a vector of size [1]).
  
   A list of the spectral description methods currently available follows.
 
@@ -167,11 +167,9 @@ void aubio_specdesc_do (aubio_specdesc_t * o, cvec_t * fftgrain,
 
   \param method spectral description method
   \param buf_size length of the input spectrum frame
-  \param channels number of input channels
 
 */
-aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size,
-    uint_t channels);
+aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size);
 
 /** deletion of a spectral descriptor 
 
index 9315050..87cf486 100644 (file)
 #include "spectral/specdesc.h"
 
 smpl_t
-cvec_sum_channel (cvec_t * s, uint_t i)
+cvec_sum (cvec_t * s)
 {
   uint_t j;
   smpl_t tmp = 0.0;
-  for (j = 0; j < s->length; j++)
-      tmp += s->norm[i][j];
+  for (j = 0; j < s->length; j++) {
+    tmp += s->norm[j];
+  }
   return tmp;
 }
 
 smpl_t
-cvec_mean_channel (cvec_t * s, uint_t i)
+cvec_mean (cvec_t * s)
 {
-  return cvec_sum_channel(s, i) / (smpl_t) (s->length);
+  return cvec_sum (s) / (smpl_t) (s->length);
 }
 
 smpl_t
-cvec_centroid_channel (cvec_t * spec, uint_t i)
+cvec_centroid (cvec_t * spec)
 {
   smpl_t sum = 0., sc = 0.;
   uint_t j;
-  sum = cvec_sum_channel (spec, i); 
+  sum = cvec_sum (spec); 
   if (sum == 0.) {
     return 0.;
   } else {
     for (j = 0; j < spec->length; j++) {
-      sc += (smpl_t) j *spec->norm[i][j];
+      sc += (smpl_t) j *spec->norm[j];
     }
     return sc / sum;
   }
 }
 
 smpl_t
-cvec_moment_channel (cvec_t * spec, uint_t i, uint_t order)
+cvec_moment (cvec_t * spec, uint_t order)
 {
   smpl_t sum = 0., centroid = 0., sc = 0.;
   uint_t j;
-  sum = cvec_sum_channel (spec, i); 
+  sum = cvec_sum (spec); 
   if (sum == 0.) {
     return 0.;
   } else {
-    centroid = cvec_centroid_channel (spec, i);
+    centroid = cvec_centroid (spec);
     for (j = 0; j < spec->length; j++) {
-      sc += (smpl_t) POW(j - centroid, order) * spec->norm[i][j];
+      sc += (smpl_t) POW(j - centroid, order) * spec->norm[j];
     }
     return sc / sum;
   }
@@ -75,35 +76,27 @@ void
 aubio_specdesc_centroid (aubio_specdesc_t * o UNUSED, cvec_t * spec,
     fvec_t * desc)
 {
-  uint_t i;
-  for (i = 0; i < spec->channels; i++) {
-    desc->data[i][0] = cvec_centroid_channel (spec, i); 
-  }
+  desc->data[0] = cvec_centroid (spec); 
 }
 
 void
 aubio_specdesc_spread (aubio_specdesc_t * o UNUSED, cvec_t * spec,
     fvec_t * desc)
 {
-  uint_t i;
-  for (i = 0; i < spec->channels; i++) {
-    desc->data[i][0] = cvec_moment_channel (spec, i, 2);
-  }
+  desc->data[0] = cvec_moment (spec, 2);
 }
 
 void
 aubio_specdesc_skewness (aubio_specdesc_t * o UNUSED, cvec_t * spec,
     fvec_t * desc)
 {
-  uint_t i; smpl_t spread;
-  for (i = 0; i < spec->channels; i++) {
-    spread = cvec_moment_channel (spec, i, 2);
-    if (spread == 0) {
-      desc->data[i][0] = 0.;
-    } else {
-      desc->data[i][0] = cvec_moment_channel (spec, i, 3);
-      desc->data[i][0] /= POW ( SQRT (spread), 3);
-    }
+  smpl_t spread;
+  spread = cvec_moment (spec, 2);
+  if (spread == 0) {
+    desc->data[0] = 0.;
+  } else {
+    desc->data[0] = cvec_moment (spec, 3);
+    desc->data[0] /= POW ( SQRT (spread), 3);
   }
 }
 
@@ -111,15 +104,13 @@ void
 aubio_specdesc_kurtosis (aubio_specdesc_t * o UNUSED, cvec_t * spec,
     fvec_t * desc)
 {
-  uint_t i; smpl_t spread;
-  for (i = 0; i < spec->channels; i++) {
-    spread = cvec_moment_channel (spec, i, 2);
-    if (spread == 0) {
-      desc->data[i][0] = 0.;
-    } else {
-      desc->data[i][0] = cvec_moment_channel (spec, i, 4);
-      desc->data[i][0] /= SQR (spread);
-    }
+  smpl_t spread;
+  spread = cvec_moment (spec, 2);
+  if (spread == 0) {
+    desc->data[0] = 0.;
+  } else {
+    desc->data[0] = cvec_moment (spec, 4);
+    desc->data[0] /= SQR (spread);
   }
 }
 
@@ -127,7 +118,7 @@ void
 aubio_specdesc_slope (aubio_specdesc_t * o UNUSED, cvec_t * spec,
     fvec_t * desc)
 {
-  uint_t i, j;
+  uint_t j;
   smpl_t norm = 0, sum = 0.; 
   // compute N * sum(j**2) - sum(j)**2
   for (j = 0; j < spec->length; j++) {
@@ -136,20 +127,18 @@ aubio_specdesc_slope (aubio_specdesc_t * o UNUSED, cvec_t * spec,
   norm *= spec->length;
   // sum_0^N(j) = length * (length + 1) / 2
   norm -= SQR( (spec->length) * (spec->length - 1.) / 2. );
-  for (i = 0; i < spec->channels; i++) {
-    sum = cvec_sum_channel (spec, i); 
-    desc->data[i][0] = 0.;
-    if (sum == 0.) {
-      break; 
-    } else {
-      for (j = 0; j < spec->length; j++) {
-        desc->data[i][0] += j * spec->norm[i][j]; 
-      }
-      desc->data[i][0] *= spec->length;
-      desc->data[i][0] -= sum * spec->length * (spec->length - 1) / 2.;
-      desc->data[i][0] /= norm;
-      desc->data[i][0] /= sum;
+  sum = cvec_sum (spec); 
+  desc->data[0] = 0.;
+  if (sum == 0.) {
+    return; 
+  } else {
+    for (j = 0; j < spec->length; j++) {
+      desc->data[0] += j * spec->norm[j]; 
     }
+    desc->data[0] *= spec->length;
+    desc->data[0] -= sum * spec->length * (spec->length - 1) / 2.;
+    desc->data[0] /= norm;
+    desc->data[0] /= sum;
   }
 }
 
@@ -157,19 +146,17 @@ void
 aubio_specdesc_decrease (aubio_specdesc_t *o UNUSED, cvec_t * spec,
     fvec_t * desc)
 {
-  uint_t i, j; smpl_t sum;
-  for (i = 0; i < spec->channels; i++) {
-    sum = cvec_sum_channel (spec, i); 
-    desc->data[i][0] = 0;
-    if (sum == 0.) {
-      break;
-    } else {
-      sum -= spec->norm[i][0];
-      for (j = 1; j < spec->length; j++) {
-        desc->data[i][0] += (spec->norm[i][j] - spec->norm[i][0]) / j;
-      }
-      desc->data[i][0] /= sum;
+  uint_t j; smpl_t sum;
+  sum = cvec_sum (spec); 
+  desc->data[0] = 0;
+  if (sum == 0.) {
+    return;
+  } else {
+    sum -= spec->norm[0];
+    for (j = 1; j < spec->length; j++) {
+      desc->data[0] += (spec->norm[j] - spec->norm[0]) / j;
     }
+    desc->data[0] /= sum;
   }
 }
 
@@ -177,22 +164,20 @@ void
 aubio_specdesc_rolloff (aubio_specdesc_t *o UNUSED, cvec_t * spec,
     fvec_t *desc)
 {
-  uint_t i, j; smpl_t cumsum, rollsum;
-  for (i = 0; i < spec->channels; i++) {
-    cumsum = 0.; rollsum = 0.;
-    for (j = 0; j < spec->length; j++) {
-      cumsum += SQR (spec->norm[i][j]);
-    }
-    if (cumsum == 0) {
-      desc->data[i][0] = 0.;
-    } else {
-      cumsum *= 0.95;
-      j = 0;
-      while (rollsum < cumsum) { 
-        rollsum += SQR (spec->norm[i][j]);
-        j++;
-      }
-      desc->data[i][0] = j;
+  uint_t j; smpl_t cumsum, rollsum;
+  cumsum = 0.; rollsum = 0.;
+  for (j = 0; j < spec->length; j++) {
+    cumsum += SQR (spec->norm[j]);
+  }
+  if (cumsum == 0) {
+    desc->data[0] = 0.;
+  } else {
+    cumsum *= 0.95;
+    j = 0;
+    while (rollsum < cumsum) { 
+      rollsum += SQR (spec->norm[j]);
+      j++;
     }
+    desc->data[0] = j;
   }
 }
index 81a8b49..9898468 100644 (file)
@@ -43,54 +43,51 @@ struct _aubio_tss_t
 void aubio_tss_do(aubio_tss_t *o, cvec_t * input, 
     cvec_t * trans, cvec_t * stead)
 {
-  uint_t i,j;
+  uint_t j;
   uint_t test;
   uint_t nbins     = input->length;
-  uint_t channels  = input->channels;
   smpl_t alpha     = o->alpha;
   smpl_t beta      = o->beta;
   smpl_t parm      = o->parm;
-  smpl_t ** dev    = (smpl_t **)o->dev->data;
-  smpl_t ** oft1   = (smpl_t **)o->oft1->data;
-  smpl_t ** oft2   = (smpl_t **)o->oft2->data;
-  smpl_t ** theta1 = (smpl_t **)o->theta1->data;
-  smpl_t ** theta2 = (smpl_t **)o->theta2->data;
+  smpl_t * dev    = (smpl_t *)o->dev->data;
+  smpl_t * oft1   = (smpl_t *)o->oft1->data;
+  smpl_t * oft2   = (smpl_t *)o->oft2->data;
+  smpl_t * theta1 = (smpl_t *)o->theta1->data;
+  smpl_t * theta2 = (smpl_t *)o->theta2->data;
   /* second phase derivative */
-  for (i=0;i<channels; i++){
-    for (j=0;j<nbins; j++){
-      dev[i][j] = aubio_unwrap2pi(input->phas[i][j]
-          -2.0*theta1[i][j]+theta2[i][j]);
-      theta2[i][j] = theta1[i][j];
-      theta1[i][j] = input->phas[i][j];
-    }
-
-    for (j=0;j<nbins; j++){
-      /* transient analysis */
-      test = (ABS(dev[i][j]) > parm*oft1[i][j]);
-      trans->norm[i][j] = input->norm[i][j] * test;
-      trans->phas[i][j] = input->phas[i][j] * test;
-    }
-
-    for (j=0;j<nbins; j++){
-      /* steady state analysis */
-      test = (ABS(dev[i][j]) < parm*oft2[i][j]);
-      stead->norm[i][j] = input->norm[i][j] * test;
-      stead->phas[i][j] = input->phas[i][j] * test;
-
-      /*increase sstate probability for sines */
-      test = (trans->norm[i][j]==0.);
-      oft1[i][j]  = test;
-      test = (stead->norm[i][j]==0.);
-      oft2[i][j]  = test;
-      test = (trans->norm[i][j]>0.);
-      oft1[i][j] += alpha*test;
-      test = (stead->norm[i][j]>0.);
-      oft2[i][j] += alpha*test;
-      test = (oft1[i][j]>1. && trans->norm[i][j]>0.);
-      oft1[i][j] += beta*test;
-      test = (oft2[i][j]>1. && stead->norm[i][j]>0.);
-      oft2[i][j] += beta*test;
-    }
+  for (j=0;j<nbins; j++){
+    dev[j] = aubio_unwrap2pi(input->phas[j]
+        -2.0*theta1[j]+theta2[j]);
+    theta2[j] = theta1[j];
+    theta1[j] = input->phas[j];
+  }
+
+  for (j=0;j<nbins; j++){
+    /* transient analysis */
+    test = (ABS(dev[j]) > parm*oft1[j]);
+    trans->norm[j] = input->norm[j] * test;
+    trans->phas[j] = input->phas[j] * test;
+  }
+
+  for (j=0;j<nbins; j++){
+    /* steady state analysis */
+    test = (ABS(dev[j]) < parm*oft2[j]);
+    stead->norm[j] = input->norm[j] * test;
+    stead->phas[j] = input->phas[j] * test;
+
+    /*increase sstate probability for sines */
+    test = (trans->norm[j]==0.);
+    oft1[j]  = test;
+    test = (stead->norm[j]==0.);
+    oft2[j]  = test;
+    test = (trans->norm[j]>0.);
+    oft1[j] += alpha*test;
+    test = (stead->norm[j]>0.);
+    oft2[j] += alpha*test;
+    test = (oft1[j]>1. && trans->norm[j]>0.);
+    oft1[j] += beta*test;
+    test = (oft2[j]>1. && stead->norm[j]>0.);
+    oft2[j] += beta*test;
   }
 }
 
@@ -100,7 +97,7 @@ uint_t aubio_tss_set_threshold(aubio_tss_t *o, smpl_t threshold){
   return AUBIO_OK;
 }
 
-aubio_tss_t * new_aubio_tss(uint_t buf_size, uint_t hop_size, uint_t channels)
+aubio_tss_t * new_aubio_tss(uint_t buf_size, uint_t hop_size)
 {
   aubio_tss_t * o = AUBIO_NEW(aubio_tss_t);
   uint_t rsize = buf_size/2+1;
@@ -109,11 +106,11 @@ aubio_tss_t * new_aubio_tss(uint_t buf_size, uint_t hop_size, uint_t channels)
   o->alpha = 3.;
   o->beta = 4.;
   o->parm = o->threshold*o->thrsfact;
-  o->theta1 = new_fvec(rsize,channels);
-  o->theta2 = new_fvec(rsize,channels);
-  o->oft1 = new_fvec(rsize,channels);
-  o->oft2 = new_fvec(rsize,channels);
-  o->dev = new_fvec(rsize,channels);
+  o->theta1 = new_fvec(rsize);
+  o->theta2 = new_fvec(rsize);
+  o->oft1 = new_fvec(rsize);
+  o->oft2 = new_fvec(rsize);
+  o->dev = new_fvec(rsize);
   return o;
 }
 
index cf697dc..56f5f86 100644 (file)
@@ -48,10 +48,9 @@ typedef struct _aubio_tss_t aubio_tss_t;
 
   \param buf_size buffer size
   \param hop_size step size
-  \param channels number of input channels
 
 */
-aubio_tss_t *new_aubio_tss (uint_t buf_size, uint_t hop_size, uint_t channels);
+aubio_tss_t *new_aubio_tss (uint_t buf_size, uint_t hop_size);
 
 /** delete tss object
 
index 454f4a2..f3e0b80 100644 (file)
@@ -54,7 +54,7 @@ struct _aubio_beattracking_t
 };
 
 aubio_beattracking_t *
-new_aubio_beattracking (uint_t winlen, uint_t channels)
+new_aubio_beattracking (uint_t winlen)
 {
 
   aubio_beattracking_t *p = AUBIO_NEW (aubio_beattracking_t);
@@ -78,25 +78,25 @@ new_aubio_beattracking (uint_t winlen, uint_t channels)
 
   p->rayparam = rayparam;
   p->step = step;
-  p->rwv = new_fvec (laglen, 1);
-  p->gwv = new_fvec (laglen, 1);
-  p->dfwv = new_fvec (winlen, 1);
-  p->dfrev = new_fvec (winlen, channels);
-  p->acf = new_fvec (winlen, channels);
-  p->acfout = new_fvec (laglen, channels);
-  p->phwv = new_fvec (2 * laglen, 1);
-  p->phout = new_fvec (winlen, channels);
+  p->rwv = new_fvec (laglen);
+  p->gwv = new_fvec (laglen);
+  p->dfwv = new_fvec (winlen);
+  p->dfrev = new_fvec (winlen);
+  p->acf = new_fvec (winlen);
+  p->acfout = new_fvec (laglen);
+  p->phwv = new_fvec (2 * laglen);
+  p->phout = new_fvec (winlen);
 
   p->timesig = 0;
 
   /* exponential weighting, dfwv = 0.5 when i =  43 */
   for (i = 0; i < winlen; i++) {
-    p->dfwv->data[0][i] = (EXP ((LOG (2.0) / rayparam) * (i + 1)))
+    p->dfwv->data[i] = (EXP ((LOG (2.0) / rayparam) * (i + 1)))
         / dfwvnorm;
   }
 
   for (i = 0; i < (laglen); i++) {
-    p->rwv->data[0][i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) *
+    p->rwv->data[i] = ((smpl_t) (i + 1.) / SQR ((smpl_t) rayparam)) *
         EXP ((-SQR ((smpl_t) (i + 1.)) / (2. * SQR ((smpl_t) rayparam))));
   }
 
@@ -160,7 +160,7 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,
   for (i = 1; i < laglen - 1; i++) {
     for (a = 1; a <= numelem; a++) {
       for (b = (1 - a); b < a; b++) {
-        bt->acfout->data[0][i] += bt->acf->data[0][a * (i + 1) + b - 1]
+        bt->acfout->data[i] += bt->acf->data[a * (i + 1) + b - 1]
             * 1. / (2. * a - 1.);
       }
     }
@@ -170,7 +170,7 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,
 
   /* find non-zero Rayleigh period */
   maxindex = fvec_max_elem (bt->acfout);
-  bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex, 0) : 1;
+  bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex) : 1;
   //rp = (maxindex==127) ? 43 : maxindex; //rayparam
   bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
 
@@ -190,7 +190,7 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,
   fvec_zeros (bt->phout);
   for (i = 0; i < bp; i++) {
     for (k = 0; k < kmax; k++) {
-      bt->phout->data[0][i] += bt->dfrev->data[0][i + (uint_t) ROUND (bp * k)];
+      bt->phout->data[i] += bt->dfrev->data[i + (uint_t) ROUND (bp * k)];
     }
   }
   fvec_weight (bt->phout, bt->phwv);
@@ -203,7 +203,7 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,
 #endif /* AUBIO_BEAT_WARNINGS */
     phase = step - bt->lastbeat;
   } else {
-    phase = fvec_quadint (bt->phout, maxindex, 0);
+    phase = fvec_quadint (bt->phout, maxindex);
   }
   /* take back one frame delay */
   phase += 1.;
@@ -236,20 +236,20 @@ aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,
 
   if (beat >= 0) {
     //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
-    output->data[0][i] = beat;
+    output->data[i] = beat;
     i++;
   }
 
   while (beat + bp <= step) {
     beat += bp;
     //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
-    output->data[0][i] = beat;
+    output->data[i] = beat;
     i++;
   }
 
   bt->lastbeat = beat;
   /* store the number of beats in this frame as the first element */
-  output->data[0][0] = i;
+  output->data[0] = i;
 }
 
 uint_t
@@ -259,14 +259,14 @@ fvec_gettimesig (fvec_t * acf, uint_t acflen, uint_t gp)
   smpl_t three_energy = 0., four_energy = 0.;
   if (acflen > 6 * gp + 2) {
     for (k = -2; k < 2; k++) {
-      three_energy += acf->data[0][3 * gp + k];
-      four_energy += acf->data[0][4 * gp + k];
+      three_energy += acf->data[3 * gp + k];
+      four_energy += acf->data[4 * gp + k];
     }
   } else {
     /*Expanded to be more accurate in time sig estimation */
     for (k = -2; k < 2; k++) {
-      three_energy += acf->data[0][3 * gp + k] + acf->data[0][6 * gp + k];
-      four_energy += acf->data[0][4 * gp + k] + acf->data[0][2 * gp + k];
+      three_energy += acf->data[3 * gp + k] + acf->data[6 * gp + k];
+      four_energy += acf->data[4 * gp + k] + acf->data[2 * gp + k];
     }
   }
   return (three_energy > four_energy) ? 3 : 4;
@@ -300,12 +300,12 @@ aubio_beattracking_checkstate (aubio_beattracking_t * bt)
     for (i = 1; i < laglen - 1; i++) {
       for (a = 1; a <= bt->timesig; a++) {
         for (b = (1 - a); b < a; b++) {
-          acfout->data[0][i] += acf->data[0][a * (i + 1) + b - 1];
+          acfout->data[i] += acf->data[a * (i + 1) + b - 1];
         }
       }
     }
     fvec_weight (acfout, bt->gwv);
-    gp = fvec_quadint (acfout, fvec_max_elem (acfout), 0);
+    gp = fvec_quadint (acfout, fvec_max_elem (acfout));
     /*
        while(gp<32) gp =gp*2;
        while(gp>64) gp = gp/2;
@@ -350,7 +350,7 @@ aubio_beattracking_checkstate (aubio_beattracking_t * bt)
     gp = rp;
     bt->timesig = fvec_gettimesig (acf, acflen, gp);
     for (j = 0; j < laglen; j++)
-      bt->gwv->data[0][j] =
+      bt->gwv->data[j] =
           EXP (-.5 * SQR ((smpl_t) (j + 1. - gp)) / SQR (bt->g_var));
     flagconst = 0;
     bp = gp;
@@ -362,7 +362,7 @@ aubio_beattracking_checkstate (aubio_beattracking_t * bt)
     /* gaussian phase weighting */
     if (step > bt->lastbeat) {
       for (j = 0; j < 2 * laglen; j++) {
-        bt->phwv->data[0][j] =
+        bt->phwv->data[j] =
             EXP (-.5 * SQR ((smpl_t) (1. + j - step +
                     bt->lastbeat)) / (bp / 8.));
       }
@@ -409,7 +409,7 @@ smpl_t
 aubio_beattracking_get_bpm (aubio_beattracking_t * bt)
 {
   if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
-    return 5168. / fvec_quadint (bt->acfout, bt->bp, 0);
+    return 5168. / fvec_quadint (bt->acfout, bt->bp);
   } else {
     return 0.;
   }
index af19b00..d4406d0 100644 (file)
@@ -47,10 +47,9 @@ typedef struct _aubio_beattracking_t aubio_beattracking_t;
 /** create beat tracking object
 
   \param hop_size number of onset detection samples [512] 
-  \param channels number (not functionnal) [1]
 
 */
-aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size, uint_t channels);
+aubio_beattracking_t * new_aubio_beattracking(uint_t hop_size);
 
 /** track the beat 
 
index 1bbe62c..77c7d52 100644 (file)
@@ -58,7 +58,7 @@ void aubio_tempo_do(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo)
   aubio_specdesc_do (o->od, o->fftgrain, o->of);
   /*if (usedoubled) {
     aubio_specdesc_do(o2,fftgrain, onset2);
-    onset->data[0][0] *= onset2->data[0][0];
+    onset->data[0] *= onset2->data[0];
   }*/
   /* execute every overlap_size*step */
   if (o->blockpos == (signed)step -1 ) {
@@ -66,26 +66,26 @@ void aubio_tempo_do(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo)
     aubio_beattracking_do(o->bt,o->dfframe,o->out);
     /* rotate dfframe */
     for (i = 0 ; i < winlen - step; i++ ) 
-      o->dfframe->data[0][i] = o->dfframe->data[0][i+step];
+      o->dfframe->data[i] = o->dfframe->data[i+step];
     for (i = winlen - step ; i < winlen; i++ ) 
-      o->dfframe->data[0][i] = 0.;
+      o->dfframe->data[i] = 0.;
     o->blockpos = -1;
   }
   o->blockpos++;
   aubio_peakpicker_do (o->pp, o->of, o->onset);
-  tempo->data[0][1] = o->onset->data[0][0];
+  tempo->data[1] = o->onset->data[0];
   thresholded = aubio_peakpicker_get_thresholded_input(o->pp);
-  o->dfframe->data[0][winlen - step + o->blockpos] = thresholded->data[0][0];
+  o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0];
   /* end of second level loop */
-  tempo->data[0][0] = 0; /* reset tactus */
+  tempo->data[0] = 0; /* reset tactus */
   i=0;
-  for (i = 1; i < o->out->data[0][0]; i++ ) {
+  for (i = 1; i < o->out->data[0]; i++ ) {
     /* if current frame is a predicted tactus */
-    if (o->blockpos == FLOOR(o->out->data[0][i])) {
-      tempo->data[0][0] = o->out->data[0][i] - FLOOR(o->out->data[0][i]); /* set tactus */
+    if (o->blockpos == FLOOR(o->out->data[i])) {
+      tempo->data[0] = o->out->data[i] - FLOOR(o->out->data[i]); /* set tactus */
       /* test for silence */
       if (aubio_silence_detection(input, o->silence)==1) {
-        tempo->data[0][1] = 0; /* unset onset */
+        tempo->data[1] = 0; /* unset onset */
       }
     }
   }
@@ -104,7 +104,7 @@ uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold) {
 
 /* Allocate memory for an tempo detection */
 aubio_tempo_t * new_aubio_tempo (char_t * onset_mode, 
-    uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate)
+    uint_t buf_size, uint_t hop_size, uint_t samplerate)
 {
   aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t);
   o->samplerate = samplerate;
@@ -114,19 +114,19 @@ aubio_tempo_t * new_aubio_tempo (char_t * onset_mode,
   o->threshold = 0.3;
   o->silence = -90.;
   o->blockpos = 0;
-  o->dfframe  = new_fvec(o->winlen,channels);
-  o->fftgrain = new_cvec(buf_size, channels);
-  o->out      = new_fvec(o->step,channels);
-  o->pv       = new_aubio_pvoc(buf_size, hop_size, channels);
-  o->pp       = new_aubio_peakpicker(channels);
+  o->dfframe  = new_fvec(o->winlen);
+  o->fftgrain = new_cvec(buf_size);
+  o->out      = new_fvec(o->step);
+  o->pv       = new_aubio_pvoc(buf_size, hop_size);
+  o->pp       = new_aubio_peakpicker();
   aubio_peakpicker_set_threshold (o->pp, o->threshold);
-  o->od       = new_aubio_specdesc(onset_mode,buf_size,channels);
-  o->of       = new_fvec(1, channels);
-  o->bt       = new_aubio_beattracking(o->winlen,channels);
-  o->onset    = new_fvec(1, channels);
+  o->od       = new_aubio_specdesc(onset_mode,buf_size);
+  o->of       = new_fvec(1);
+  o->bt       = new_aubio_beattracking(o->winlen);
+  o->onset    = new_fvec(1);
   /*if (usedoubled)    {
-    o2 = new_aubio_specdesc(type_onset2,buffer_size,channels);
-    onset2 = new_fvec(1 , channels);
+    o2 = new_aubio_specdesc(type_onset2,buffer_size);
+    onset2 = new_fvec(1);
   }*/
   return o;
 }
index f057e28..d6d01f6 100644 (file)
@@ -39,7 +39,7 @@ typedef struct _aubio_tempo_t aubio_tempo_t;
 
 /** create tempo detection object */
 aubio_tempo_t * new_aubio_tempo (char_t * method, 
-    uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
+    uint_t buf_size, uint_t hop_size, uint_t samplerate);
 
 /** execute tempo detection */
 void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);
index 96f5b51..819d6f7 100644 (file)
@@ -31,7 +31,7 @@ aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate)
   aubio_filter_set_samplerate (f, samplerate);
   lvec_t *bs = aubio_filter_get_feedforward (f);
   lvec_t *as = aubio_filter_get_feedback (f);
-  lsmp_t *b = bs->data[0], *a = as->data[0];
+  lsmp_t *b = bs->data, *a = as->data;
   uint_t order = aubio_filter_get_order (f);
 
   if (order != 7) {
@@ -240,9 +240,9 @@ aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate)
 }
 
 aubio_filter_t *
-new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate)
+new_aubio_filter_a_weighting (uint_t samplerate)
 {
-  aubio_filter_t *f = new_aubio_filter (7, channels);
+  aubio_filter_t *f = new_aubio_filter (7);
   aubio_filter_set_a_weighting (f, samplerate);
   return f;
 }
index 9aa1f00..cf1a1cb 100644 (file)
@@ -60,7 +60,6 @@ extern "C" {
 
 /** create new A-design filter
 
-  \param channels number of channels to allocate
   \param samplerate sampling frequency of the signal to filter. Should be one of 
   8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
   192000 Hz
@@ -68,8 +67,7 @@ extern "C" {
   \return a new filter object
 
 */
-aubio_filter_t *new_aubio_filter_a_weighting (uint_t channels,
-    uint_t samplerate);
+aubio_filter_t *new_aubio_filter_a_weighting (uint_t samplerate);
 
 /** set feedback and feedforward coefficients of a A-weighting filter
 
index 97f4138..0600168 100644 (file)
@@ -35,20 +35,19 @@ aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1, lsmp_t b2,
     AUBIO_ERROR ("order of biquad filter must be 3, not %d\n", order);
     return AUBIO_FAIL;
   }
-  bs->data[0][0] = b0;
-  bs->data[0][1] = b1;
-  bs->data[0][2] = b2;
-  as->data[0][0] = 1.;
-  as->data[0][1] = a1;
-  as->data[0][1] = a2;
+  bs->data[0] = b0;
+  bs->data[1] = b1;
+  bs->data[2] = b2;
+  as->data[0] = 1.;
+  as->data[1] = a1;
+  as->data[1] = a2;
   return AUBIO_OK;
 }
 
 aubio_filter_t *
-new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2,
-    uint_t channels)
+new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2)
 {
-  aubio_filter_t *f = new_aubio_filter (3, channels);
+  aubio_filter_t *f = new_aubio_filter (3);
   aubio_filter_set_biquad (f, b0, b1, b2, a1, a2);
   return f;
 }
index 5cf31fd..b3004ac 100644 (file)
@@ -61,11 +61,10 @@ uint_t aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1,
   \param b2 forward filter coefficient
   \param a1 feedback filter coefficient
   \param a2 feedback filter coefficient
-  \param channels number of channels to allocate
 
 */
 aubio_filter_t *new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2,
-    lsmp_t a1, lsmp_t a2, uint_t channels);
+    lsmp_t a1, lsmp_t a2);
 
 #ifdef __cplusplus
 }
index 3ab36a4..45c2894 100644 (file)
@@ -31,7 +31,7 @@ aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate)
   aubio_filter_set_samplerate (f, samplerate);
   lvec_t *bs = aubio_filter_get_feedforward (f);
   lvec_t *as = aubio_filter_get_feedback (f);
-  lsmp_t *b = bs->data[0], *a = as->data[0];
+  lsmp_t *b = bs->data, *a = as->data;
   uint_t order = aubio_filter_get_order (f);
 
   if ( order != 5 ) {
@@ -196,8 +196,8 @@ aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate)
   return 0;
 }
 
-aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate) {
-  aubio_filter_t * f = new_aubio_filter(5, channels);
+aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate) {
+  aubio_filter_t * f = new_aubio_filter(5);
   aubio_filter_set_c_weighting (f, samplerate);
   return f;
 }
index 819fa0a..c80cfc3 100644 (file)
@@ -60,7 +60,6 @@ extern "C" {
 
 /** create new C-design filter
 
-  \param channels number of channels to allocate
   \param samplerate sampling frequency of the signal to filter. Should be one of 
   8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
   192000 Hz
@@ -68,8 +67,7 @@ extern "C" {
   \return a new filter object
 
 */
-aubio_filter_t *new_aubio_filter_c_weighting (uint_t channels,
-    uint_t samplerate);
+aubio_filter_t *new_aubio_filter_c_weighting (uint_t samplerate);
 
 /** set feedback and feedforward coefficients of a C-weighting filter
 
index 3c10f74..0975e6f 100644 (file)
@@ -48,34 +48,27 @@ aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out)
 void
 aubio_filter_do (aubio_filter_t * f, fvec_t * in)
 {
-  uint_t i, j, l, order = f->order;
-  lsmp_t *x;
-  lsmp_t *y;
-  lsmp_t *a = f->a->data[0];
-  lsmp_t *b = f->b->data[0];
-
-  for (i = 0; i < in->channels; i++) {
-    x = f->x->data[i];
-    y = f->y->data[i];
-    for (j = 0; j < in->length; j++) {
-      /* new input */
-      x[0] = KILL_DENORMAL (in->data[i][j]);
-      y[0] = b[0] * x[0];
-      for (l = 1; l < order; l++) {
-        y[0] += b[l] * x[l];
-        y[0] -= a[l] * y[l];
-      }
-      /* new output */
-      in->data[i][j] = y[0];
-      /* store for next sample */
-      for (l = order - 1; l > 0; l--) {
-        x[l] = x[l - 1];
-        y[l] = y[l - 1];
-      }
+  uint_t j, l, order = f->order;
+  lsmp_t *x = f->x->data;
+  lsmp_t *y = f->y->data;
+  lsmp_t *a = f->a->data;
+  lsmp_t *b = f->b->data;
+
+  for (j = 0; j < in->length; j++) {
+    /* new input */
+    x[0] = KILL_DENORMAL (in->data[j]);
+    y[0] = b[0] * x[0];
+    for (l = 1; l < order; l++) {
+      y[0] += b[l] * x[l];
+      y[0] -= a[l] * y[l];
+    }
+    /* new output */
+    in->data[j] = y[0];
+    /* store for next sample */
+    for (l = order - 1; l > 0; l--) {
+      x[l] = x[l - 1];
+      y[l] = y[l - 1];
     }
-    /* store for next run */
-    f->x->data[i] = x;
-    f->y->data[i] = y;
   }
 }
 
@@ -83,20 +76,20 @@ aubio_filter_do (aubio_filter_t * f, fvec_t * in)
 void
 aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp)
 {
-  uint_t j, i = 0;
+  uint_t j;
   uint_t length = in->length;
   /* apply filtering */
   aubio_filter_do (f, in);
   aubio_filter_do_reset (f);
   /* mirror */
   for (j = 0; j < length; j++)
-    tmp->data[i][length - j - 1] = in->data[i][j];
+    tmp->data[length - j - 1] = in->data[j];
   /* apply filtering on mirrored */
   aubio_filter_do (f, tmp);
   aubio_filter_do_reset (f);
   /* invert back */
   for (j = 0; j < length; j++)
-    in->data[i][j] = tmp->data[i][length - j - 1];
+    in->data[j] = tmp->data[length - j - 1];
 }
 
 lvec_t *
@@ -138,18 +131,18 @@ aubio_filter_do_reset (aubio_filter_t * f)
 }
 
 aubio_filter_t *
-new_aubio_filter (uint_t order, uint_t channels)
+new_aubio_filter (uint_t order)
 {
   aubio_filter_t *f = AUBIO_NEW (aubio_filter_t);
-  f->x = new_lvec (order, channels);
-  f->y = new_lvec (order, channels);
-  f->a = new_lvec (order, 1);
-  f->b = new_lvec (order, 1);
+  f->x = new_lvec (order);
+  f->y = new_lvec (order);
+  f->a = new_lvec (order);
+  f->b = new_lvec (order);
   /* by default, samplerate is not set */
   f->samplerate = 0;
   f->order = order;
   /* set default to identity */
-  f->a->data[0][1] = 1.;
+  f->a->data[1] = 1.;
   return f;
 }
 
index 396e961..5d151ff 100644 (file)
@@ -25,7 +25,7 @@
 
   Digital filter
 
-  This object stores a digital filter of order \f$n\f$ for \f$c\f$ channels.
+  This object stores a digital filter of order \f$n\f$.
   It contains the following data:
     - \f$ n*1 b_i \f$ feedforward coefficients 
     - \f$ n*1 a_i \f$ feedback coefficients 
@@ -150,16 +150,15 @@ void aubio_filter_do_reset (aubio_filter_t * f);
 
 /** create new filter object
 
-  This function creates a new ::aubio_filter_t object, given an order 
-  and a specific number of channels.
+  This function creates a new ::aubio_filter_t object, given the order of the
+  filter.
 
   \param order order of the filter (number of coefficients)
-  \param channels number of channels to allocate
 
   \return the newly created filter object
 
 */
-aubio_filter_t *new_aubio_filter (uint_t order, uint_t channels);
+aubio_filter_t *new_aubio_filter (uint_t order);
 
 /** delete a filter object
  
index 3556518..21fe5af 100644 (file)
@@ -60,17 +60,14 @@ del_aubio_resampler (aubio_resampler_t * s)
 void
 aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output)
 {
-  uint_t i;
   s->proc->input_frames = input->length;
   s->proc->output_frames = output->length;
   s->proc->src_ratio = (double) s->ratio;
-  for (i = 0; i < input->channels; i++) {
-    /* make SRC_PROC data point to input outputs */
-    s->proc->data_in = (float *) input->data[i];
-    s->proc->data_out = (float *) output->data[i];
-    /* do resampling */
-    src_process (s->stat, s->proc);
-  }
+  /* make SRC_PROC data point to input outputs */
+  s->proc->data_in = (float *) input->data;
+  s->proc->data_out = (float *) output->data;
+  /* do resampling */
+  src_process (s->stat, s->proc);
 }
 
 #else
@@ -86,12 +83,12 @@ new_aubio_resampler (smpl_t ratio UNUSED, uint_t type UNUSED)
 }
 
 void
-del_aubio_resampler (aubio_resampler_t * s)
+del_aubio_resampler (aubio_resampler_t * s UNUSED)
 {
 }
 
 void
-aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output)
+aubio_resampler_do (aubio_resampler_t * s UNUSED, fvec_t * input UNUSED, fvec_t * output UNUSED)
 {
 }
 #endif /* HAVE_SAMPLERATE */
index 2b7e29c..ee44d74 100644 (file)
@@ -31,7 +31,6 @@
 struct _aubio_hist_t {
   fvec_t * hist;
   uint_t nelems;
-  uint_t channels;
   fvec_t * cent;
   aubio_scale_t *scaler;
 };
@@ -39,22 +38,21 @@ struct _aubio_hist_t {
 /**
  * Object creation/deletion calls
  */
-aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems, uint_t channels){
+aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems){
   aubio_hist_t * s = AUBIO_NEW(aubio_hist_t);
   smpl_t step = (ihig-ilow)/(smpl_t)(nelems);
   smpl_t accum = step;
   uint_t i;
-  s->channels = channels;
   s->nelems = nelems;
-  s->hist = new_fvec(nelems, channels);
-  s->cent = new_fvec(nelems, 1);
+  s->hist = new_fvec(nelems);
+  s->cent = new_fvec(nelems);
 
   /* use scale to map ilow/ihig -> 0/nelems */
   s->scaler = new_aubio_scale(ilow,ihig,0,nelems);
   /* calculate centers now once */
-  s->cent->data[0][0] = ilow + 0.5 * step;
+  s->cent->data[0] = ilow + 0.5 * step;
   for (i=1; i < s->nelems; i++, accum+=step )
-    s->cent->data[0][i] = s->cent->data[0][0] + accum;
+    s->cent->data[i] = s->cent->data[0] + accum;
 
   return s;
 }
@@ -70,45 +68,40 @@ void del_aubio_hist(aubio_hist_t *s) {
  * do it
  */
 void aubio_hist_do (aubio_hist_t *s, fvec_t *input) {
-  uint_t i,j;
+  uint_t j;
   sint_t tmp = 0;
   aubio_scale_do(s->scaler, input);
   /* reset data */
-  for (i=0; i < s->channels; i++)
-    for (j=0; j < s->nelems; j++)
-      s->hist->data[i][j] = 0;
+  fvec_zeros(s->hist);
   /* run accum */
-  for (i=0; i < input->channels; i++)
-    for (j=0;  j < input->length; j++)
-    {
-      tmp = (sint_t)FLOOR(input->data[i][j]);
-      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
-        s->hist->data[i][tmp] += 1;
+  for (j=0;  j < input->length; j++)
+  {
+    tmp = (sint_t)FLOOR(input->data[j]);
+    if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) {
+      s->hist->data[tmp] += 1;
     }
+  }
 }
 
 void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input) {
-  uint_t i,j;
+  uint_t j;
   sint_t tmp = 0;
   aubio_scale_do(s->scaler, input);
   /* reset data */
-  for (i=0; i < s->channels; i++)
-    for (j=0; j < s->nelems; j++)
-      s->hist->data[i][j] = 0;
+  fvec_zeros(s->hist);
   /* run accum */
-  for (i=0; i < input->channels; i++)
-    for (j=0;  j < input->length; j++) {
-      if (input->data[i][j] != 0) {
-        tmp = (sint_t)FLOOR(input->data[i][j]);
-        if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
-          s->hist->data[i][tmp] += 1;
-      }
+  for (j=0;  j < input->length; j++) {
+    if (input->data[j] != 0) {
+      tmp = (sint_t)FLOOR(input->data[j]);
+      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
+        s->hist->data[tmp] += 1;
     }
+  }
 }
 
 
 void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) {
-  uint_t i,j;
+  uint_t i;
   sint_t tmp = 0;
   smpl_t ilow = fvec_min(input);
   smpl_t ihig = fvec_max(input);
@@ -118,42 +111,37 @@ void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) {
   aubio_scale_set_limits (s->scaler, ilow, ihig, 0, s->nelems);
 
   /* recalculate centers */
-  s->cent->data[0][0] = ilow + 0.5f * step;
+  s->cent->data[0] = ilow + 0.5f * step;
   for (i=1; i < s->nelems; i++)
-    s->cent->data[0][i] = s->cent->data[0][0] + i * step;
+    s->cent->data[i] = s->cent->data[0] + i * step;
 
   /* scale */
   aubio_scale_do(s->scaler, input);
 
   /* reset data */
-  for (i=0; i < s->channels; i++)
-    for (j=0; j < s->nelems; j++)
-      s->hist->data[i][j] = 0;
+  fvec_zeros(s->hist);
   /* run accum */
-  for (i=0; i < input->channels; i++)
-    for (j=0;  j < input->length; j++) {
-      if (input->data[i][j] != 0) {
-        tmp = (sint_t)FLOOR(input->data[i][j]);
-        if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
-          s->hist->data[i][tmp] += 1;
-      }
+  for (i=0;  i < input->length; i++) {
+    if (input->data[i] != 0) {
+      tmp = (sint_t)FLOOR(input->data[i]);
+      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
+        s->hist->data[tmp] += 1;
     }
+  }
 }
 
 void aubio_hist_weight (aubio_hist_t *s) {
-  uint_t i,j;
-  for (i=0; i < s->channels; i++)
-    for (j=0; j < s->nelems; j++) {
-      s->hist->data[i][j] *= s->cent->data[0][j];
-    }
+  uint_t j;
+  for (j=0; j < s->nelems; j++) {
+    s->hist->data[j] *= s->cent->data[j];
+  }
 }
 
 smpl_t aubio_hist_mean (aubio_hist_t *s) {
-  uint_t i,j;
+  uint_t j;
   smpl_t tmp = 0.0;
-  for (i=0; i < s->channels; i++)
-    for (j=0; j < s->nelems; j++)
-      tmp += s->hist->data[i][j];
+  for (j=0; j < s->nelems; j++)
+    tmp += s->hist->data[j];
   return tmp/(smpl_t)(s->nelems);
 }
 
index 0cd1f99..62c52e7 100644 (file)
@@ -39,9 +39,8 @@ typedef struct _aubio_hist_t aubio_hist_t;
  * \param flow minimum input
  * \param fhig maximum input
  * \param nelems number of histogram columns
- * \param channels number of channels
  */
-aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems, uint_t channels);
+aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems);
 /** histogram deletion */
 void del_aubio_hist(aubio_hist_t *s);
 /** compute the histogram */
index 6fdeeab..83933f8 100644 (file)
@@ -69,13 +69,11 @@ uint_t aubio_scale_set_limits (aubio_scale_t *s, smpl_t ilow, smpl_t ihig,
 
 void aubio_scale_do (aubio_scale_t *s, fvec_t *input) 
 {
-  uint_t i, j;
-  for (i=0; i < input->channels; i++){
-    for (j=0;  j < input->length; j++){
-      input->data[i][j] -= s->ilow;
-      input->data[i][j] *= s->scaler;
-      input->data[i][j] += s->olow;
-    }
+  uint_t j;
+  for (j=0;  j < input->length; j++){
+    input->data[j] -= s->ilow;
+    input->data[j] *= s->scaler;
+    input->data[j] += s->olow;
   }
 }
 
index 66c9716..b52cee5 100644 (file)
@@ -8,11 +8,9 @@
 #define AUBIO_OP(OPNAME, OP, TYPE, OBJ) \
 void TYPE ## _ ## OPNAME (TYPE ## _t *o) \
 { \
-  uint_t i,j; \
-  for (i = 0; i < o->channels; i++) { \
-    for (j = 0; j < o->length; j++) { \
-      o->OBJ[i][j] = OP (o->OBJ[i][j]); \
-    } \
+  uint_t j; \
+  for (j = 0; j < o->length; j++) { \
+    o->OBJ[j] = OP (o->OBJ[j]); \
   } \
 }
 
@@ -34,21 +32,17 @@ AUBIO_OP_C_AND_F(round, ROUND)
 //AUBIO_OP_C_AND_F(pow, POW)
 void fvec_pow (fvec_t *s, smpl_t power)
 {
-  uint_t i,j;
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length; j++) {
-      s->data[i][j] = POW(s->data[i][j], power);
-    }
+  uint_t j;
+  for (j = 0; j < s->length; j++) {
+    s->data[j] = POW(s->data[j], power);
   }
 }
 
 void cvec_pow (cvec_t *s, smpl_t power)
 {
-  uint_t i,j;
-  for (i = 0; i < s->channels; i++) {
-    for (j = 0; j < s->length; j++) {
-      s->norm[i][j] = POW(s->norm[i][j], power);
-    }
+  uint_t j;
+  for (j = 0; j < s->length; j++) {
+    s->norm[j] = POW(s->norm[j], power);
   }
 }
 
index 7257765..38bfe05 100644 (file)
@@ -11,31 +11,25 @@ typedef float smpl_t;
 typedef char char_t;
 
 /* fvec */
-fvec_t * new_fvec(uint_t length, uint_t channels);
+fvec_t * new_fvec(uint_t length);
 void del_fvec(fvec_t *s);
-smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position);
-void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position);
-smpl_t * fvec_get_channel(fvec_t *s, uint_t channel);
-void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);
-smpl_t ** fvec_get_data(fvec_t *s);
+smpl_t fvec_read_sample(fvec_t *s, uint_t position);
+void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position);
+smpl_t * fvec_get_data(fvec_t *s);
 
 /* cvec */
-cvec_t * new_cvec(uint_t length, uint_t channels);
+cvec_t * new_cvec(uint_t length);
 void del_cvec(cvec_t *s);
-void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
-void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
-smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
-smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
-void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
-void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
-smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
-smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
-smpl_t ** cvec_get_norm(cvec_t *s);
-smpl_t ** cvec_get_phas(cvec_t *s);
+void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
+void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
+smpl_t cvec_read_norm(cvec_t *s, uint_t position);
+smpl_t cvec_read_phas(cvec_t *s, uint_t position);
+smpl_t * cvec_get_norm(cvec_t *s);
+smpl_t * cvec_get_phas(cvec_t *s);
 
 
 /* fft */
-aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels);
+aubio_fft_t * new_aubio_fft(uint_t size);
 void del_aubio_fft(aubio_fft_t * s);
 void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum);
 void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output);
@@ -49,22 +43,22 @@ void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum);
 void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec);
 
 /* filter */
-aubio_filter_t * new_aubio_filter(uint_t order, uint_t channels);
+aubio_filter_t * new_aubio_filter(uint_t order);
 void aubio_filter_do(aubio_filter_t * b, fvec_t * in);
 void aubio_filter_do_outplace(aubio_filter_t * b, fvec_t * in, fvec_t * out);
 void aubio_filter_do_filtfilt(aubio_filter_t * b, fvec_t * in, fvec_t * tmp);
 void del_aubio_filter(aubio_filter_t * b);
 
 /* a_weighting */
-aubio_filter_t * new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate);
+aubio_filter_t * new_aubio_filter_a_weighting (uint_t samplerate);
 uint_t aubio_filter_set_a_weighting (aubio_filter_t * b, uint_t samplerate);
 
 /* c_weighting */
-aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate);
+aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate);
 uint_t aubio_filter_set_c_weighting (aubio_filter_t * b, uint_t samplerate);
 
 /* biquad */
-aubio_filter_t * new_aubio_filter_biquad(lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3, uint_t channels);
+aubio_filter_t * new_aubio_filter_biquad(lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3);
 uint_t aubio_filter_set_biquad (aubio_filter_t * b, lsmp_t b1, lsmp_t b2, lsmp_t b3, lsmp_t a2, lsmp_t a3);
 
 /* mathutils */
@@ -93,14 +87,14 @@ void del_aubio_resampler(aubio_resampler_t *s);
 #endif /* HAVE_SAMPLERATE */
 
 /* pvoc */
-aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels);
+aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s);
 void del_aubio_pvoc(aubio_pvoc_t *pv);
 void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t *in, cvec_t * fftgrain);
 void aubio_pvoc_rdo(aubio_pvoc_t *pv, cvec_t * fftgrain, fvec_t *out);
 
 /* pitch detection */
 aubio_pitch_t *new_aubio_pitch (char *pitch_mode,
-    uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
+    uint_t bufsize, uint_t hopsize, uint_t samplerate);
 void aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
 uint_t aubio_pitch_set_tolerance(aubio_pitch_t *p, smpl_t thres);
 uint_t aubio_pitch_set_unit(aubio_pitch_t *p, char * pitch_unit);
@@ -108,7 +102,7 @@ void del_aubio_pitch(aubio_pitch_t * p);
 
 /* tempo */
 aubio_tempo_t * new_aubio_tempo (char_t * mode,
-    uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate);
+    uint_t buf_size, uint_t hop_size, uint_t samplerate);
 void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);
 uint_t aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence);
 uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold);
@@ -119,12 +113,11 @@ void del_aubio_tempo(aubio_tempo_t * o);
 /* specdesc */
 void aubio_specdesc_do (aubio_specdesc_t * o, cvec_t * fftgrain,
   fvec_t * desc);
-aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size,
-  uint_t channels); 
+aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size); 
 void del_aubio_specdesc (aubio_specdesc_t * o);
 
 /* peak picker */
-aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels);
+aubio_peakpicker_t * new_aubio_peakpicker();
 void aubio_peakpicker_do(aubio_peakpicker_t * p, fvec_t * in, fvec_t * out);
 fvec_t * aubio_peakpicker_get_thresholded_input(aubio_peakpicker_t * p);
 void del_aubio_peakpicker(aubio_peakpicker_t * p);
@@ -139,8 +132,8 @@ uint_t aubio_peakpicker_set_threshold(aubio_peakpicker_t * p, smpl_t threshold);
 aubio_sndfile_t * new_aubio_sndfile_ro (const char * inputfile);
 aubio_sndfile_t * new_aubio_sndfile_wo(aubio_sndfile_t * existingfile, const char * outputname);
 void aubio_sndfile_info(aubio_sndfile_t * file);
-int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t * write);
-int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t * read);
+int aubio_sndfile_write(aubio_sndfile_t * file, int frames, fvec_t ** write);
+int aubio_sndfile_read(aubio_sndfile_t * file, int frames, fvec_t ** read);
 int del_aubio_sndfile(aubio_sndfile_t * file);
 uint_t aubio_sndfile_channels(aubio_sndfile_t * file);
 uint_t aubio_sndfile_samplerate(aubio_sndfile_t * file);
index 62075b7..64915b2 100644 (file)
@@ -7,28 +7,27 @@ int main(){
   uint_t rates[] = { 8000, 16000, 22050, 44100, 96000, 192000};
   uint_t nrates = 6;
   uint_t samplerate, i = 0;
-  uint_t channels = 2;
 
   for ( samplerate = rates[i]; i < nrates ; i++ ) {
-    f = new_aubio_filter_a_weighting (channels, samplerate);
+    f = new_aubio_filter_a_weighting (samplerate);
     del_aubio_filter (f);
 
-    f = new_aubio_filter (7, channels*2);
+    f = new_aubio_filter (7);
     aubio_filter_set_a_weighting (f, samplerate);
     del_aubio_filter (f);
   }
 
   // samplerate unknown
-  f = new_aubio_filter_a_weighting (channels, 4200);
+  f = new_aubio_filter_a_weighting (4200);
   del_aubio_filter (f);
 
   // order to small
-  f = new_aubio_filter (2, channels*2);
+  f = new_aubio_filter (2);
   aubio_filter_set_a_weighting (f, samplerate);
   del_aubio_filter (f);
 
   // order to big
-  f = new_aubio_filter (12, channels*2);
+  f = new_aubio_filter (12);
   aubio_filter_set_a_weighting (f, samplerate);
   del_aubio_filter (f);
 
index 91770fe..d5283fc 100644 (file)
@@ -7,28 +7,27 @@ int main(){
   uint_t rates[] = { 8000, 16000, 22050, 44100, 96000, 192000};
   uint_t nrates = 6;
   uint_t samplerate, i = 0;
-  uint_t channels = 2;
 
   for ( samplerate = rates[i]; i < nrates ; i++ ) {
-    f = new_aubio_filter_c_weighting (channels, samplerate);
+    f = new_aubio_filter_c_weighting (samplerate);
     del_aubio_filter (f);
 
-    f = new_aubio_filter (5, channels*2);
+    f = new_aubio_filter (5);
     aubio_filter_set_c_weighting (f, samplerate);
     del_aubio_filter (f);
   }
 
   // samplerate unknown
-  f = new_aubio_filter_c_weighting (channels, 4200);
+  f = new_aubio_filter_c_weighting (4200);
   del_aubio_filter (f);
 
   // order to small
-  f = new_aubio_filter (2, channels*2);
+  f = new_aubio_filter (2);
   aubio_filter_set_c_weighting (f, samplerate);
   del_aubio_filter (f);
 
   // order to big
-  f = new_aubio_filter (12, channels*2);
+  f = new_aubio_filter (12);
   aubio_filter_set_c_weighting (f, samplerate);
   del_aubio_filter (f);
 
index 63794fe..e4ac6dc 100644 (file)
@@ -6,12 +6,11 @@
 int main(){
         /* 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 */
-        fvec_t * out      = new_fvec (win_s/4, channels);     /* input buffer */
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
+        fvec_t * out      = new_fvec (win_s/4);     /* input buffer */
   
         /* allocate fft and other memory space */
-        aubio_beattracking_t * tempo  = new_aubio_beattracking(win_s, channels);
+        aubio_beattracking_t * tempo  = new_aubio_beattracking(win_s);
 
         uint_t i = 0;
 
index 78d7318..6555cae 100644 (file)
@@ -3,9 +3,8 @@
 int main(){
         /* 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 */
-        aubio_filter_t * o = new_aubio_filter_biquad(0.3,0.2,0.1,0.2,0.3, channels);
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
+        aubio_filter_t * o = new_aubio_filter_biquad(0.3,0.2,0.1,0.2,0.3);
 
         aubio_filter_do_filtfilt(o,in,in);
         aubio_filter_do(o,in);
index e76471d..f2e5cf0 100644 (file)
@@ -3,8 +3,7 @@
 int main(){
         /* allocate some memory */
         uint_t win_s      = 1024;                       /* window size */
-        uint_t channels   = 1;                          /* number of channel */
-        cvec_t * sp       = new_cvec (win_s, channels); /* input buffer */
+        cvec_t * sp       = new_cvec (win_s); /* input buffer */
         del_cvec(sp);
 
         return 0;
index e43efa2..a17b977 100644 (file)
@@ -4,20 +4,19 @@
 int main(){
         /* allocate some memory */
         uint_t win_s      = 8;                       /* window size        */
-        uint_t channels   = 1;                        /* 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      */
-        in->data[0][0] = 1;
-        in->data[0][1] = 2;
-        in->data[0][2] = 3;
-        in->data[0][3] = 4;
-        in->data[0][4] = 5;
-        in->data[0][5] = 6;
-        in->data[0][6] = 5;
-        in->data[0][7] = 6;
+        fvec_t * in       = new_fvec (win_s); /* input buffer       */
+        cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
+        fvec_t * out      = new_fvec (win_s); /* output buffer      */
+        in->data[0] = 1;
+        in->data[1] = 2;
+        in->data[2] = 3;
+        in->data[3] = 4;
+        in->data[4] = 5;
+        in->data[5] = 6;
+        in->data[6] = 5;
+        in->data[7] = 6;
         /* allocate fft and other memory space */
-        aubio_fft_t * fft = new_aubio_fft(win_s,channels);
+        aubio_fft_t * fft = new_aubio_fft(win_s);
         /* fill input with some data */
         fvec_print(in);
         /* execute stft */
index 3ab11b7..84409d0 100644 (file)
@@ -5,27 +5,26 @@ main (void)
 {
   /* allocate some memory */
   uint_t win_s = 32;            /* window size */
-  uint_t channels = 1;          /* number of channel */
-  fvec_t *in = new_fvec (win_s, channels);      /* input buffer */
-  fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
+  fvec_t *in = new_fvec (win_s);      /* input buffer */
+  fvec_t *out = new_fvec (win_s);     /* input buffer */
 
 
-  aubio_filter_t *o = new_aubio_filter_c_weighting (channels, 44100);
-  in->data[0][12] = 0.5;
+  aubio_filter_t *o = new_aubio_filter_c_weighting (44100);
+  in->data[12] = 0.5;
   fvec_print (in);
   aubio_filter_do (o, in);
   fvec_print (in);
   del_aubio_filter (o);
 
-  o = new_aubio_filter_c_weighting (channels, 44100);
-  in->data[0][12] = 0.5;
+  o = new_aubio_filter_c_weighting (44100);
+  in->data[12] = 0.5;
   fvec_print (in);
   aubio_filter_do_outplace (o, in, out);
   fvec_print (out);
   del_aubio_filter (o);
 
-  o = new_aubio_filter_c_weighting (channels, 44100);
-  in->data[0][12] = 0.5;
+  o = new_aubio_filter_c_weighting (44100);
+  in->data[12] = 0.5;
   fvec_print (in);
   aubio_filter_do_filtfilt (o, in, out);
   fvec_print (out);
index 5a1d096..4ab3fcf 100644 (file)
@@ -8,11 +8,10 @@ main (void)
 {
   /* allocate some memory */
   uint_t win_s = 1024;          /* window size */
-  uint_t channels = 2;          /* number of channel */
   uint_t n_filters = 13;        /* number of filters */
-  cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
-  fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
-  fvec_t *coeffs = NULL;
+  cvec_t *in = new_cvec (win_s);      /* input buffer */
+  fvec_t *out = new_fvec (win_s);     /* input buffer */
+  fmat_t *coeffs = NULL;
 
   /* allocate fft and other memory space */
   aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);
@@ -22,6 +21,7 @@ main (void)
     return -1;
   }
 
+  /*
   if (fvec_max (coeffs) != 0.) {
     return -1;
   }
@@ -29,8 +29,9 @@ main (void)
   if (fvec_min (coeffs) != 0.) {
     return -1;
   }
+  */
 
-  fvec_print (coeffs);
+  fmat_print (coeffs);
 
   aubio_filterbank_do (o, in, out);
 
index 3e417f9..79001df 100644 (file)
@@ -8,11 +8,10 @@ main (void)
 {
   /* allocate some memory */
   uint_t win_s = 512;           /* fft size */
-  uint_t channels = 2;          /* number of channel */
   uint_t n_filters = 40;        /* number of filters */
-  cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
-  fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
-  fvec_t *coeffs = NULL;
+  cvec_t *in = new_cvec (win_s);      /* input buffer */
+  fvec_t *out = new_fvec (win_s);     /* input buffer */
+  fmat_t *coeffs = NULL;
   smpl_t samplerate = 16000.;
 
   /* allocate fft and other memory space */
@@ -26,7 +25,7 @@ main (void)
     return -1;
   }
 
-  //fvec_print (coeffs);
+  //fmat_print (coeffs);
 
   //fprintf(stderr, "%f\n", fvec_sum(coeffs));
 
index 8fa1f7c..d51feec 100644 (file)
@@ -3,8 +3,7 @@
 int main(){
         /* 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 */
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
         del_fvec(in);
 
         return 0;
index 5c87b50..9cd39e5 100644 (file)
@@ -7,7 +7,7 @@ int main( )
 {
   uint_t length;
   for (length = 1; length < 10; length ++ ) {
-    aubio_hist_t *o = new_aubio_hist(0, 1, length, 5);
+    aubio_hist_t *o = new_aubio_hist(0, 1, length);
     fvec_t *t = new_aubio_window("hanning", length);
     aubio_hist_do(o,t);
     fvec_print(t);
index a41f64b..c724d10 100644 (file)
@@ -5,11 +5,10 @@ main (void)
 {
   /* allocate some memory */
   uint_t win_s = 512;           /* fft size */
-  uint_t channels = 1;          /* number of channel */
   uint_t n_filters = 40;        /* number of filters */
   uint_t n_coefs = 13;          /* number of coefficients */
-  cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
-  fvec_t *out = new_fvec (n_coefs, channels);     /* input buffer */
+  cvec_t *in = new_cvec (win_s);      /* input buffer */
+  fvec_t *out = new_fvec (n_coefs);     /* input buffer */
   smpl_t samplerate = 16000.;
 
   /* allocate fft and other memory space */
index db94669..fd2ab2e 100644 (file)
@@ -3,10 +3,9 @@
 int main(){
         /* allocate some memory */
         uint_t win_s      = 1024;                       /* window size */
-        uint_t channels   = 1;                          /* number of channel */
-        fvec_t * in       = new_fvec (win_s/4, channels); /* input buffer */
-        fvec_t * out      = new_fvec (2, channels);     /* input buffer */
-        aubio_onset_t * onset  = new_aubio_onset("complex", win_s, win_s/4, channels, 44100.);
+        fvec_t * in       = new_fvec (win_s/4); /* input buffer */
+        fvec_t * out      = new_fvec (2);     /* input buffer */
+        aubio_onset_t * onset  = new_aubio_onset("complex", win_s, win_s/4, 44100.);
         uint_t i = 0;
 
         while (i < 10) {
index 8234d98..fe1b71b 100644 (file)
@@ -7,37 +7,36 @@ int
 main ()
 {
   uint_t win_s = 1024;          /* window size */
-  uint_t channels = 1;          /* number of channel */
-  cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
-  fvec_t *out = new_fvec (1, channels); /* input buffer */
+  cvec_t *in = new_cvec (win_s);      /* input buffer */
+  fvec_t *out = new_fvec (1); /* input buffer */
 
   aubio_specdesc_t *o;
   
-  o = new_aubio_specdesc ("energy", win_s, channels);
+  o = new_aubio_specdesc ("energy", win_s);
   aubio_specdesc_do (o, in, out);
   del_aubio_specdesc (o);
 
-  o = new_aubio_specdesc ("energy", win_s, channels);
+  o = new_aubio_specdesc ("energy", win_s);
   aubio_specdesc_do (o, in, out);
   del_aubio_specdesc (o);
 
-  o = new_aubio_specdesc ("hfc", win_s, channels);
+  o = new_aubio_specdesc ("hfc", win_s);
   aubio_specdesc_do (o, in, out);
   del_aubio_specdesc (o);
 
-  o = new_aubio_specdesc ("complex", win_s, channels);
+  o = new_aubio_specdesc ("complex", win_s);
   aubio_specdesc_do (o, in, out);
   del_aubio_specdesc (o);
 
-  o = new_aubio_specdesc ("phase", win_s, channels);
+  o = new_aubio_specdesc ("phase", win_s);
   aubio_specdesc_do (o, in, out);
   del_aubio_specdesc (o);
 
-  o = new_aubio_specdesc ("kl", win_s, channels);
+  o = new_aubio_specdesc ("kl", win_s);
   aubio_specdesc_do (o, in, out);
   del_aubio_specdesc (o);
 
-  o = new_aubio_specdesc ("mkl", win_s, channels);
+  o = new_aubio_specdesc ("mkl", win_s);
   aubio_specdesc_do (o, in, out);
   del_aubio_specdesc (o);
 
index 1e44318..42aff7d 100644 (file)
@@ -5,9 +5,8 @@
 int main(){
         /* 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 */
-        fvec_t * out      = new_fvec (1, channels); /* input buffer */
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
+        fvec_t * out      = new_fvec (1); /* input buffer */
         aubio_peakpicker_t * o = new_aubio_peakpicker(1);
         aubio_peakpicker_set_threshold (o, 0.3);
 
index cd5753a..d42bdd3 100644 (file)
@@ -21,21 +21,24 @@ uint_t midiin   = 4;  /* number of midi input channels     */
 uint_t midiout  = 2;  /* number of midi output channels    */
 uint_t pos      = 0;  /* frames%dspblocksize for jack loop */
 
-fvec_t * in;
-cvec_t * fftgrain;
-fvec_t * out;
+fvec_t * in[2];
+cvec_t * fftgrain[2];
+fvec_t * out[2];
 
-aubio_pvoc_t * pv;
+aubio_pvoc_t * pv[2];
 
 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      */
+  uint_t i;
+    for (i=0;i<channels;i++) {
+        in[i]       = new_fvec (hop_s); /* input buffer       */
+        fftgrain[i] = new_cvec (win_s); /* fft norm and phase */
+        out[i]      = new_fvec (hop_s); /* output buffer      */
         /* allocate fft and other memory space */
-        pv = new_aubio_pvoc(win_s,hop_s,channels);
+        pv[i] = new_aubio_pvoc(win_s,hop_s);
+    }
 
 #ifdef HAVE_JACK
         aubio_jack_t * jack_setup;
@@ -52,10 +55,12 @@ int main(){
         fprintf(stderr, "WARNING: no jack support\n");
 #endif
         
-        del_aubio_pvoc(pv);
-        del_cvec(fftgrain);
-        del_fvec(in);
-        del_fvec(out);
+    for (i=0;i<channels;i++) {
+        del_aubio_pvoc(pv[i]);
+        del_cvec(fftgrain[i]);
+        del_fvec(in[i]);
+        del_fvec(out[i]);
+    }
         aubio_cleanup();
         return 0;
 }
@@ -66,25 +71,27 @@ int aubio_process(float **input, float **output, int nframes) {
   for (j=0;j<(unsigned)nframes;j++) {
     for (i=0;i<channels;i++) {
       /* write input to datanew */
-      fvec_write_sample(in, input[i][j], i, pos);
+      fvec_write_sample(in[i], input[i][j], pos);
       /* put synthnew in output */
-      output[i][j] = fvec_read_sample(out, i, pos);
+      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<channels;i++) {
+      aubio_pvoc_do (pv[i], in[i], fftgrain[i]);
       // zero phases of first channel
-      for (i=0;i<fftgrain->length;i++) fftgrain->phas[0][i] = 0.; 
+      for (i=0;i<fftgrain[i]->length;i++) fftgrain[0]->phas[i] = 0.; 
       // double phases of second channel
-      for (i=0;i<fftgrain->length;i++) {
-        fftgrain->phas[1][i] = 
-          aubio_unwrap2pi (fftgrain->phas[1][i] * 2.); 
+      for (i=0;i<fftgrain[i]->length;i++) {
+        fftgrain[1]->phas[i] = 
+          aubio_unwrap2pi (fftgrain[1]->phas[i] * 2.); 
       }
       // copy second channel to third one
-      aubio_pvoc_rdo(pv,fftgrain,out);
+      aubio_pvoc_rdo(pv[i], fftgrain[i], out[i]);
       pos = -1;
     }
+    }
     pos++;
   }
   return 0;
index e8352ab..6bea4c3 100644 (file)
@@ -6,13 +6,12 @@
 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      */
+        fvec_t * in       = new_fvec (hop_s); /* input buffer       */
+        cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
+        fvec_t * out      = new_fvec (hop_s); /* output buffer      */
         /* allocate fft and other memory space */
-        aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s,channels);
+        aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
         /* fill input with some data */
         printf("initialised\n");
         /* execute stft */
index 7872b86..ac884c6 100644 (file)
@@ -7,11 +7,10 @@ main ()
   uint_t win_s = 1024;          /* window size */
   uint_t hop_s = win_s / 4;     /* hop size */
   uint_t samplerate = 44100;    /* samplerate */
-  uint_t channels = 1;          /* number of channel */
-  fvec_t *in = new_fvec (hop_s, channels);      /* input buffer */
-  fvec_t *out = new_fvec (1, channels); /* input buffer */
+  fvec_t *in = new_fvec (hop_s);      /* input buffer */
+  fvec_t *out = new_fvec (1); /* input buffer */
   aubio_pitch_t *o =
-      new_aubio_pitch ("default", win_s, hop_s, channels, samplerate);
+      new_aubio_pitch ("default", win_s, hop_s, samplerate);
   uint_t i = 0;
 
   while (i < 100) {
index a6fb74a..dda6099 100644 (file)
@@ -6,11 +6,10 @@ int main(){
         /* allocate some memory */
         uint_t win_s      = 1024;                       /* window size */
         uint_t hop_s      = win_s/4;                    /* hop size */
-        uint_t channels   = 3;                          /* number of channel */
-        fvec_t * in       = new_fvec (hop_s, channels); /* input buffer */
-        fvec_t * out      = new_fvec (1, channels);
+        fvec_t * in       = new_fvec (hop_s); /* input buffer */
+        fvec_t * out      = new_fvec (1);
         aubio_pitchfcomb_t * o  = new_aubio_pitchfcomb (
-          win_s, hop_s, channels);
+          win_s, hop_s);
         uint_t i = 0;
 
         while (i < 2) {
index aaecc3d..7d3cb16 100644 (file)
@@ -6,11 +6,10 @@ int main(){
         /* allocate some memory */
         uint_t win_s      = 1024;                       /* window size */
         uint_t hop_s      = win_s/4;                    /* hop size */
-        uint_t channels   = 1;                          /* number of channel */
-        cvec_t * in       = new_cvec (win_s, channels); /* input buffer */
-        fvec_t * out      = new_fvec (1, channels); /* input buffer */
+        cvec_t * in       = new_cvec (win_s); /* input buffer */
+        fvec_t * out      = new_fvec (1); /* input buffer */
 
-        aubio_pitchmcomb_t * o  = new_aubio_pitchmcomb(win_s, hop_s, channels);
+        aubio_pitchmcomb_t * o  = new_aubio_pitchmcomb(win_s, hop_s);
         uint_t i = 0;
 
         while (i < 1000) {
index 08500a7..745feca 100644 (file)
@@ -5,8 +5,8 @@
 int main(){
         /* allocate some memory */
         uint_t win_s      = 1024;                       /* window size */
-        fvec_t * in       = new_fvec (win_s, 1); /* input buffer */
-        fvec_t * out = new_fvec (1, 1); /* input buffer */
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
+        fvec_t * out = new_fvec (1); /* input buffer */
         aubio_pitchschmitt_t * o  = new_aubio_pitchschmitt(win_s);
         uint_t i = 0;
 
index 719c30f..1e256e8 100644 (file)
@@ -5,9 +5,8 @@
 int main(){
         /* 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 */
-        fvec_t * out      = new_fvec (win_s/2, channels); /* input buffer */
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
+        fvec_t * out      = new_fvec (win_s/2); /* input buffer */
         aubio_pitchyin_t *p = new_aubio_pitchyin (win_s);
         uint_t i = 0;
 
index 93bb0ce..96939ce 100644 (file)
@@ -5,9 +5,8 @@
 int main(){
         /* 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 */
-        fvec_t * out      = new_fvec (1, channels); /* output pitch periods */
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
+        fvec_t * out      = new_fvec (1); /* output pitch periods */
         aubio_pitchyinfft_t * o  = new_aubio_pitchyinfft(win_s);
         aubio_pitchyinfft_set_tolerance (o, 0.2);
         uint_t i = 0;
index c8d08c8..b28bf9a 100644 (file)
@@ -6,10 +6,9 @@ main ()
 {
   /* allocate some memory */
   uint_t win_s = 1024;          /* window size */
-  uint_t channels = 1;          /* number of channel */
   smpl_t ratio = 0.5;
-  fvec_t *in = new_fvec (win_s, channels);      /* input buffer */
-  fvec_t *out = new_fvec ((uint_t) (win_s * ratio), channels);  /* input buffer */
+  fvec_t *in = new_fvec (win_s);      /* input buffer */
+  fvec_t *out = new_fvec ((uint_t) (win_s * ratio));  /* input buffer */
   aubio_resampler_t *o = new_aubio_resampler (0.5, 0);
   uint_t i = 0;
 
index 3fc7202..3f94eb2 100644 (file)
@@ -5,8 +5,7 @@
 int main(){
         /* 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 */
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
         aubio_scale_t * o = new_aubio_scale(0,1,2,3);
         aubio_scale_set_limits (o,0,1,2,3);
         uint_t i = 0;
index b2d636a..3a6c283 100644 (file)
@@ -4,10 +4,9 @@
 int main(){
         /* 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 */
-        fvec_t * out      = new_fvec (2, channels);     /* input buffer */
-        aubio_tempo_t * o  = new_aubio_tempo("complex", win_s, win_s/4, channels, 44100.);
+        fvec_t * in       = new_fvec (win_s); /* input buffer */
+        fvec_t * out      = new_fvec (2);     /* input buffer */
+        aubio_tempo_t * o  = new_aubio_tempo("complex", win_s, win_s/4, 44100.);
         uint_t i = 0;
 
         smpl_t curtempo, curtempoconf;
index b8ac41c..0040168 100644 (file)
@@ -13,20 +13,19 @@ int main(){
        int i;
         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 */
-        cvec_t * cstead   = new_cvec (win_s, channels); /* fft norm and phase */
-        cvec_t * ctrans   = new_cvec (win_s, channels); /* fft norm and phase */
-        fvec_t * stead    = new_fvec (hop_s, channels); /* output buffer      */
-        fvec_t * trans    = new_fvec (hop_s, channels); /* output buffer      */
+        fvec_t * in       = new_fvec (hop_s); /* input buffer       */
+        cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
+        cvec_t * cstead   = new_cvec (win_s); /* fft norm and phase */
+        cvec_t * ctrans   = new_cvec (win_s); /* fft norm and phase */
+        fvec_t * stead    = new_fvec (hop_s); /* output buffer      */
+        fvec_t * trans    = new_fvec (hop_s); /* output buffer      */
         /* allocate fft and other memory space */
-        aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s,channels);
-        aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s,channels);
-        aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels);
+        aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
+        aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
+        aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);
 
-       aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s,channels);
+       aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
         /* fill input with some data */
         printf("initialised\n");
         /* execute stft */