Changeset 3c707f7 for src


Ignore:
Timestamp:
Nov 4, 2007, 4:47:38 PM (17 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:
82f0c4e7
Parents:
812b376
Message:

hist.{c,h}: redo indentation

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/hist.c

    r812b376 r3c707f7  
    11/*
    2         Copyright (C) 2003 Paul Brossier
     2  Copyright (C) 2003 Paul Brossier
    33
    4         This program is free software; you can redistribute it and/or modify
    5         it under the terms of the GNU General Public License as published by
    6         the Free Software Foundation; either version 2 of the License, or
    7         (at your option) any later version.
     4  This program is free software; you can redistribute it and/or modify
     5  it under the terms of the GNU General Public License as published by
     6  the Free Software Foundation; either version 2 of the License, or
     7  (at your option) any later version.
    88
    9         This program is distributed in the hope that it will be useful,
    10         but WITHOUT ANY WARRANTY; without even the implied warranty of
    11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12         GNU General Public License for more details.
     9  This program is distributed in the hope that it will be useful,
     10  but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  GNU General Public License for more details.
    1313
    14         You should have received a copy of the GNU General Public License
    15         along with this program; if not, write to the Free Software
    16         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    17          */
     14  You should have received a copy of the GNU General Public License
     15  along with this program; if not, write to the Free Software
     16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     17*/
    1818
    1919#include "aubio_priv.h"
     
    2828
    2929struct _aubio_hist_t {
    30         fvec_t * hist;
    31         uint_t nelems;
    32         uint_t channels;
    33         fvec_t * cent;
    34         aubio_scale_t *scaler;
     30  fvec_t * hist;
     31  uint_t nelems;
     32  uint_t channels;
     33  fvec_t * cent;
     34  aubio_scale_t *scaler;
    3535};
    3636
     
    3939 */
    4040aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems, uint_t channels){
    41         aubio_hist_t * s = AUBIO_NEW(aubio_hist_t);
    42         smpl_t step = (ihig-ilow)/(smpl_t)(nelems);
    43         smpl_t accum = step;
    44         uint_t i;
    45         s->channels = channels;
    46         s->nelems = nelems;
     41  aubio_hist_t * s = AUBIO_NEW(aubio_hist_t);
     42  smpl_t step = (ihig-ilow)/(smpl_t)(nelems);
     43  smpl_t accum = step;
     44  uint_t i;
     45  s->channels = channels;
     46  s->nelems = nelems;
    4747  s->hist = new_fvec(nelems, channels);
    48         s->cent = new_fvec(nelems, 1);
    49        
    50         /* use scale to map ilow/ihig -> 0/nelems */
    51         s->scaler = new_aubio_scale(ilow,ihig,0,nelems);
    52         /* calculate centers now once */
    53         s->cent->data[0][0] = ilow + 0.5 * step;
    54         for (i=1; i < s->nelems; i++, accum+=step )
    55                 s->cent->data[0][i] = s->cent->data[0][0] + accum;
    56        
    57         return s;       
     48  s->cent = new_fvec(nelems, 1);
     49
     50  /* use scale to map ilow/ihig -> 0/nelems */
     51  s->scaler = new_aubio_scale(ilow,ihig,0,nelems);
     52  /* calculate centers now once */
     53  s->cent->data[0][0] = ilow + 0.5 * step;
     54  for (i=1; i < s->nelems; i++, accum+=step )
     55    s->cent->data[0][i] = s->cent->data[0][0] + accum;
     56
     57  return s;
    5858}
    5959
    6060void del_aubio_hist(aubio_hist_t *s) {
    6161  del_fvec(s->hist);
    62         del_fvec(s->cent);
    63         del_aubio_scale(s->scaler);
    64         AUBIO_FREE(s);
     62  del_fvec(s->cent);
     63  del_aubio_scale(s->scaler);
     64  AUBIO_FREE(s);
    6565}
    6666
     
    6868 * do it
    6969 */
    70 void aubio_hist_do (aubio_hist_t *s, fvec_t *input)
    71 {
    72         uint_t i,j;
    73         sint_t tmp = 0;
    74         aubio_scale_do(s->scaler, input);
    75         /* reset data */
    76         for (i=0; i < s->channels; i++)
    77                 for (j=0; j < s->nelems; j++)
    78                         s->hist->data[i][j] = 0;
    79         /* run accum */
    80         for (i=0; i < input->channels; i++)
    81                 for (j=0;  j < input->length; j++)
    82                 {
    83                         tmp = (sint_t)FLOOR(input->data[i][j]);
    84                         if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    85                                 s->hist->data[i][tmp] += 1;
    86                 }
     70void aubio_hist_do (aubio_hist_t *s, fvec_t *input) {
     71  uint_t i,j;
     72  sint_t tmp = 0;
     73  aubio_scale_do(s->scaler, input);
     74  /* reset data */
     75  for (i=0; i < s->channels; i++)
     76    for (j=0; j < s->nelems; j++)
     77      s->hist->data[i][j] = 0;
     78  /* run accum */
     79  for (i=0; i < input->channels; i++)
     80    for (j=0;  j < input->length; j++)
     81    {
     82      tmp = (sint_t)FLOOR(input->data[i][j]);
     83      if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
     84        s->hist->data[i][tmp] += 1;
     85    }
    8786}
    8887
    89 void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input)
    90 {
    91         uint_t i,j;
    92         sint_t tmp = 0;
    93         aubio_scale_do(s->scaler, input);
    94         /* 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;
    98         /* run accum */
    99         for (i=0; i < input->channels; i++)
    100                 for (j=0;  j < input->length; j++)
    101                 {
    102                         if (input->data[i][j] != 0) {
    103                                 tmp = (sint_t)FLOOR(input->data[i][j]);
    104                                 if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    105                                         s->hist->data[i][tmp] += 1;
    106                         }
    107                 }
     88void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input) {
     89  uint_t i,j;
     90  sint_t tmp = 0;
     91  aubio_scale_do(s->scaler, input);
     92  /* reset data */
     93  for (i=0; i < s->channels; i++)
     94    for (j=0; j < s->nelems; j++)
     95      s->hist->data[i][j] = 0;
     96  /* run accum */
     97  for (i=0; i < input->channels; i++)
     98    for (j=0;  j < input->length; j++) {
     99      if (input->data[i][j] != 0) {
     100        tmp = (sint_t)FLOOR(input->data[i][j]);
     101        if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
     102          s->hist->data[i][tmp] += 1;
     103      }
     104    }
    108105}
    109106
    110107
    111 void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input)
    112 {
    113         uint_t i,j;
    114         sint_t tmp = 0;
    115         smpl_t ilow = vec_min(input);
    116         smpl_t ihig = vec_max(input);
    117         smpl_t step = (ihig-ilow)/(smpl_t)(s->nelems);
    118        
    119         /* readapt */
    120         aubio_scale_set(s->scaler, ilow, ihig, 0, s->nelems);
     108void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) {
     109  uint_t i,j;
     110  sint_t tmp = 0;
     111  smpl_t ilow = vec_min(input);
     112  smpl_t ihig = vec_max(input);
     113  smpl_t step = (ihig-ilow)/(smpl_t)(s->nelems);
    121114
    122         /* recalculate centers */
    123         s->cent->data[0][0] = ilow + 0.5f * step;
    124         for (i=1; i < s->nelems; i++)
    125                 s->cent->data[0][i] = s->cent->data[0][0] + i * step;
     115  /* readapt */
     116  aubio_scale_set(s->scaler, ilow, ihig, 0, s->nelems);
    126117
    127         /* scale */     
    128         aubio_scale_do(s->scaler, input);
     118  /* recalculate centers */
     119  s->cent->data[0][0] = ilow + 0.5f * step;
     120  for (i=1; i < s->nelems; i++)
     121    s->cent->data[0][i] = s->cent->data[0][0] + i * step;
    129122
    130         /* reset data */
    131         for (i=0; i < s->channels; i++)
    132                 for (j=0; j < s->nelems; j++)
    133                         s->hist->data[i][j] = 0;
    134         /* run accum */
    135         for (i=0; i < input->channels; i++)
    136                 for (j=0;  j < input->length; j++)
    137                 {
    138                         if (input->data[i][j] != 0) {
    139                                 tmp = (sint_t)FLOOR(input->data[i][j]);
    140                                 if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
    141                                         s->hist->data[i][tmp] += 1;
    142                         }
    143                 }
     123  /* scale */
     124  aubio_scale_do(s->scaler, input);
     125
     126  /* reset data */
     127  for (i=0; i < s->channels; i++)
     128    for (j=0; j < s->nelems; j++)
     129      s->hist->data[i][j] = 0;
     130  /* run accum */
     131  for (i=0; i < input->channels; i++)
     132    for (j=0;  j < input->length; j++) {
     133      if (input->data[i][j] != 0) {
     134        tmp = (sint_t)FLOOR(input->data[i][j]);
     135        if ((tmp >= 0) && (tmp < (sint_t)s->nelems))
     136          s->hist->data[i][tmp] += 1;
     137      }
     138    }
    144139}
    145140
    146 void aubio_hist_weight (aubio_hist_t *s)
    147 {
    148         uint_t i,j;
    149         for (i=0; i < s->channels; i++)
    150                 for (j=0; j < s->nelems; j++) {
    151                         s->hist->data[i][j] *= s->cent->data[0][j];
    152                 }
     141void aubio_hist_weight (aubio_hist_t *s) {
     142  uint_t i,j;
     143  for (i=0; i < s->channels; i++)
     144    for (j=0; j < s->nelems; j++) {
     145      s->hist->data[i][j] *= s->cent->data[0][j];
     146    }
    153147}
    154148
    155 smpl_t aubio_hist_mean (aubio_hist_t *s)
    156 {
    157         uint_t i,j;
    158         smpl_t tmp = 0.0f;
    159         for (i=0; i < s->channels; i++)
    160                 for (j=0; j < s->nelems; j++)
    161                         tmp += s->hist->data[i][j];
    162         return tmp/(smpl_t)(s->nelems);
     149smpl_t aubio_hist_mean (aubio_hist_t *s) {
     150  uint_t i,j;
     151  smpl_t tmp = 0.0f;
     152  for (i=0; i < s->channels; i++)
     153    for (j=0; j < s->nelems; j++)
     154      tmp += s->hist->data[i][j];
     155  return tmp/(smpl_t)(s->nelems);
    163156}
    164157
  • src/hist.h

    r812b376 r3c707f7  
    1515         along with this program; if not, write to the Free Software
    1616         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    17          */
     17*/
    1818
    1919/** @file
     
    3434typedef struct _aubio_hist_t aubio_hist_t;
    3535
    36 /** histogram creation 
     36/** histogram creation
    3737 * \param flow minimum input
    3838 * \param fhig maximum input
    3939 * \param nelems number of histogram columns
    40  * \param channels number of channels 
     40 * \param channels number of channels
    4141 */
    4242aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems, uint_t channels);
     
    4848void aubio_hist_do_notnull(aubio_hist_t *s, fvec_t * input);
    4949/** compute the mean of the histogram */
    50 smpl_t aubio_hist_mean(aubio_hist_t *s); 
     50smpl_t aubio_hist_mean(aubio_hist_t *s);
    5151/** weight the histogram */
    52 void aubio_hist_weight(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);
Note: See TracChangeset for help on using the changeset viewer.