View Single Post
Old 08-22-2016, 12:11 PM   #87
teatime
Human being with feelings
 
teatime's Avatar
 
Join Date: Aug 2016
Location: South Africa
Posts: 44
Default Quick Sine

This is a dirt-cheap quadratic approximation of a sine:

B = 4/$PI;
C = -4/($PI*$PI);

function quicksine(x) local(y)
(
y = B*x + C*x*abs(x);
y = 0.225 * (y * abs(y) - y) + y;
y;
);

Haven't listened to it, but it does pretty well as an LFO.

NB: Only valid between -PI and PI. Discovered here: http://forum.devmaster.net/t/fast-an...ne-cosine/9648

I recommend following the link, there are varying levels of accuracy to be had with this approximation, depending on what you're optimising for.
teatime is offline   Reply With Quote