+
+ // Check for pulses outside +/- 10% (sign of misdetection).
+ for (int i = SYNC_PULSE_START; i < SYNC_PULSE_END; ++i) {
+ double cycles = pulses[i].len * calibration_factor * C64_FREQUENCY;
+ if (cycles < SYNC_PULSE_LENGTH / SYNC_TEST_TOLERANCE || cycles > SYNC_PULSE_LENGTH * SYNC_TEST_TOLERANCE) {
+ fprintf(stderr, "Sync cycle with upflank at %.6f was detected at %.0f cycles; misdetect?\n",
+ pulses[i].time, cycles);
+ }
+ }
+
+ // Compute the standard deviation (to check for uneven speeds).
+ double sum2 = 0.0;
+ for (int i = SYNC_PULSE_START; i < SYNC_PULSE_END; ++i) {
+ double cycles = pulses[i].len * calibration_factor * C64_FREQUENCY;
+ sum2 += (cycles - SYNC_PULSE_LENGTH) * (cycles - SYNC_PULSE_LENGTH);
+ }
+ double stddev = sqrt(sum2 / (SYNC_PULSE_END - SYNC_PULSE_START - 1));
+ fprintf(stderr, "Sync pulse length standard deviation: %.2f cycles\n",
+ stddev);