Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float return_fsaw(int time, int osc_id)
- {
- float time_to_rad = ((float)time/ONESECOND)*(2*M_PI); //where ONESECOND is the number of pixels representing one second. the program draws the wave by looping through incrementing time by 1 to draw the wave form of one second.
- float value=0;
- int i = 0;
- for (i=1; i<=oscArray[osc_id]->fourier; i++)
- {
- value += (pow(-1, i))*((sin(i*oscArray[osc_id]->freq*time_to_rad))/i);
- }
- value = (2/M_PI)*value;
- if (value >1) printf("F.Saw: value exceeded 1. Value = %f, time = %d, time_to_rad = %f\n", value, time, time_to_rad);
- return value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement