Just use Y = sin(theta). You don’t need to complicate anything by using Euler’s formula.
btb4198 said:
I know that sinewaves have two part to them a positive frequency and neg frequency.
No. Sine waves only have one frequency, but the output value (amplitude) of a sin function like your C# function has a peak to peak range from -1 to +1.
That’s because the trig functions are based on a unit circle (radius 1) centered at the origin of a given coordinate system (i.e. circle centered at 0,0). Both the x and y components of all the points on the circumference of that circle range from negative one to positive one.
You can scale that range to anything you like, such as 0.05 as you did in your original post. Then you have
Y = 0.05 * sin( t * some_number);
Where some_number = 1000 * 2 * pi / 44100;
This will give you a range from -0.05 to positive 0.05. If you don’t want negative values for some reason, you can translate the waveform by adding 0.05, so your formula is
Y = (0.05 * sin( t * some_number) ) + 0.05;
That will give you a positively biased sin wave with values ranging from 0 to 0.1. However, since this is being used for an audio type application, you should not be concerned with negative values. They will work just fine, and that is probably what you want anyway.
------------------------------------------------------------------------------------------
Here is a hint for making you code work.
1: To start out, forget about the input frequency, amplitude, and beat, and also leave out the counter, beat code. Just hard-code some frequency and amplitude sine wave and get that to work.
2: When that works, switch over to using the input frequency and amplitude and get that to work.
3: When that works add the beat code and make that part work.