test program to generate sine waves
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 10 Nov 2010 03:01:26 +0000 (03:01 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 10 Nov 2010 03:01:26 +0000 (03:01 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@211 01035d8c-6547-0410-b346-abe4f91aad63

codec2/unittest/mksine.c [new file with mode: 0755]

diff --git a/codec2/unittest/mksine.c b/codec2/unittest/mksine.c
new file mode 100755 (executable)
index 0000000..2383e79
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+  mksine.c
+  David Rowe 
+  10 Nov 2010
+
+  Creates a file of sine wave samples.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#define TWO_PI     6.283185307
+#define N          8000
+#define FS         8000.0
+#define AMP        1000.0
+
+int main(int argc, char *argv[]) {
+    FILE *f;
+    int   i;
+    float freq;
+    short buf[N];
+
+    if (argc != 3) {
+       printf("usage: mksine outputFile frequencyHz\n");
+       exit(0);
+    }
+
+    f = fopen(argv[1] ,"wb");
+    freq = atof(argv[2]);
+
+    for(i=0; i<N; i++)
+       buf[i] = AMP*cos(freq*i*(TWO_PI/FS));
+
+    fwrite(buf, sizeof(short), N, f);
+
+    return 0;
+}