blob: f16420adfbb6eecad2849038e38b16cf408fd7bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}
|