return bestpos;
}
-sf_count_t findMaximum(double (*func) (sf_count_t), sf_count_t x0, sf_count_t xgm, sf_count_t x1)
+sf_count_t findMaximum(double (*func) (sf_count_t), sf_count_t x0, sf_count_t xg, sf_count_t xg2, sf_count_t x1)
{
- sf_count_t xg, xg2, xg0, xg20;
+ sf_count_t xg0, xg20;
- xg0 = xg = MAX(x0, xgm - 65536);
- xg20 = xg2 = MIN(xgm + 65536, x1);
+ xg0 = xg = MAX(x0, MIN(xg, x1));
+ xg20 = xg2 = MAX(x0, MIN(xg2, x1));
for(;;)
{
sf_count_t size = MIN(infile_info.frames, strtod(argv[3], NULL) * infile_info.samplerate);
sf_count_t guess = strtod(argv[4], NULL) * infile_info.samplerate;
+ sf_count_t guess2 = strtod(argv[5], NULL) * infile_info.samplerate;
int channels = infile_info.channels;
size_t fftsize = atoi(argv[2]);
size_t ndata = channels * (fftsize/2 + 1);
}
#endif
- sf_count_t best = findMaximum(similarityAt, 0, guess - fftsize, size - 2 * fftsize);
+ sf_count_t best = findMaximum(similarityAt, 0, guess - fftsize, guess2 - fftsize, size - 2 * fftsize);
fprintf(stderr, "Result: %.9f (sample %ld)\n", (best + fftsize) / (double) infile_info.samplerate, (long) (best + fftsize));
// Now write it!
// 2. Open sound file
fprintf(stderr, "Opening...\n");
- SNDFILE *outfile = sf_open(argv[5], SFM_WRITE, &infile_info);
+ SNDFILE *outfile = sf_open(argv[6], SFM_WRITE, &infile_info);
if(!outfile)
err(1, "open");