<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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?</blockquote><div><br></div><div>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...)</div><div><br></div><div>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!</div><div><br></div><div>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?</div></div></div></div>