]> git.sesse.net Git - c64tapwav/commitdiff
Factor out cycles.plot writing.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 11 Mar 2015 23:16:40 +0000 (00:16 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 11 Mar 2015 23:16:40 +0000 (00:16 +0100)
decode.cpp

index 43d6766bfd38774c58f4b6fc4601f7c18f598bb0..7def49df3c7fbb9f19377122c8c9639d6002462a 100644 (file)
@@ -319,6 +319,16 @@ std::vector<pulse> detect_pulses(const std::vector<float> &pcm, int sample_rate)
        return pulses;
 }
 
+void output_cycle_plot(const std::vector<pulse> &pulses, double calibration_factor)
+{
+       FILE *fp = fopen("cycles.plot", "w");
+       for (unsigned i = 0; i < pulses.size(); ++i) {
+               double cycles = pulses[i].len * calibration_factor * C64_FREQUENCY;
+               fprintf(fp, "%f %f\n", pulses[i].time, cycles);
+       }
+       fclose(fp);
+}
+
 int main(int argc, char **argv)
 {
        parse_options(argc, argv);
@@ -358,12 +368,7 @@ int main(int argc, char **argv)
        }
 
        if (output_cycles_plot) {
-               FILE *fp = fopen("cycles.plot", "w");
-               for (unsigned i = 0; i < pulses.size(); ++i) {
-                       double cycles = pulses[i].len * calibration_factor * C64_FREQUENCY;
-                       fprintf(fp, "%f %f\n", pulses[i].time, cycles);
-               }
-               fclose(fp);
+               output_cycle_plot(pulses, calibration_factor);
        }
 
        output_tap(pulses, calibration_factor);