summaryrefslogtreecommitdiffstats
path: root/look_up_table_gen.cpp
blob: 6f3867f80d7f4253bee4653f16f72655880ea1df (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
30
31
32
33
34
35
#include <cmath>
#include <iostream>

int main()
{
	const int SAMPLES=16;

	std::cout<<"int sine_table["<<SAMPLES<<"]={";
	
	for(int i=0; i<SAMPLES; ++i)
	{
		if(i==0)
			std::cout<<(int)(0.5*pow(2, 16))<<",";
		else
			std::cout<<(int)(((1+std::sin((long double)i*(long double)2*M_PIl/(long double)SAMPLES))/2)*(pow(2, 16)-1))<<",";
	}

	std::cout<<"};\nint triangle_table["<<SAMPLES<<"]={";

	for(int i=0; i<SAMPLES; ++i)
	{
		if(i<SAMPLES/2)
		{
			std::cout<<(int)((long double)i/(long double)SAMPLES*2*(pow(2, 16)-1))<<",";
		}
		else
		{
			std::cout<<(int)((long double)(SAMPLES-i)/(long double)SAMPLES*2*(pow(2, 16)-1))<<",";
		}
	}

	std::cout<<"};\n";
	
	return 0;
}