float best_scale = 1.0;
int best_offs = 0;
- // Try delaying orig.
+ // Try delaying cand.
for (int orig_offs = 0; orig_offs < clip_len / 2; ++orig_offs) {
- float sum_xx = sumsq_orig[clip_len - orig_offs] - sumsq_orig[0];
- float sum_yy = sumsq_cand[clip_len] - sumsq_cand[orig_offs];
+ float sum_xx = sumsq_cand[clip_len - orig_offs] - sumsq_cand[0];
+ float sum_yy = sumsq_orig[clip_len] - sumsq_orig[orig_offs];
float sum_xy = fft_in[orig_offs] * (1.0 / fft_len);
float corr = sum_xy / sqrt(sum_xx * sum_yy);
fprintf(fp, "%f %f\n", -orig_offs * (1e3 / OUTPUT_FREQUENCY), corr);
}
}
- // Try delaying cand.
+ // Try delaying orig.
for (int cand_offs = 0; cand_offs < clip_len / 2; ++cand_offs) {
- float sum_xx = sumsq_orig[clip_len] - sumsq_orig[cand_offs];
- float sum_yy = sumsq_cand[clip_len - cand_offs] - sumsq_cand[0];
+ float sum_xx = sumsq_cand[clip_len] - sumsq_cand[cand_offs];
+ float sum_yy = sumsq_orig[clip_len - cand_offs] - sumsq_orig[0];
float sum_xy = fft_in[fft_len - cand_offs] * (1.0 / fft_len);
float corr = sum_xy / sqrt(sum_xx * sum_yy);
fprintf(fp, "%f %f\n", cand_offs * (1e3 / OUTPUT_FREQUENCY), corr);