Changeset 0dbdb40


Ignore:
Timestamp:
Apr 18, 2007, 1:07:48 AM (14 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
c8b80cd
Parents:
5507e9d
Message:

mathutils.c: add aubio_spectral_centroid

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r5507e9d r0dbdb40  
    458458}
    459459
     460smpl_t aubio_spectral_centroid(cvec_t * spectrum, smpl_t samplerate) {
     461  uint_t i=0, j;
     462  smpl_t sum = 0., sc = 0.;
     463  for ( j = 0; j < spectrum->length; j++ ) {
     464    sum += spectrum->norm[i][j];
     465  }
     466  if (sum == 0.) return 0.;
     467  for ( j = 0; j < spectrum->length; j++ ) {
     468    sc += (smpl_t)j * spectrum->norm[i][j];
     469  }
     470  return sc / sum * samplerate / (smpl_t)(spectrum->length);
     471}
     472
    460473void aubio_autocorr(fvec_t * input, fvec_t * output){
    461474        uint_t i = 0, j = 0, length = input->length;
  • src/mathutils.h

    r5507e9d r0dbdb40  
    209209smpl_t aubio_zero_crossing_rate(fvec_t * input);
    210210/**
     211 * spectrum centroid computed on a cvec
     212 */
     213smpl_t aubio_spectral_centroid(cvec_t * input, smpl_t samplerate);
     214/**
    211215 * clean up cached memory at the end of program
    212216 *
Note: See TracChangeset for help on using the changeset viewer.