[sdiy] Approximating sine with plain integer math

Olivier Gillet ol.gillet at gmail.com
Thu Apr 7 21:06:02 CEST 2016

> Obviously a good quality table look-up costs a reasonable amount of memory
> for the table, and should have at least a linear-interp between table
> values, but that still seems simpler than a lot of this. Is there some
> other reason a numerical approach is preferred?

A couple of months ago I posted here about my experiments in cramming as
many band-limited sawtooth oscillators as possible in a STM32F4 (I have
found another algorithm for that by the way...)

I also tried doing the same for sine oscillators, so I benchmarked both the
"magic circle" algorithm and the interpolated lookup. The former is about
3x faster. In ARM assembly, once state variables are loaded in registers -
which can be done for the duration of a block of 16 samples or so - the
code is exactly 2 instructions: one multiply and add ; and one multiply and
subtract. Table lookup with linear interpolation: one address computation
on the phase counter, two loads, then one subtraction and one MAC for the
linear interpolation. The memory lookups are what slow things down (RAM is
fast but scarce, flash has wait states). On a slower MCU without a MAC
instruction, the lookup table is still a good approach though!

About the waveshaping approach suggested by John: doesn't it introduce
aliasing at high frequencies? What happens to the shape of the output if
the input sawtooth is band-limited?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20160407/15a43335/attachment.htm>

More information about the Synth-diy mailing list