X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=decode.cpp;h=99776bc29a07e15eb54d57c1cd5d2fa8986f4822;hb=08089f496815d725c3bee171bae0e884642ffc05;hp=1a5ee74856c5c635e37ea434213307114964be6c;hpb=eb5c6ac462d461ce3929e9a82fdd5f33aa537923;p=c64tapwav diff --git a/decode.cpp b/decode.cpp index 1a5ee74..99776bc 100644 --- a/decode.cpp +++ b/decode.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -60,6 +61,7 @@ struct pulse { int main(int argc, char **argv) { + make_lanczos_weight_table(); std::vector pcm; while (!feof(stdin)) { @@ -189,4 +191,20 @@ int main(int argc, char **argv) fwrite(&hdr, sizeof(hdr), 1, stdout); fwrite(tap_data.data(), tap_data.size(), 1, stdout); + + // Output a debug raw file with pulse detection points. + fp = fopen("debug.raw", "wb"); + short one = 32767; + short zero = 0; + unsigned pulsenum = 0; + for (unsigned i = 0; i < pcm.size(); ++i) { + unsigned next_pulse = (pulsenum >= pulses.size()) ? INT_MAX : int(pulses[pulsenum].time * SAMPLE_RATE); + if (i >= next_pulse) { + fwrite(&one, sizeof(one), 1, fp); + ++pulsenum; + } else { + fwrite(&zero, sizeof(zero), 1, fp); + } + } + fclose(fp); }