sonic_lite.c
static int prevPeriodBetter(int minDiff, int maxDiff, int preferNewPeriod) {
  if (minDiff == 0 || sonicStream.prevPeriod == 0) {
    return 0;
  }
  if (preferNewPeriod) {
    if (maxDiff > minDiff * 3) {
      /* Got a reasonable match this period */
      return 0;
    }
    if (minDiff * 2 <= sonicStream.prevMinDiff * 3) {
      /* Mismatch is not that much greater this period */
      return 0;
    }
  } else {
    if (minDiff <= sonicStream.prevMinDiff) {
      return 0;
    }
  }
  return 1;
}
/* At abrupt ends of voiced words, we can have pitch periods that are better
   approximated by the previous pitch period estimate.  Try to detect this case.  */
At abrupt ends of voiced words, we can have pitch periods that are better
approximated by the previous pitch period estimate.  Try to detect this case.
At abrupt ends of voiced words we can have pitch periods that are better approximated by the previous pitch period estimate . Try to detect this case .
static int prevPeriodBetter(int minDiff, int maxDiff, int preferNewPeriod) {
  if (minDiff == 0 || sonicStream.prevPeriod == 0) {
    return 0;
  }
  if (preferNewPeriod) {
    if (maxDiff > minDiff * 3) {
      return 0;
    }
    if (minDiff * 2 <= sonicStream.prevMinDiff * 3) {
      return 0;
    }
  } else {
    if (minDiff <= sonicStream.prevMinDiff) {
      return 0;
    }
  }
  return 1;
}
static int prevPeriodBetter ( int minDiff , int maxDiff , int preferNewPeriod ) { if ( minDiff == 0 || sonicStream . prevPeriod == 0 ) { return 0 ; } if ( preferNewPeriod ) { if ( maxDiff > minDiff * 3 ) { return 0 ; } if ( minDiff * 2 <= sonicStream . prevMinDiff * 3 ) { return 0 ; } } else { if ( minDiff <= sonicStream . prevMinDiff ) { return 0 ; } } return 1 ; }
At abrupt ends of voiced words, we can have pitch periods that are better
approximated by the previous pitch period estimate.
At abrupt ends of voiced words we can have pitch periods that are better approximated by the previous pitch period estimate .
/* Got a reasonable match this period */ /* Mismatch is not that much greater this period */