]> git.sesse.net Git - audiosync/commitdiff
Add a program to simulate a bad oscillator.
authorsgunderson@bigfoot.com <>
Thu, 28 Dec 2006 01:31:19 +0000 (02:31 +0100)
committersgunderson@bigfoot.com <>
Thu, 28 Dec 2006 01:31:19 +0000 (02:31 +0100)
gen-random-skew.c [new file with mode: 0644]

diff --git a/gen-random-skew.c b/gen-random-skew.c
new file mode 100644 (file)
index 0000000..59d3fb6
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+int main(int argc, char **argv)
+{
+       unsigned num_samples = atoi(argv[1]);
+       
+       srand(time(NULL));
+       double r = 1.005; // some overall skew just to be evil
+
+       for (unsigned i = 0; i < num_samples; ++i) {
+               double r_delta = 3e-6 * (rand() / (RAND_MAX+1.0) - .5);
+               r += r_delta;
+
+               fwrite(&r, sizeof(double), 1, stdout);
+
+               if (i % 44100 == 0) {
+                       fprintf(stderr, "%lf\n", r);
+               }
+       }
+}