]> git.sesse.net Git - audiosync/commitdiff
Fix more bugs in estimate-skew.
authorsgunderson@bigfoot.com <>
Thu, 28 Dec 2006 13:59:38 +0000 (14:59 +0100)
committersgunderson@bigfoot.com <>
Thu, 28 Dec 2006 13:59:38 +0000 (14:59 +0100)
estimate-skew.c

index d2991fc32cafe04f89a5d921951ee3afce2f8e7c..e8ba75ea41c5b2bc68415751940738270dafee6d 100644 (file)
@@ -11,7 +11,7 @@ double frac(double x)
 double filter(double x)
 {
        static double l = 0.0;
-       l = 0.01 * x + 0.99 * l;
+       l = 0.001 * x + 0.999 * l;
        return l;
 }
 
@@ -54,8 +54,8 @@ int main(int argc, char **argv)
 
        short prev_sample, sample = 0;
        int in_pos = -1;
-       double p = -1.0;
-       double speed = 1.0;
+       double p = 0.0;
+       double speed = 1.001;
 
        while (!feof(in1) && !feof(in2)) {
                short refs;
@@ -82,9 +82,9 @@ int main(int argc, char **argv)
                // subtract the two samples and pull it through a filter. we assume
                // the sines are normalized for now (and that there's no dc skew)
                double offset = filter(intp_sample - refs);
-               speed -= 0.00000001 * offset;
+               speed += 1e-8 * offset;
                fwrite(&speed, sizeof(double), 1, skew);
 
-               printf("%f (offset=%f)\n", speed, intp_sample - sample);
+               printf("%f (offset=%f / filt=%f)\n", speed, intp_sample - refs, offset);
        }
 }