shithub: aubio

Download patch

ref: 812b376c958b72e57bd5e21c1c8e29644b011809
parent: 274839fbaabb20bb8ad05ef54855dcf5ea85bd49
author: Paul Brossier <[email protected]>
date: Sun Nov 4 11:44:54 EST 2007

hist.c: move hist cent to a structure

--- a/src/hist.c
+++ b/src/hist.c
@@ -30,7 +30,7 @@
 	fvec_t * hist;
 	uint_t nelems;
 	uint_t channels;
-	smpl_t * cent;
+	fvec_t * cent;
 	aubio_scale_t *scaler;
 };
 
@@ -45,14 +45,14 @@
 	s->channels = channels;
 	s->nelems = nelems;
   s->hist = new_fvec(nelems, channels);
-	s->cent = AUBIO_ARRAY(smpl_t, nelems);
+	s->cent = new_fvec(nelems, 1);
 	
 	/* use scale to map ilow/ihig -> 0/nelems */
 	s->scaler = new_aubio_scale(ilow,ihig,0,nelems);
 	/* calculate centers now once */
-	s->cent[0] = ilow + 0.5 * step;
+	s->cent->data[0][0] = ilow + 0.5 * step;
 	for (i=1; i < s->nelems; i++, accum+=step )
-		s->cent[i] = s->cent[0] + accum;
+		s->cent->data[0][i] = s->cent->data[0][0] + accum;
 	
 	return s;	
 }
@@ -59,7 +59,7 @@
 
 void del_aubio_hist(aubio_hist_t *s) {
   del_fvec(s->hist);
-	AUBIO_FREE(s->cent);
+	del_fvec(s->cent);
 	del_aubio_scale(s->scaler);
 	AUBIO_FREE(s);
 }
@@ -120,9 +120,9 @@
 	aubio_scale_set(s->scaler, ilow, ihig, 0, s->nelems);
 
 	/* recalculate centers */
-	s->cent[0] = ilow + 0.5f * step;
+	s->cent->data[0][0] = ilow + 0.5f * step;
 	for (i=1; i < s->nelems; i++)
-		s->cent[i] = s->cent[0] + i * step;
+		s->cent->data[0][i] = s->cent->data[0][0] + i * step;
 
 	/* scale */	
 	aubio_scale_do(s->scaler, input);
@@ -148,7 +148,7 @@
 	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[j];
+			s->hist->data[i][j] *= s->cent->data[0][j];
 		}
 }