Main Archive Specials Wiki | FAQ Links Submit Forum

Cheap pseudo-sinusoidal lfo

References : Posted by fumminger[AT]umminger[DOT]com

Notes :
Although the code is written in standard C++, this algorithm is really better suited for dsps where one can take advantage of multiply-accumulate instructions and where the required phase accumulator can be easily implemented by masking a counter.

It provides a pretty cheap roughly sinusoidal waveform that is good enough for an lfo.

Code :
// x should be between -1.0 and 1.0
double pseudo_sine(double x)
// Compute 2*(x^2-1.0)^2-1.0
x *= x;
x -= 1.0;
x *= x;
// The following lines modify the range to lie between -1.0 and 1.0.
// If a range of between 0.0 and 1.0 is acceptable or preferable
// (as in a modulated delay line) then you can save some cycles.
x *= 2.0;
x -= 1.0;


Added on : 31/03/04 by bekkah[ AT ]web[ DOT ]de
Comment :
You forgot a

return x;

Added on : 05/04/04 by fumminger[ AT ]umminger[ DOT ]com
Comment :
Doh! You're right.


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