Changeset e391790


Ignore:
Timestamp:
Aug 1, 2015, 10:28:38 AM (5 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:
482fab8
Parents:
10482d2
Message:

src/pitch/pitchyin.c, src/pitch/pitchyinfft.c: avoid producing NaN on silence (closes #7)

Location:
src/pitch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitchyin.c

    r10482d2 re391790  
    146146    }
    147147    tmp2 += yin->data[tau];
    148     yin->data[tau] *= tau / tmp2;
     148    if (tmp2 != 0) {
     149      yin->data[tau] *= tau / tmp2;
     150    } else {
     151      yin->data[tau] = 1.;
     152    }
    149153    period = tau - 3;
    150154    if (tau > 4 && (yin->data[period] < tol) &&
  • src/pitch/pitchyinfft.c

    r10482d2 re391790  
    136136    // and the cumulative mean normalized difference function
    137137    tmp += yin->data[tau];
    138     yin->data[tau] *= tau / tmp;
     138    if (tmp != 0) {
     139      yin->data[tau] *= tau / tmp;
     140    } else {
     141      yin->data[tau] = 1.;
     142    }
    139143  }
    140144  // find best candidates
Note: See TracChangeset for help on using the changeset viewer.