[sdiy] OT - Linear interpolation in C

Olivier Gillet ol.gillet at gmail.com
Sun Jan 30 19:18:50 CET 2011


> /* arranged to have only one multiply and two adds */
> interp = this + index * ((next - this) >> 8);

Does this trick works well on the dspic?

Unless your wavetable has no big discontinuities, (next - this) needs
to be "one size larger" than next and this. For example, if next and
this are signed 16 bits ints, (next - this) >> 8 only fits in a 16 bit
signed int, not in an 8 bits signed int, so the index * ((next - this)
>> 8) multiplication is 8 x 16 instead of 8 x 8.

I remember having used it on ARM and x86, but not on AVR, since the
switch from an 8 bits operand to a 16 bits operand made things slower
than the "unoptimized" expression.



More information about the Synth-diy mailing list