frac32buffer in
frac32 pitch
frac32.u.map pitch detections that are above treshold value will be ommited (not sure if it actually helps, but it's there to try)
int32_t prv;
uint32_t Prv;
uint32_t cur;
uint32_t writepos;
int32_t array[128];
uint32_t Array[128];
int64_t TM;
int32_t TS;
bool zc;
int cnt;
int32_t tmp;
int32_t lp1;
int32_t lp2;
int32_t hp;
uint32_t Time;
int i;
// for(i=0;i<127;i++){
// tmp+=array[i]-tmp>>8;
//}
for (i = 0; i < 128; i++) {
int32_t diff = tmp - array[i];
diff = diff > 0 ? diff : -diff;
if (diff < (param_tresh)) {
int k = (i + writepos) & 127;
cur = Array[k];
TM = Array[k] - Prv;
TS = TM < 0 ? (1 << 32) + TM : TM;
Prv = Array[k];
}
}
outlet_pitch = ((int64_t)(65584) << 8) / TS << 4;
lp1 += (inlet_in - lp1) >> 7;
lp2 += (lp1 - lp2) >> 7;
hp += (lp2 - hp) >> 10;
int32_t lh = lp2 - hp;
if ((lh >= 0) && (prv < 0)) {
int32_t chg = lh - prv;
tmp += chg - tmp >> 4;
array[writepos] = chg;
Array[writepos] = Time;
writepos = (writepos + 1) & 127;
}
Time += 1;
prv = lh;