Changeset fff2bee for src/mathutils.c


Ignore:
Timestamp:
Apr 17, 2007, 9:59:15 PM (13 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:
5507e9d
Parents:
3fd2dc1
Message:

mathutils.c: add aubio_zero_crossing_rate at Amaury's request

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r3fd2dc1 rfff2bee  
    441441}
    442442
     443smpl_t aubio_zero_crossing_rate(fvec_t * input) {
     444  uint_t i=0,j;
     445  uint_t zcr = 0;
     446  for ( j = 1; j < input->length; j++ ) {
     447    // previous was negative
     448    if( input->data[i][j-1] <= 0. ) {
     449      if ( input->data[i][j] > 0. ) {
     450        zcr += 1;
     451      }
     452    //previous was positive
     453    } else if ( input->data[i][j] <= 0. ){
     454      zcr += 1;
     455    }
     456  }
     457  return zcr/(smpl_t)input->length;
     458}
     459
    443460void aubio_autocorr(fvec_t * input, fvec_t * output){
    444461        uint_t i = 0, j = 0, length = input->length;
Note: See TracChangeset for help on using the changeset viewer.