X-Git-Url: https://git.sesse.net/?p=c64tapwav;a=blobdiff_plain;f=sync.cpp;h=e5e5120c3afc78d389a3eadb84c8a7f867f24ea1;hp=7e43ec114cf59797daa2718b67615cd1057bc023;hb=b051acfd16d8c44e64e69ff972c07c1741a192f0;hpb=af205db54703906ad67adb6393a9df97c96357e8 diff --git a/sync.cpp b/sync.cpp index 7e43ec1..e5e5120 100644 --- a/sync.cpp +++ b/sync.cpp @@ -2,8 +2,8 @@ // to find the most likely misalignment as it changes throughout the file. #define NUM_THEORIES 200 -#define THEORY_FROM -10.0 /* in samples */ -#define THEORY_TO 10.0 /* in samples */ +#define THEORY_FROM -20.0 /* in samples */ +#define THEORY_TO 20.0 /* in samples */ #define SWITCH_COST 1000.0 /* pretty arbitrary */ #include @@ -41,6 +41,7 @@ struct hypothesis { int main(int argc, char **argv) { + make_lanczos_weight_table(); std::vector pcm; while (!feof(stdin)) { @@ -113,7 +114,7 @@ int main(int argc, char **argv) fprintf(stderr, "Matching blocks... %7.2f", 0.0); hypothesis *prev_hyp = bases; size_t total_end = pcm.size(); - //size_t total_end = 4410000; + //size_t total_end = 441000; for (unsigned i = 0; i < total_end; i += BUFSIZE) { fprintf(stderr, "\b\b\b\b\b\b\b%7.2f", i / 44100.0); size_t end = std::min(i + BUFSIZE, total_end); @@ -181,17 +182,17 @@ int main(int argc, char **argv) double inv_sd = sqrt(2.0) / sqrt(var_left + var_right); std::vector aligned_pcm; std::vector mono_pcm; + aligned_pcm.resize(total_end); + mono_pcm.resize(total_end); for (unsigned i = 0; i < total_end; ++i) { - double d = linear_interpolate(best_path, i / double(BUFSIZE)); + double d = lanczos_interpolate(best_path, i / double(BUFSIZE)); int left = pcm[i].left; - int right = linear_interpolate_right(pcm, i + d); + int right = lanczos_interpolate_right(pcm, i + d); - stereo_sample ss; - ss.left = left; - ss.right = clip(right); - aligned_pcm.push_back(ss); + aligned_pcm[i].left = left; + aligned_pcm[i].right = clip(right); - mono_pcm.push_back(clip(lrintf(inv_sd * 4096.0 * (left + right)))); + mono_pcm[i] = clip(lrintf(inv_sd * 4096.0 * (left + right))); if (i % 4096 == 0) { fprintf(stderr, "\b\b\b\b\b\b\b\b%7.2f%%", 100.0 * i / total_end);