#define PI 3.141592653 float sin_data[1024]; void sin_wave(float Amplitude, float Period, float Horizontal) { unsigned int i; for(i = 0;i < 1024; i++) { sin_data[i] = Amplitude * sin( 2 * PI / Period * i + Horizontal ); } }
#define PI 3.141592653 float triangle_data[1024]; void triangle_wave(float Amplitude, float Period, float Horizontal) { unsigned int i; for(i = 0;i < 1024; i++) { triangle_data[i] = Amplitude * asin(sin( 2 * PI / Period * i + Horizontal )) / PI * 2; } }
#define PI 3.141592653 float trapezoid_data[1024]; void trapezoid_wava(float Amplitude, float Period, float Horizontal) { unsigned int i; float y; for(i = 0;i < 1024; i++) { trapezoid_data[i] = Amplitude * asin(sin( 2 * PI / Period * i + Horizontal )); if( trapezoid_data[i] >= Amplitude) trapezoid_data[i] = Amplitude; if( trapezoid_data[i] <= -Amplitude) trapezoid_data[i] = Amplitude; } }
#define PI 3.141592653 float square_data[1024]; void square_wave(float Amplitude, float Period, float Horizontal) { unsigned int i; for(i = 0;i < 1024; i++) { square_data[i] = Amplitude * sin( 2 * PI / Period * i + Horizontal ); } if( square_data[i] > 0) square_data[i] = Amplitude; else if(square_data[i] < 0) square_data[i] = -Amplitude; }