Changeset fc61225


Ignore:
Timestamp:
Dec 4, 2009, 1:43:29 AM (14 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:
168337e
Parents:
8e5c051
Message:

src/utils: switch to mono

Location:
src/utils
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/utils/hist.c

    r8e5c051 rfc61225  
    3232  fvec_t * hist;
    3333  uint_t nelems;
    34   uint_t channels;
    3534  fvec_t * cent;
    3635  aubio_scale_t *scaler;
     
    4039 * Object creation/deletion calls
    4140 */
    42 aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems, uint_t channels){
     41aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems){
    4342  aubio_hist_t * s = AUBIO_NEW(aubio_hist_t);
    4443  smpl_t step = (ihig-ilow)/(smpl_t)(nelems);
    4544  smpl_t accum = step;
    4645  uint_t i;
    47   s->channels = channels;
    4846  s->nelems = nelems;
    49   s->hist = new_fvec(nelems, channels);
    50   s->cent = new_fvec(nelems, 1);
     47  s->hist = new_fvec(nelems);
     48  s->cent = new_fvec(nelems);
    5149
    5250  /* use scale to map ilow/ihig -> 0/nelems */
    5351  s->scaler = new_aubio_scale(ilow,ihig,0,nelems);
    5452  /* calculate centers now once */
    55   s->cent->data[0][0] = ilow + 0.5 * step;
     53  s->cent->data[0] = ilow + 0.5 * step;
    5654  for (i=1; i < s->nelems; i++, accum+=step )
    57     s->cent->data[0][i] = s->cent->data[0][0] + accum;
     55    s->cent->data[i] = s->cent->data[0] + accum;
    5856
    5957  return s;
     
    7169 */
    7270void aubio_hist_do (aubio_hist_t *s, fvec_t *input) {
    73   uint_t i,j;
     71  uint_t j;
    7472  sint_t tmp = 0;
    7573  aubio_scale_do(s->scaler, input);
    7674  /* reset data */
    77   for (i=0; i < s->channels; i++)
    78     for (j=0; j < s->nelems; j++)
    79       s->hist->data[i][j] = 0;
     75  fvec_zeros(s->hist);
    8076  /* run accum */
    81   for (i=0; i < input->channels; i++)
    82     for (j=0;  j < input->length; j++)
    83     {
    84       tmp = (sint_t)FLOOR(input->data[i][j]);
    85       if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    86         s->hist->data[i][tmp] += 1;
     77  for (j=0;  j < input->length; j++)
     78  {
     79    tmp = (sint_t)FLOOR(input->data[j]);
     80    if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) {
     81      s->hist->data[tmp] += 1;
    8782    }
     83  }
    8884}
    8985
    9086void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input) {
    91   uint_t i,j;
     87  uint_t j;
    9288  sint_t tmp = 0;
    9389  aubio_scale_do(s->scaler, input);
    9490  /* reset data */
    95   for (i=0; i < s->channels; i++)
    96     for (j=0; j < s->nelems; j++)
    97       s->hist->data[i][j] = 0;
     91  fvec_zeros(s->hist);
    9892  /* run accum */
    99   for (i=0; i < input->channels; i++)
    100     for (j=0;  j < input->length; j++) {
    101       if (input->data[i][j] != 0) {
    102         tmp = (sint_t)FLOOR(input->data[i][j]);
    103         if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    104           s->hist->data[i][tmp] += 1;
    105       }
     93  for (j=0;  j < input->length; j++) {
     94    if (input->data[j] != 0) {
     95      tmp = (sint_t)FLOOR(input->data[j]);
     96      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
     97        s->hist->data[tmp] += 1;
    10698    }
     99  }
    107100}
    108101
    109102
    110103void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) {
    111   uint_t i,j;
     104  uint_t i;
    112105  sint_t tmp = 0;
    113106  smpl_t ilow = fvec_min(input);
     
    119112
    120113  /* recalculate centers */
    121   s->cent->data[0][0] = ilow + 0.5f * step;
     114  s->cent->data[0] = ilow + 0.5f * step;
    122115  for (i=1; i < s->nelems; i++)
    123     s->cent->data[0][i] = s->cent->data[0][0] + i * step;
     116    s->cent->data[i] = s->cent->data[0] + i * step;
    124117
    125118  /* scale */
     
    127120
    128121  /* reset data */
    129   for (i=0; i < s->channels; i++)
    130     for (j=0; j < s->nelems; j++)
    131       s->hist->data[i][j] = 0;
     122  fvec_zeros(s->hist);
    132123  /* run accum */
    133   for (i=0; i < input->channels; i++)
    134     for (j=0;  j < input->length; j++) {
    135       if (input->data[i][j] != 0) {
    136         tmp = (sint_t)FLOOR(input->data[i][j]);
    137         if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    138           s->hist->data[i][tmp] += 1;
    139       }
     124  for (i=0;  i < input->length; i++) {
     125    if (input->data[i] != 0) {
     126      tmp = (sint_t)FLOOR(input->data[i]);
     127      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
     128        s->hist->data[tmp] += 1;
    140129    }
     130  }
    141131}
    142132
    143133void aubio_hist_weight (aubio_hist_t *s) {
    144   uint_t i,j;
    145   for (i=0; i < s->channels; i++)
    146     for (j=0; j < s->nelems; j++) {
    147       s->hist->data[i][j] *= s->cent->data[0][j];
    148     }
     134  uint_t j;
     135  for (j=0; j < s->nelems; j++) {
     136    s->hist->data[j] *= s->cent->data[j];
     137  }
    149138}
    150139
    151140smpl_t aubio_hist_mean (aubio_hist_t *s) {
    152   uint_t i,j;
     141  uint_t j;
    153142  smpl_t tmp = 0.0;
    154   for (i=0; i < s->channels; i++)
    155     for (j=0; j < s->nelems; j++)
    156       tmp += s->hist->data[i][j];
     143  for (j=0; j < s->nelems; j++)
     144    tmp += s->hist->data[j];
    157145  return tmp/(smpl_t)(s->nelems);
    158146}
  • src/utils/hist.h

    r8e5c051 rfc61225  
    4040 * \param fhig maximum input
    4141 * \param nelems number of histogram columns
    42  * \param channels number of channels
    4342 */
    44 aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems, uint_t channels);
     43aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems);
    4544/** histogram deletion */
    4645void del_aubio_hist(aubio_hist_t *s);
  • src/utils/scale.c

    r8e5c051 rfc61225  
    7070void aubio_scale_do (aubio_scale_t *s, fvec_t *input)
    7171{
    72   uint_t i, j;
    73   for (i=0; i < input->channels; i++){
    74     for (j=0;  j < input->length; j++){
    75       input->data[i][j] -= s->ilow;
    76       input->data[i][j] *= s->scaler;
    77       input->data[i][j] += s->olow;
    78     }
     72  uint_t j;
     73  for (j=0;  j < input->length; j++){
     74    input->data[j] -= s->ilow;
     75    input->data[j] *= s->scaler;
     76    input->data[j] += s->olow;
    7977  }
    8078}
Note: See TracChangeset for help on using the changeset viewer.