
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;
else
{
if(phase < 0.5)
yp = 1.0  phase;
else
yp = phase;
}
x = yp * PI;
x2 = x*x;
//Taylor expansion out to x**9/9! factored into multiplyadds
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];
} 
Comments
Added on : 23/01/11 by barbarawright[ AT ]mail15[ DOT ]com Comment : The <a href="http://bestfinanceblog.com">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! 



