Changes in src/mathutils.c [ade9afe:6c7d49b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/mathutils.c ¶
rade9afe r6c7d49b 21 21 22 22 #include "aubio_priv.h" 23 #include " sample.h"23 #include "fvec.h" 24 24 #include "mathutils.h" 25 25 #include "config.h" … … 227 227 /* pre part of the buffer does not exist */ 228 228 } else { 229 for (k=0;k<length-pos+post +1;k++)229 for (k=0;k<length-pos+post;k++) 230 230 medar[k] = vec->data[0][k+pos-post]; 231 for (k=length-pos+post +1;k<win_length;k++)231 for (k=length-pos+post;k<win_length;k++) 232 232 medar[k] = 0.; /* 0-padding at the end */ 233 233 } … … 433 433 } 434 434 435 smpl_t aubio_spectral_centroid(cvec_t * spectrum, smpl_t samplerate) {436 uint_t i=0, j;437 smpl_t sum = 0., sc = 0.;438 for ( j = 0; j < spectrum->length; j++ ) {439 sum += spectrum->norm[i][j];440 }441 if (sum == 0.) return 0.;442 for ( j = 0; j < spectrum->length; j++ ) {443 sc += (smpl_t)j * spectrum->norm[i][j];444 }445 return sc / sum * samplerate / (smpl_t)(spectrum->length);446 }447 448 435 void aubio_autocorr(fvec_t * input, fvec_t * output) { 449 436 uint_t i = 0, j = 0, length = input->length;
Note: See TracChangeset
for help on using the changeset viewer.