X-Git-Url: https://git.sesse.net/?p=c64tapwav;a=blobdiff_plain;f=decode.cpp;h=e85f57934e685f214f4cda1cf02fc247a9a332fa;hp=c9a5ded52741f233ccf877c3f7384d1dbdc37bce;hb=bd548bb6f007d0b106a241480676bbc18196bdc8;hpb=ea559cf143beb9b6305293a355a66fef1a0bed4a diff --git a/decode.cpp b/decode.cpp index c9a5ded..e85f579 100644 --- a/decode.cpp +++ b/decode.cpp @@ -1,32 +1,25 @@ #include #include #include -#include #include #include #include #include +#include "audioreader.h" #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 &pcm, int x) { @@ -63,14 +56,9 @@ int main(int argc, char **argv) { make_lanczos_weight_table(); std::vector pcm; - - while (!feof(stdin)) { - short buf[BUFSIZE]; - ssize_t ret = fread(buf, 2, BUFSIZE, stdin); - if (ret >= 0) { - pcm.insert(pcm.end(), buf, buf + ret); - } - } + if (!read_audio_file(argv[1], &pcm)) { + exit(1); + } #if 0 for (int i = 0; i < LEN; ++i) {