#include <stdio.h>
#include <string.h>
#include <math.h>
-#include <unistd.h>
#include <assert.h>
#include <limits.h>
#include <vector>
#include <algorithm>
#include "interpolate.h"
+#include "tap.h"
#define BUFSIZE 4096
#define HYSTERESIS_LIMIT 3000
#define SAMPLE_RATE 44100
#define C64_FREQUENCY 985248
-#define TAP_RESOLUTION 8
#define SYNC_PULSE_START 1000
#define SYNC_PULSE_END 15000
#define SYNC_PULSE_LENGTH 378.0
#define SYNC_TEST_TOLERANCE 1.10
-struct tap_header {
- char identifier[12];
- char version;
- char reserved[3];
- unsigned int data_len;
-};
-
// between [x,x+1]
double find_zerocrossing(const std::vector<short> &pcm, int x)
{
double upper = x;
double lower = x + 1;
- while (upper - lower > 1e-6) {
+ while (lower - upper > 1e-3) {
double mid = 0.5f * (upper + lower);
if (lanczos_interpolate(pcm, mid) > 0) {
upper = mid;
int main(int argc, char **argv)
{
+ make_lanczos_weight_table();
std::vector<short> pcm;
while (!feof(stdin)) {