[sdiy] Approximating sine with plain integer math

Olivier Gillet ol.gillet at gmail.com
Thu Apr 7 09:47:10 CEST 2016


>
> I dug up the following code, but it's not from a shipping product, and I'm
> not sure I remember how it works.


This is the "modified coupled form" algorithm, sometimes called "magic
circle algorithm":

https://ccrma.stanford.edu/~jos/pdf/GordonAndSmith86.pdf

It works fairly well in fixed point too - the rounding errors manifest
themselves as a small DC offset, rather than as a loss of amplitude.

Unlike a direct form, second order filter (the recurrence y = 2 * coeff *
y_ - y__), this algorithm handles coefficient changes pretty well -
actually, any value of the sinZ and cosZ variable correspond to a valid
state of the filter.

And you can get away with the sinf in the constructor (or in your buffer
filling routine if you allow FM) because an appropriate polynomial
approximation of degree 3 of sinf would introduce only a few cents of
tuning error in the high frequencies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20160407/8d7ee493/attachment.htm>


More information about the Synth-diy mailing list