aboutsummaryrefslogtreecommitdiff
path: root/tools/lookuptablemaker.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lookuptablemaker.c')
-rw-r--r--tools/lookuptablemaker.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/lookuptablemaker.c b/tools/lookuptablemaker.c
new file mode 100644
index 0000000..f16420a
--- /dev/null
+++ b/tools/lookuptablemaker.c
@@ -0,0 +1,29 @@
+// Example sine lut generator
+#include <stdio.h>
+#include <math.h>
+
+#define M_PI 3.1415926535f
+#define SIN_SIZE 512
+#define SIN_FP 12
+
+int main()
+{
+ int ii;
+ FILE *fp= fopen("sinlut.c", "w");
+ unsigned short hw;
+
+ fprintf(fp, "//\n// Sine lut; %d entries, %d fixeds\n//\n\n",
+ SIN_SIZE, SIN_FP);
+ fprintf(fp, "const short sin_lut[%d]=\n{", SIN_SIZE);
+ for(ii=0; ii<SIN_SIZE; ii++)
+ {
+ hw= (unsigned short)(sin(ii*2*M_PI/SIN_SIZE)*(1<<SIN_FP));
+ if(ii%8 == 0)
+ fputs("\n\t", fp);
+ fprintf(fp, "0x%04X, ", hw);
+ }
+ fputs("\n};\n", fp);
+
+ fclose(fp);
+ return 0;
+}