I know that sinewaves have two part to them a positive frequency and neg frequency. I am out put a sinewave 0.05 * (sine(1000 *t 2*pi*)/44100) and I am get two frequencies but i only want one.. so can I change sin x = 1/2 i (e^(-ix) - e^(ix) ) to sin x = e^(ix) so it would be f(t) = 0.05 * (e^(i(1000 *t*2*pi))/4410) would that just give me 1000Hz? and not add any other Frequencies to it?
No. But I don't understand how you are getting two frequencies. ##y=A\sin \omega t: \omega = 2\pi f## ... only has the one frequency. You could try: ##\sin\omega t = \Im [e^{i\omega t}]## ... that help?
Are you worrying about the fact that use of a mathematical identity is giving you something unexpected in the 'real world? This is a common problem. Even the roots of a simple quadratic can have values that are impossible in practice. It's is fine (very useful, in fact) to use the exponential version of a simple sinusoidal waveform but you need to bear in mind that the answers you get from your calculations often have an implied "real part of" in front of them. You can do all the calculations with sines and coses and never get involved with the exponential form but it gets very 'lumpy'. The 'negative frequency' that your calculations imply has a reality when you amplitude modulate a carrier, where the sidebands are above and below the carrier frequency (positive and negative relative to it).
If you're concerned with the negative frequency you may also chose to use a sine transform instead of a full Fourier transform.
"If you're concerned with the negative frequency you may also chose to use a sine transform instead of a full Fourier transform." what do you mean ?
what do you mean by "The 'negative frequency' that your calculations imply has a reality when you amplitude modulate a carrier, where the sidebands are above and below the carrier frequency (positive and negative relative to it) "
Please show us the code that gives you two frequencies. trig functions in C# http://www.dotnetperls.com/cos-sin-tan
This is what I just tried it did not work Code (Text): wavefile = new WaveFileWriter(save1.FileName, tone.WaveFormat); double counter2 = 0; double Frequency3 = Convert.ToDouble(FREtx3.Text); double Amplitude3 = Convert.ToDouble(PeakTXT3.Text); Beat = Convert.ToDouble(isochronictxt.Text); if (Beat != 0) { Beat = (1 / Beat); } else { Beat = 0; } for (int n = 0; n < time; n++) { if (counter2 >= Beat) { for (int t = 0; t < 10000; t++) { wavefile.WriteSample(0F); wavefile.WriteSample(0F); } counter2 = 0; } else { Complex R = Amplitude3 * (Complex.Exp((-Complex.ImaginaryOne * Math.PI * n *2D* Frequency3/ 44100D))); wavefile.WriteSample((float) Math.Abs( R.Magnitude)); Complex L = Amplitude3 * (Complex.Exp((-Complex.ImaginaryOne * Math.PI * n * 2D * Frequency3/44100D))); wavefile.WriteSample((float)Math.Abs(L.Magnitude)); counter2 = counter2 + (1D / 44100D); } } wavefile.Flush(); wavefile.Dispose(); file.Add(save1.FileName); I tired with an -I and without an I both did not work
this is what I am using now : Code (Text): wavefile = new WaveFileWriter(save1.FileName, tone.WaveFormat); double counter2 = 0; double Frequency3 = Convert.ToDouble(FREtx3.Text); double Amplitude3 = Convert.ToDouble(PeakTXT3.Text); Beat = Convert.ToDouble(isochronictxt.Text); if (Beat != 0) { Beat = (1 / Beat); } else { Beat = 0; } for (int n = 0; n < time; n++) { if (counter2 >= Beat) { for (int t = 0; t < 10000; t++) { wavefile.WriteSample(0F); wavefile.WriteSample(0F); } counter2 = 0; } else { Complex R = Amplitude3 * (Complex.Sin((Math.PI * n *2D* Frequency3/ 44100D))); wavefile.WriteSample((float) Math.Abs( R.Magnitude)); Complex L = Amplitude3 * (Complex.Sin((Math.PI * n * 2D * Frequency3/44100D))); wavefile.WriteSample((float)Math.Abs(L.Magnitude)); counter2 = counter2 + (1D / 44100D); } } wavefile.Flush(); wavefile.Dispose(); file.Add(save1.FileName); and this is how it looks on a graph :
this is how it sounds https://onedrive.live.com/redir?resid=CC8AF223519E2440!114&authkey=!ADGTKdZEpF4F4Q4&ithint=file,.wav you can hear the other frequency
I can't help but wonder why the OP is tackling this with a computer (numerical) approach. It just adds another layer if possible errors and misunderstanding. What is wrong with doing it analytically? Hopping about amongst digital models will always bring in the possibility of problems.
Just use Y = sin(theta). You don’t need to complicate anything by using Euler’s formula. 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.
I think he is trying to program something, not trying to analyse something. It's as if he is given some user specified input for frequency and amplitude, and it is his job to play it back via computer.
Why not work out the answer 'properly' and then use a program to produce the figures for the output? In a straightforward case like this, the code is very easy to write and you don't need to be doing any 'DSP' tricks. (It is also a good way of understanding the basics.)
Ok, I listened to the .wav file and it sounds fine. How is it different from what you were expecting? If you are concerned about that kind of a ‘click’ to the sound, it’s probably because you are enveloping a sine wave inside of (basically) a square wave. In other words (aside from some slight sawtooth effect) each pulse or burst goes straight from 0 to full volume, and then cuts off from full volume to zero. The square wave itself is composed of many frequencies (odd harmonics). You can probably alleviate all that by modifying the code to include a volume ramp-up at the beginning of each pulse, and also a ramp-down at the end. [Edit] (deleted) Picture of sine wave vs absolute value of sine wave. Not completely sure if there will be much difference in the sound of the audio, but if I were you I would take out the absolute value just to give it a try.