"Adrian Spilca" <adsp40@spamGuard_yahoo.co.uk> wrote in message
news:
[email protected]...
> Bob wrote:
>
> > <
[email protected]> wrote in message
> > news:
[email protected] oups.com...
> >> Hello All,
> >>
> >> Can anyone please help me in implementing exp10(x) in a fixed point C.
> >> I need to convert a dB value ( 0 to 50 dB) to linear domain value. This
> >> is for a 16-bit DSP application.
> >>
> >> Thanks and Regards,
> >>
> >> Patrick
> >
> > easy.
> >
> > outputVal = exp10Table[ inputVal ];
> >
> > very fast, too.
> >
> > Of course, exp10Table will consume 128k bytes. Is that a problem? ;-)
> > If you can spare the time for a MAC or two (or three), the lookup tables
> > can be *tiny*. The first step in coding any integer approximation
function
> > is usually writing the desired function using floating point. (You'll
need
> > to test your integer code against it.)
> >
> > e.g.
> > int16 LibFunc( int16 inVal )
> > { return (int)( 65535* whateverFunction((float)(inVal) / 256.0)); }
> >
> > Bob
>
> Not quite integer... Patrick was talking about fixed point.
> And in the second post he mentioned "precision", 128 values might not be
> enough.
>
> But the table method is not a bad idea, I was actually thinking about
table
> lookup and interpolation.
>
> Adrian
Hi Adrian,
Yes, I made some pretty wild assumptions since Patrick hasn't really defined
the problem (how many bits wide and where is the radix of the input and
output? How much error is tolerable? How many MACs can he afford?). If you
assume 16bit in and 16bit out (doesn't matter what the bits represent -
fixed, float, Spanish, etc.) then a 64k*2byte table *will* do it in a single
lookup op. You'ld have to be awfully short on time and long on space to do
it that way, though ;-)
Bob
hint to Patrick: convert your dB to bB (binaryBell - not deciBell). The exp2
is easier than exp10 in a binary world.