Changeset a7667ce


Ignore:
Timestamp:
Dec 1, 2007, 10:59:25 PM (16 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
6913434
Parents:
2b6144dd
Message:

filter.c: add denormal, make multichannel using lvecs, update adsgn, cdsgn, pitchdetection

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitchdetection.c

    r2b6144dd ra7667ce  
    2222#include "spectral/phasevoc.h"
    2323#include "mathutils.h"
    24 #include "temporal/filter.h"
     24#include "temporal/cdesign.h"
    2525#include "pitch/pitchmcomb.h"
    2626#include "pitch/pitchyin.h"
     
    103103      p->fftgrain = new_cvec(bufsize, channels);
    104104      p->mcomb    = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate);
    105       p->filter   = new_aubio_cdsgn_filter(samplerate);
     105      p->filter   = new_aubio_cdsgn_filter(samplerate, channels);
    106106      p->callback = aubio_pitchdetection_mcomb;
    107107      break;
  • src/temporal/adesign.c

    r2b6144dd ra7667ce  
    2626#include "temporal/adesign.h"
    2727
    28 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate) {
    29   aubio_filter_t * f = new_aubio_filter(samplerate, 7);
    30   lsmp_t * a = f->a;
    31   lsmp_t * b = f->b;
     28aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate, uint_t channels) {
     29  aubio_filter_t * f = new_aubio_filter(samplerate, 7, channels);
     30  lsmp_t * a = f->a->data[0];
     31  lsmp_t * b = f->b->data[0];
    3232  /* uint_t l; */
    3333  /* for now, 44100, adsgn */
     
    5252  }
    5353  */
    54   f->a = a;
    55   f->b = b;
     54  f->a->data[0] = a;
     55  f->b->data[0] = b;
    5656  return f;
    5757}
  • src/temporal/adesign.h

    r2b6144dd ra7667ce  
    2323
    2424*/
    25 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate);
     25aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate, uint_t channels);
    2626
    2727#define aubio_adsgn_filter_do aubio_filter_do
  • src/temporal/cdesign.c

    r2b6144dd ra7667ce  
    2626#include "temporal/adesign.h"
    2727
    28 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate) {
    29   aubio_filter_t * f = new_aubio_filter(samplerate, 5);
    30   lsmp_t * a = f->a;
    31   lsmp_t * b = f->b;
     28aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate, uint_t channels) {
     29  aubio_filter_t * f = new_aubio_filter(samplerate, 5, channels);
     30  lsmp_t * a = f->a->data[0];
     31  lsmp_t * b = f->b->data[0];
    3232  /* uint_t l; */
    3333  /* for now, 44100, cdsgn */
     
    4848  }
    4949  */
    50   f->a = a;
    51   f->b = b;
     50  f->a->data[0] = a;
     51  f->b->data[0] = b;
    5252  return f;
    5353}
  • src/temporal/cdesign.h

    r2b6144dd ra7667ce  
    2525
    2626*/
    27 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate);
     27aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate, uint_t channels);
    2828
    2929#define aubio_cdsgn_filter_do aubio_filter_do
  • src/temporal/filter.c

    r2b6144dd ra7667ce  
    2424#include "aubio_priv.h"
    2525#include "fvec.h"
     26#include "lvec.h"
    2627#include "mathutils.h"
    2728#include "temporal/filter.h"
    2829#include "temporal/filter_priv.h"
    2930
    30 /* bug: mono only */
    3131void aubio_filter_do(aubio_filter_t * f, fvec_t * in) {
    32   uint_t i,j,l, order = f->order;
    33   lsmp_t *x = f->x;
    34   lsmp_t *y = f->y;
    35   lsmp_t *a = f->a;
    36   lsmp_t *b = f->b;
    37   i=0;//for (i=0;i<in->channels;i++) {
    38   for (j = 0; j < in->length; j++) {
    39     /* new input */
    40     //AUBIO_DBG("befor %f\t", in->data[i][j]);
    41     x[0] = in->data[i][j];
    42     y[0] = b[0] * x[0];
    43     for (l=1;l<order; l++) {
    44       y[0] += b[l] * x[l];
    45       y[0] -= a[l] * y[l];
    46     } /* + 1e-37; for denormal ? */
    47     /* new output */
    48     in->data[i][j] = y[0];
    49     //AUBIO_DBG("after %f\n", in->data[i][j]);
    50     /* store states for next sample */
    51     for (l=order-1; l>0; l--){
    52       x[l] = x[l-1];
    53       y[l] = y[l-1];
    54     }
    55   }
    56   /* store states for next buffer */
    57   f->x = x;
    58   f->y = y;
    59   //}   
     32  aubio_filter_do_outplace(f, in, in);
    6033}
    6134
    6235void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) {
    6336  uint_t i,j,l, order = f->order;
    64   lsmp_t *x = f->x;
    65   lsmp_t *y = f->y;
    66   lsmp_t *a = f->a;
    67   lsmp_t *b = f->b;
     37  lsmp_t *x;
     38  lsmp_t *y;
     39  lsmp_t *a = f->a->data[0];
     40  lsmp_t *b = f->b->data[0];
    6841
    69   i=0; // works in mono only !!!
    70   //for (i=0;i<in->channels;i++) {
    71   for (j = 0; j < in->length; j++) {
    72     /* new input */
    73     x[0] = in->data[i][j];
    74     y[0] = b[0] * x[0];
    75     for (l=1;l<order; l++) {
    76       y[0] += b[l] * x[l];
    77       y[0] -= a[l] * y[l];
     42  for (i = 0; i < in->channels; i++) {
     43    x = f->x->data[i];
     44    y = f->y->data[i];
     45    for (j = 0; j < in->length; j++) {
     46      /* new input */
     47      if (ISDENORMAL(in->data[i][j])) {
     48        x[0] = y[0] = 0.;
     49      } else {
     50        x[0] = in->data[i][j];
     51        y[0] = b[0] * x[0];
     52        for (l=1;l<order; l++) {
     53          y[0] += b[l] * x[l];
     54          y[0] -= a[l] * y[l];
     55        }
     56      }
     57      /* new output */
     58      out->data[i][j] = y[0];
     59      /* store for next sample */
     60      for (l=order-1; l>0; l--){
     61        x[l] = x[l-1];
     62        y[l] = y[l-1];
     63      }
    7864    }
    79     // + 1e-37;
    80     /* new output */
    81     out->data[i][j] = y[0];
    82     /* store for next sample */
    83     for (l=order-1; l>0; l--){
    84       x[l] = x[l-1];
    85       y[l] = y[l-1];
    86     }
     65    /* store for next run */
     66    f->x->data[i] = x;
     67    f->y->data[i] = y;
    8768  }
    88   /* store for next run */
    89   f->x = x;
    90   f->y = y;
    91   //}
    9269}
    9370
     
    126103}
    127104
    128 aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order) {
     105aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order, uint_t channels) {
    129106  aubio_filter_t * f = AUBIO_NEW(aubio_filter_t);
    130   lsmp_t * x = f->x;
    131   lsmp_t * y = f->y;
    132   lsmp_t * a = f->a;
    133   lsmp_t * b = f->b;
    134   uint_t l;
     107  f->x = new_lvec(order, channels);
     108  f->y = new_lvec(order, channels);
     109  f->a = new_lvec(order, 1);
     110  f->b = new_lvec(order, 1);
     111  f->a->data[0][1] = 1.;
    135112  f->order = order;
    136   a = AUBIO_ARRAY(lsmp_t,f->order);
    137   b = AUBIO_ARRAY(lsmp_t,f->order);
    138   x = AUBIO_ARRAY(lsmp_t,f->order);
    139   y = AUBIO_ARRAY(lsmp_t,f->order);
    140   /* initial states to zeros */
    141   for (l=0; l<f->order; l++){
    142     x[l] = 0.;
    143     y[l] = 0.;
    144   }
    145   f->x = x;
    146   f->y = y;
    147   f->a = a;
    148   f->b = b;
    149113  return f;
    150114}
  • src/temporal/filter.h

    r2b6144dd ra7667ce  
    6969  \param samplerate signal sampling rate
    7070  \param order order of the filter (number of coefficients)
     71  \param channels number of channels to allocate
    7172
    7273*/
    73 aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order);
     74aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels);
    7475/** delete a filter object
    7576 
  • src/temporal/filter_priv.h

    r2b6144dd ra7667ce  
    1818*/
    1919
     20#include "lvec.h"
    2021struct _aubio_filter_t {
    2122  uint_t order;
    22   lsmp_t * a;
    23   lsmp_t * b;
    24   lsmp_t * y;
    25   lsmp_t * x;
     23  lvec_t * a;
     24  lvec_t * b;
     25  lvec_t * y;
     26  lvec_t * x;
    2627};
    2728
  • swig/aubio.i

    r2b6144dd ra7667ce  
    8686
    8787/* filter */
    88 extern aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order);
    89 extern aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate);
     88extern aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels);
    9089extern void aubio_filter_do(aubio_filter_t * b, fvec_t * in);
    9190extern void aubio_filter_do_outplace(aubio_filter_t * b, fvec_t * in, fvec_t * out);
     
    9392extern void del_aubio_filter(aubio_filter_t * b);
    9493
    95 extern aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate);
     94extern aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate, uint_t channels);
    9695extern void aubio_adsgn_filter_do(aubio_filter_t * b, fvec_t * in);
    9796extern void del_aubio_adsgn_filter(aubio_filter_t * b);
    9897
    99 extern aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate);
     98extern aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate, uint_t channels);
    10099extern void aubio_cdsgn_filter_do(aubio_filter_t * b, fvec_t * in);
    101100extern void del_aubio_cdsgn_filter(aubio_filter_t * b);
Note: See TracChangeset for help on using the changeset viewer.