Changeset 274839f


Ignore:
Timestamp:
Nov 4, 2007, 4:14:31 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:
812b376
Parents:
2b3280a
Message:

hist.c: move hist data to a structure, rename aubio_hist_weigth to aubio_hist_weight

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/hist.c

    r2b3280a r274839f  
    2828
    2929struct _aubio_hist_t {
    30         /*bug: move to a fvec */
    31         smpl_t ** hist;
     30        fvec_t * hist;
    3231        uint_t nelems;
    3332        uint_t channels;
     
    4645        s->channels = channels;
    4746        s->nelems = nelems;
    48         s->hist = AUBIO_ARRAY(smpl_t*, channels);
    49         for (i=0; i< s->channels; i++) {
    50                 s->hist[i] = AUBIO_ARRAY(smpl_t, nelems);
    51         }
     47  s->hist = new_fvec(nelems, channels);
    5248        s->cent = AUBIO_ARRAY(smpl_t, nelems);
    5349       
     
    6359
    6460void del_aubio_hist(aubio_hist_t *s) {
    65         uint_t i;
    66         for (i=0; i< s->channels; i++) {
    67                 AUBIO_FREE(s->hist[i]);
    68         }
    69         AUBIO_FREE(s->hist);
     61  del_fvec(s->hist);
    7062        AUBIO_FREE(s->cent);
    7163        del_aubio_scale(s->scaler);
     
    8476        for (i=0; i < s->channels; i++)
    8577                for (j=0; j < s->nelems; j++)
    86                         s->hist[i][j] = 0;
     78                        s->hist->data[i][j] = 0;
    8779        /* run accum */
    8880        for (i=0; i < input->channels; i++)
     
    9183                        tmp = (sint_t)FLOOR(input->data[i][j]);
    9284                        if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    93                                 s->hist[i][tmp] += 1;
     85                                s->hist->data[i][tmp] += 1;
    9486                }
    9587}
     
    10395        for (i=0; i < s->channels; i++)
    10496                for (j=0; j < s->nelems; j++)
    105                         s->hist[i][j] = 0;
     97                        s->hist->data[i][j] = 0;
    10698        /* run accum */
    10799        for (i=0; i < input->channels; i++)
     
    111103                                tmp = (sint_t)FLOOR(input->data[i][j]);
    112104                                if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    113                                         s->hist[i][tmp] += 1;
     105                                        s->hist->data[i][tmp] += 1;
    114106                        }
    115107                }
     
    139131        for (i=0; i < s->channels; i++)
    140132                for (j=0; j < s->nelems; j++)
    141                         s->hist[i][j] = 0;
     133                        s->hist->data[i][j] = 0;
    142134        /* run accum */
    143135        for (i=0; i < input->channels; i++)
     
    147139                                tmp = (sint_t)FLOOR(input->data[i][j]);
    148140                                if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    149                                         s->hist[i][tmp] += 1;
     141                                        s->hist->data[i][tmp] += 1;
    150142                        }
    151143                }
    152144}
    153145
    154 void aubio_hist_weigth (aubio_hist_t *s)
     146void aubio_hist_weight (aubio_hist_t *s)
    155147{
    156148        uint_t i,j;
    157149        for (i=0; i < s->channels; i++)
    158150                for (j=0; j < s->nelems; j++) {
    159                         s->hist[i][j] *= s->cent[j];
     151                        s->hist->data[i][j] *= s->cent[j];
    160152                }
    161153}
     
    167159        for (i=0; i < s->channels; i++)
    168160                for (j=0; j < s->nelems; j++)
    169                         tmp += s->hist[i][j];
     161                        tmp += s->hist->data[i][j];
    170162        return tmp/(smpl_t)(s->nelems);
    171163}
  • src/hist.h

    r2b3280a r274839f  
    5050smpl_t aubio_hist_mean(aubio_hist_t *s);
    5151/** weight the histogram */
    52 void aubio_hist_weigth(aubio_hist_t *s);
     52void aubio_hist_weight(aubio_hist_t *s);
    5353/** compute dynamic histogram for non-null elements */
    5454void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input);
  • src/onsetdetection.c

    r2b3280a r274839f  
    129129                aubio_hist_dyn_notnull(o->histog,o->dev1);
    130130                /* weight it */
    131                 aubio_hist_weigth(o->histog);
     131                aubio_hist_weight(o->histog);
    132132                /* its mean is the result */
    133133                onset->data[i][0] = aubio_hist_mean(o->histog);
     
    158158                aubio_hist_dyn_notnull(o->histog,o->dev1);
    159159                /* weight it */
    160                 aubio_hist_weigth(o->histog);
     160                aubio_hist_weight(o->histog);
    161161                /* its mean is the result */
    162162                onset->data[i][0] = aubio_hist_mean(o->histog);
Note: See TracChangeset for help on using the changeset viewer.