[sdiy] Micro as a Linear to Exponential converter?
Antti Huovilainen
ajhuovil at cc.hut.fi
Fri Aug 14 13:10:51 CEST 2009
On Fri, 14 Aug 2009, Tom Wiltshire wrote:
> I'd just like to agree with Colin's outlined scheme above. I've done similar
> things. Antti's comment that "the code part is trivial" is a bit misleading,
> IMO.
I meant that when you have the generic MCU thing working, the exponential
conversion (read: interpolated table lookup) itself truly is trivial. You
can just write it all in C. MCUs are plenty fast nowadays.
Example code below:
unsigned short noteTable[128];
// note = 0..126, frac = 0..65535 (equivalent to 0..0.99999)
unsigned short expo(short note, unsigned short frac)
{
long l1, l2, f, y;
f = frac;
l1 = noteTable[note];
l2 = noteTable[note+1];
y = l1 * 65536L + (l2-l1)*frac;
return (unsigned short) (y >> 16);
}
Antti
"No boom today. Boom tomorrow. There's always a boom tomorrow"
-- Lt. Cmdr. Ivanova
More information about the Synth-diy
mailing list