On Wed, Oct 19, 2016 at 4:25 PM, Jonathan Wilkes jancsika@yahoo.com wrote:
When implemented in C, which approach takes the least amount of time to read, reason about, and fully comprehend?
That is an important question. Pd code is full of clever tricks and bit hacks for dsp efficiency. What is the origin of q8_rsqrt(), why and how does it work? What about PD_BIGORSMALL() in m_pd.h? And the mysterious UNITBIT32 number in d_osc.c? Ideally such code should be commented not only to denote its function (if necessary) but also to reference the origin so you may be able to find info.
An approximation for a trig function should go in an (inline) function, with a comment if the name can't clarify the function sufficiently. But to fully comprehend is a different matter. Dsp code in general takes substantial background to understand. You could wonder why and how the approximation works, but the same question goes for the function that it replaces.
And if we're not talking hot code then the answer of which answer arrived in less time should (at least in large part) dictate which method to use, shouldn't it?
-Jonathan
Katja