Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/mathutils.c

    r33cd81f r729a3c0  
    4444
    4545fvec_t *
    46 new_aubio_window (char_t * window_type, uint_t length)
    47 {
    48   fvec_t * win = new_fvec (length);
    49   fvec_set_window (win, window_type);
    50   return win;
    51 }
    52 
    53 uint_t fvec_set_window (fvec_t *win, char_t *window_type) {
     46new_aubio_window (char_t * window_type, uint_t size)
     47{
     48  fvec_t * win = new_fvec (size);
    5449  smpl_t * w = win->data;
    55   uint_t i, size = win->length;
     50  uint_t i;
    5651  aubio_window_type wintype;
    57   if (window_type == NULL) {
    58       AUBIO_ERR ("window type can not be null.\n");
    59       return 1;
    60   } else if (strcmp (window_type, "rectangle") == 0)
     52  if (strcmp (window_type, "rectangle") == 0)
    6153      wintype = aubio_win_rectangle;
    6254  else if (strcmp (window_type, "hamming") == 0)
     
    7971      wintype = aubio_win_default;
    8072  else {
    81       AUBIO_ERR ("unknown window type `%s`.\n", window_type);
    82       return 1;
     73      AUBIO_ERR ("unknown window type %s, using default.\n", window_type);
     74      wintype = aubio_win_default;
    8375  }
    8476  switch(wintype) {
     
    113105      break;
    114106    case aubio_win_gaussian:
    115       {
    116         lsmp_t a, b, c = 0.5;
    117         uint_t n;
    118         for (n = 0; n < size; n++)
    119         {
    120           a = (n-c*(size-1))/(SQR(c)*(size-1));
    121           b = -c*SQR(a);
    122           w[n] = EXP(b);
    123         }
    124       }
     107      for (i=0;i<size;i++)
     108        w[i] = EXP(- 1.0 / SQR(size) * SQR(2.0*i-size));
    125109      break;
    126110    case aubio_win_welch:
    127111      for (i=0;i<size;i++)
    128         w[i] = 1.0 - SQR((2.*i-size)/(size+1.0));
     112        w[i] = 1.0 - SQR((2*i-size)/(size+1.0));
    129113      break;
    130114    case aubio_win_parzen:
    131115      for (i=0;i<size;i++)
    132         w[i] = 1.0 - ABS((2.*i-size)/(size+1.0));
     116        w[i] = 1.0 - ABS((2*i-size)/(size+1.0));
    133117      break;
    134118    default:
    135119      break;
    136120  }
    137   return 0;
     121  return win;
    138122}
    139123
Note: See TracChangeset for help on using the changeset viewer.