[sdiy] Approximating sine with plain integer math

John Ames commodorejohn at gmail.com
Thu Apr 7 05:41:51 CEST 2016


On 4/6/16, Brian Willoughby <brianw at audiobanshee.com> wrote:
> I can't see the overflow in Grapher.app, but I suppose it could be
> outputting +1.0 when the maximum fixed-point value would be 1 code less than
> that. How much overflow are you seeing? I haven't bothered to try the C
> code, I just typed the functions into Grapher.app and zoomed in.
Yep, it's just that one point over the limit (the function without
correction produces values from e.g. -32768 to 32768 in a 16-bit
limit.) The problem is that that one point over pushes it around from
e.g. 32767 to -32768, so it's not a slight clipping but a full-volume
single-sample pop. The corrected function reduces the volume before
the final multiplication, so it stays safely at e.g. -32764 to 32764.



More information about the Synth-diy mailing list