[filterbank] fix get_power
[aubio.git] / src / spectral / filterbank.c
index 5497a4f..e82d93d 100644 (file)
@@ -42,6 +42,15 @@ new_aubio_filterbank (uint_t n_filters, uint_t win_s)
 {
   /* allocate space for filterbank object */
   aubio_filterbank_t *fb = AUBIO_NEW (aubio_filterbank_t);
+
+  if ((sint_t)n_filters <= 0) {
+    AUBIO_ERR("filterbank: n_filters should be > 0, got %d\n", n_filters);
+    goto fail;
+  }
+  if ((sint_t)win_s <= 0) {
+    AUBIO_ERR("filterbank: win_s should be > 0, got %d\n", win_s);
+    goto fail;
+  }
   fb->win_s = win_s;
   fb->n_filters = n_filters;
 
@@ -53,6 +62,9 @@ new_aubio_filterbank (uint_t n_filters, uint_t win_s)
   fb->power = 1;
 
   return fb;
+fail:
+  AUBIO_FREE (fb);
+  return NULL;
 }
 
 void
@@ -118,5 +130,5 @@ aubio_filterbank_set_power (aubio_filterbank_t *f, smpl_t power)
 smpl_t
 aubio_filterbank_get_power (aubio_filterbank_t *f)
 {
-  return f->norm;
+  return f->power;
 }