11 int main(int argc, char **argv)
13 FILE *in, *skew, *out;
16 if (strcmp(argv[1], "-") == 0) {
19 in = fopen(argv[1], "rb");
27 if (strcmp(argv[2], "-") == 0) {
30 skew = fopen(argv[2], "rb");
38 if (strcmp(argv[3], "-") == 0) {
41 out = fopen(argv[3], "wb");
48 short prev_sample, sample = 0;
52 while (!feof(in) && !feof(skew)) {
54 if (fread(&delta_p, sizeof(double), 1, skew) != 1) {
60 // read samples until we're at the right position
61 while ((int)(ceil(p)) > in_pos) {
63 if (fread(&sample, sizeof(short), 1, in) != 1) {
69 // linear interpolation (works well since delta_p varies so slowly)
71 short intp_sample = prev_sample * (1.0 - t) + sample * t;
73 fwrite(&intp_sample, sizeof(short), 1, out);