*/
struct _aubio_hist_t {
- /*bug: move to a fvec */
- smpl_t ** hist;
+ fvec_t * hist;
uint_t nelems;
uint_t channels;
smpl_t * cent;
uint_t i;
s->channels = channels;
s->nelems = nelems;
- s->hist = AUBIO_ARRAY(smpl_t*, channels);
- for (i=0; i< s->channels; i++) {
- s->hist[i] = AUBIO_ARRAY(smpl_t, nelems);
- }
+ s->hist = new_fvec(nelems, channels);
s->cent = AUBIO_ARRAY(smpl_t, nelems);
/* use scale to map ilow/ihig -> 0/nelems */
}
void del_aubio_hist(aubio_hist_t *s) {
- uint_t i;
- for (i=0; i< s->channels; i++) {
- AUBIO_FREE(s->hist[i]);
- }
- AUBIO_FREE(s->hist);
+ del_fvec(s->hist);
AUBIO_FREE(s->cent);
del_aubio_scale(s->scaler);
AUBIO_FREE(s);
/* reset data */
for (i=0; i < s->channels; i++)
for (j=0; j < s->nelems; j++)
- s->hist[i][j] = 0;
+ s->hist->data[i][j] = 0;
/* run accum */
for (i=0; i < input->channels; i++)
for (j=0; j < input->length; j++)
{
tmp = (sint_t)FLOOR(input->data[i][j]);
if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
- s->hist[i][tmp] += 1;
+ s->hist->data[i][tmp] += 1;
}
}
/* reset data */
for (i=0; i < s->channels; i++)
for (j=0; j < s->nelems; j++)
- s->hist[i][j] = 0;
+ s->hist->data[i][j] = 0;
/* run accum */
for (i=0; i < input->channels; i++)
for (j=0; j < input->length; j++)
if (input->data[i][j] != 0) {
tmp = (sint_t)FLOOR(input->data[i][j]);
if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
- s->hist[i][tmp] += 1;
+ s->hist->data[i][tmp] += 1;
}
}
}
/* reset data */
for (i=0; i < s->channels; i++)
for (j=0; j < s->nelems; j++)
- s->hist[i][j] = 0;
+ s->hist->data[i][j] = 0;
/* run accum */
for (i=0; i < input->channels; i++)
for (j=0; j < input->length; j++)
if (input->data[i][j] != 0) {
tmp = (sint_t)FLOOR(input->data[i][j]);
if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
- s->hist[i][tmp] += 1;
+ s->hist->data[i][tmp] += 1;
}
}
}
-void aubio_hist_weigth (aubio_hist_t *s)
+void aubio_hist_weight (aubio_hist_t *s)
{
uint_t i,j;
for (i=0; i < s->channels; i++)
for (j=0; j < s->nelems; j++) {
- s->hist[i][j] *= s->cent[j];
+ s->hist->data[i][j] *= s->cent[j];
}
}
smpl_t tmp = 0.0f;
for (i=0; i < s->channels; i++)
for (j=0; j < s->nelems; j++)
- tmp += s->hist[i][j];
+ tmp += s->hist->data[i][j];
return tmp/(smpl_t)(s->nelems);
}
/* apply o->histogram */
aubio_hist_dyn_notnull(o->histog,o->dev1);
/* weight it */
- aubio_hist_weigth(o->histog);
+ aubio_hist_weight(o->histog);
/* its mean is the result */
onset->data[i][0] = aubio_hist_mean(o->histog);
//onset->data[i][0] = vec_mean(o->dev1);
* overall function)*/
aubio_hist_dyn_notnull(o->histog,o->dev1);
/* weight it */
- aubio_hist_weigth(o->histog);
+ aubio_hist_weight(o->histog);
/* its mean is the result */
onset->data[i][0] = aubio_hist_mean(o->histog);