[sdiy] Logs on a micro? Was: Reverse engineer an EPROM encoding?
rsdio at sounds.wa.com
rsdio at sounds.wa.com
Wed Nov 13 07:29:06 CET 2013
I believe "exponential" is the more general term, but it might be
"logarithmic."
There's no need to avoid floating point, just make sure you convert
the result to 12-bit integer with the correct scaling. e.g. if your
floating point calculation ranges from 0.0 to < 1.0, then simply
multiply the result by 2048 and round. Not sure what you do for the
sign bit.
I recommend that you create a short array[0x010000] to hold the
calculated results of the conversion, then simply use faster lookups
to translate from your original samples to the 12-bit format. Using
float, you might even be able to start with 24-bit samples and
maintain slightly more resolution than if you convert to 16-bit
before converting to the log-12 format. In other words, you could go
directly from 24-bit to 12-bit log.
Brian Willoughby
Sound Consulting
p.s. I spent a while investigation exponential curves in order to map
a control value to LED brightness while accounting for the gamma
curve. Taylor Series allow you to approximate exponential functions
on something like an 8-bit micro, but you might as well use the full
32-bit float math libraries - provided that they're not also taking
short cuts that have insufficient accuracy.
On Nov 12, 2013, at 19:27, MTG wrote:
> OK, thanks for the tip. I'm *assuming* "log" is the correct word
> here, but in any event it is their "compression" technique. I was
> able to perform some tests to validate the basic operation... I
> created a small table of values that output a linear ramp from the
> drum machine over it's full range.
>
> I'm doing the computation on a PC, not a micro, but since the
> result has to be stuffed in an 16 or 12 bit number, I need to avoid
> the floating point mess that a typical PC program would use. I need
> the result to be in a format that the drum machine understands (16-
> bit data, 12 of which are used and one of those is a sign bit).
>
> GB
More information about the Synth-diy
mailing list