Changeset fff2bee


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

mathutils.c: add aubio_zero_crossing_rate at Amaury's request

Location:
src
Files:
2 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;
  • src/mathutils.h

    r3fd2dc1 rfff2bee  
    205205void aubio_autocorr(fvec_t * input, fvec_t * output);
    206206/**
     207 * zero-crossing rate (number of zero cross per sample)
     208 */
     209smpl_t aubio_zero_crossing_rate(fvec_t * input);
     210/**
    207211 * clean up cached memory at the end of program
    208212 *
Note: See TracChangeset for help on using the changeset viewer.