src/temporal: switch to mono
authorPaul Brossier <piem@piem.org>
Fri, 4 Dec 2009 00:39:30 +0000 (01:39 +0100)
committerPaul Brossier <piem@piem.org>
Fri, 4 Dec 2009 00:39:30 +0000 (01:39 +0100)
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

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 */