- FILE *fp = fopen(argv[1], "rb");
- fseek(fp, 14, SEEK_SET);
-
- int x = 0;
-
- while (!feof(fp)) {
- int len = getc(fp);
- int cycles;
- if (len == 0) {
- int a = getc(fp);
- int b = getc(fp);
- int c = getc(fp);
- cycles = a | (b << 8) | (c << 16);
- } else {
- cycles = len * 8;
- }
- pulse p;
- p.start = float(x) * WAVE_FREQ / C64_FREQ;
- p.end = (float(x) + cycles * 0.5) * WAVE_FREQ / C64_FREQ;
- pulses.push_back(p);
- x += cycles;
- }
-
- int len_cycles = x;
- int len_samples = int(ceil(float(len_cycles) * WAVE_FREQ / C64_FREQ));