From: Steinar H. Gunderson Date: Wed, 11 Mar 2015 22:26:08 +0000 (+0100) Subject: Move detect_pulses into its own function. X-Git-Url: https://git.sesse.net/?p=c64tapwav;a=commitdiff_plain;h=7780b150f76de3a52ce985a1d0e7b950fa6c0638;hp=b55d61c30b6c2158589de0d0584a6dcc590e52dd Move detect_pulses into its own function. --- diff --git a/decode.cpp b/decode.cpp index 94bc1dd..1c97331 100644 --- a/decode.cpp +++ b/decode.cpp @@ -231,34 +231,9 @@ std::vector do_filter(const std::vector& pcm, const float* filter) return filtered_pcm; } -int main(int argc, char **argv) +std::vector detect_pulses(const std::vector &pcm, int sample_rate) { - parse_options(argc, argv); - - make_lanczos_weight_table(); - std::vector pcm; - int sample_rate; - if (!read_audio_file(argv[optind], &pcm, &sample_rate)) { - exit(1); - } - - if (use_filter) { - pcm = do_filter(pcm, filter_coeff); - } - -#if 0 - for (int i = 0; i < LEN; ++i) { - in[i] += rand() % 10000; - } -#endif - -#if 0 - for (int i = 0; i < LEN; ++i) { - printf("%d\n", in[i]); - } -#endif - - std::vector pulses; // in seconds + std::vector pulses; // Find the flanks. int last_bit = -1; @@ -300,6 +275,37 @@ int main(int argc, char **argv) } last_bit = bit; } + return pulses; +} + +int main(int argc, char **argv) +{ + parse_options(argc, argv); + + make_lanczos_weight_table(); + std::vector pcm; + int sample_rate; + if (!read_audio_file(argv[optind], &pcm, &sample_rate)) { + exit(1); + } + + if (use_filter) { + pcm = do_filter(pcm, filter_coeff); + } + +#if 0 + for (int i = 0; i < LEN; ++i) { + in[i] += rand() % 10000; + } +#endif + +#if 0 + for (int i = 0; i < LEN; ++i) { + printf("%d\n", in[i]); + } +#endif + + std::vector pulses = detect_pulses(pcm, sample_rate); double calibration_factor = 1.0; if (do_calibrate) {