From 2d875bfb4e11cea397aeb88d9781d8a36079c9a1 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 4 May 2013 22:16:58 +0200 Subject: [PATCH] Make a debug.raw with detected pulses. --- decode.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/decode.cpp b/decode.cpp index 1a5ee74..fdc1347 100644 --- a/decode.cpp +++ b/decode.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -189,4 +190,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); } -- 2.39.2