sf_count_t i;
- for(i = x0 + step; i < x1; i += step)
+ for(i = x0; i < x1; i += step)
{
double cur = func(i);
if(cur > best)
xg0 = xg = MAX(x0, MIN(xg, x1));
xg20 = xg2 = MAX(x0, MIN(xg2, x1));
+ fprintf(stderr, "min/max: %d %d\n", (int)xg, (int)xg2);
+
for(;;)
{
sf_count_t size = xg2 - xg;
if(size == 0)
break;
- fprintf(stderr, "round:\n");
- sf_count_t bestguess = findMaximumSingle(func, xg, xg2, (xg2 - xg) / 16 + 1);
- xg = MAX(x0, bestguess - size / 3);
- xg2 = MIN(bestguess + size / 3, x1);
+ //fprintf(stderr, "round:\n");
+ sf_count_t bestguess = findMaximumSingle(func, xg, xg2, size / 32 + 1);
+ xg = MAX(xg, bestguess - size / 3);
+ xg2 = MIN(bestguess + size / 3, xg2);
}
- if(xg - xg0 < (xg20 - xg0) / 16)
+ fprintf(stderr, "guessed: %d\n", (int)xg);
+
+ if(xg - xg0 < (xg20 - xg0) / 64)
fprintf(stderr, "warning: best match very close to left margin, maybe decrease the guess?\n");
- if(xg20 - xg < (xg20 - xg0) / 16)
+ if(xg20 - xg < (xg20 - xg0) / 64)
fprintf(stderr, "warning: best match very close to right margin, maybe increase the guess?\n");
return xg;
double sxy = vectorDot(data_end + ndata_lowpass, data_cur + ndata_lowpass, ndata_highpass - ndata_lowpass);
double syy = vectorDot(data_cur + ndata_lowpass, data_cur + ndata_lowpass, ndata_highpass - ndata_lowpass);
double v = syy ? ((sxy*sxy) / (sxx*syy)) : -1;
- fprintf(stderr, "Evaluated at %.9f: %f\n", i / (double) infile_info.samplerate, v);
+ //fprintf(stderr, "Evaluated at %.9f: %f\n", i / (double) infile_info.samplerate, v);
return v;
}