Main Archive Specials Wiki | FAQ Links Submit Forum

Sine calculation

Type : waveform generation, Taylor approximation of sin()
References : Posted by Phil Burk

Notes :
Code from JSyn for a sine wave generator based on a Taylor Expansion. It is not as efficient as the filter methods, but it has linear frequency control and is, therefore, suitable for FM or other time varying applications where accurate frequency is needed. The sine generated is accurate to at least 16 bits.

Code :
for(i=0; i < nSamples ; i++)
//Generate sawtooth phasor to provide phase for sine generation
IncrementWrapPhase(phase, freqPtr[i]);
//Wrap phase back into region where results are more accurate

if(phase > 0.5)
yp = 1.0 - phase;
if(phase < -0.5)
yp = -1.0 - phase;
yp = phase;

x = yp * PI;
x2 = x*x;

//Taylor expansion out to x**9/9! factored into multiply-adds
fastsin = x*(x2*(x2*(x2*(x2*(1.0/362880.0)
- (1.0/5040.0))
+ (1.0/120.0))
- (1.0/6.0))
+ 1.0);

outPtr[i] = fastsin * amplPtr[i];


Added on : 23/01/11 by barbarawright[ AT ]mail15[ DOT ]com
Comment :
The <a href="">loan</a> are essential for people, which want to organize their career. By the way, this is not very hard to receive a commercial loan.

Add your own comment
Comments are displayed in fixed width, no HTML code allowed!


Are you human?

Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion