DSPRelated.com
Forums

Fast int array to float array convert.

Started by Steve Holle October 19, 2004

I'm using a 21065L and am trying to find the quickest way to split an
interleaved integer array into two float arrays.

Details :
My input array consists of 128 samples of codec data as
i1,i0,i1,i0,i1,i0,i1,i0...
I need to convert this into two separate float arrays as :
f1,f1,f1,f1...
f0,f0,f0,f0...

Currently I'm doing something like this :
r2 = dm(_l_NumPairs) ;
LCNTR=r2 , DO xfer UNTIL LCE ; //
Loop through the input array by twos.
r0 = dm(i4,m4) ; //
Get sample for zero.
f1 = float r0 ; //
Convert it to float.
dm(i2,m1) = r1 ; //
Store it in output zero.
r0 = dm(i4,m4) ; //
Get sample for one.
f1 = float r0 ; //
Convert it to float.
xfer: dm(i1,m1) = r1 ; //
Store it in output one.

Is there any way to eliminate the intermediate r0 assignment?
Should either the input or output array be in code memory space? Would it
make a difference?

Thanks.

Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT 59101





Steve Holle wrote:
...
> Currently I'm doing something like this :
> r2 = dm(_l_NumPairs) ;
> LCNTR=r2 , DO xfer UNTIL LCE ;
> r0 = dm(i4,m4) ;
> f1 = float r0 ;
> dm(i2,m1) = r1 ;
> r0 = dm(i4,m4) ;
> f1 = float r0 ;
> xfer: dm(i1,m1) = r1 ;
>
> Is there any way to eliminate the intermediate r0 assignment?
No. Steve, you write assembler code like a c compiler (no offense :-).

> Should either the input or output array be in code memory space?
> Would it make a difference?
Yes. Try this (assume that the float array is in pm, i10 is the
corresponding pointer and m9 = m1):

r2 = dm(_l_NumPairs) ;
r2=r2-1, r0 = dm(i4,m4) ;
f1 = float r0 , r0 = dm(i4,m4);

LCNTR=r2 , DO xfer UNTIL LCE ;
f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;
xfer: f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;

f1 = float r0, pm(i10,m9) = f1 ;
pm(i10,m9) = f1 ;

This code should run three times faster than your original.

Regards,
Andor





hai all,

i am devoloping digital effect and recorder
in one module.
in that for 16 bit to 8 bit and vice versa conversion
i had applied
mu_law companding.

when i am recording plain sound is good and
delay,flange and
chorous recording also very fine...but when i am
recording reverb more
noise adding (hissing noise).for this i had applied
fir filter.hissing
noise solved...but for low volume like end of guitar
play more noise
adding..

is there any idea to solve this problem.kindly let
me know.

thanks in advance...

with kind regards
ayyams

________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony




On Tue, 19 Oct 2004, Steve Holle wrote:

>
>
> I'm using a 21065L and am trying to find the quickest way to split an
> interleaved integer array into two float arrays.
>
> Details :
> My input array consists of 128 samples of codec data as
> i1,i0,i1,i0,i1,i0,i1,i0...
> I need to convert this into two separate float arrays as :
> f1,f1,f1,f1...
> f0,f0,f0,f0...
>
> Currently I'm doing something like this :
> r2 = dm(_l_NumPairs) ;
> LCNTR=r2 , DO xfer UNTIL LCE ; //
> Loop through the input array by twos.
> r0 = dm(i4,m4) ; //
> Get sample for zero.
> f1 = float r0 ; //
> Convert it to float.
> dm(i2,m1) = r1 ; //

I'd have done it

r1 = dm(i4,m4);
f1 = float r1;
dm(i2,m1) = f1;

Which is really the same thing, but you only use one register.

>
> Is there any way to eliminate the intermediate r0 assignment?

Nope.

> Should either the input or output array be in code memory space? Would it
> make a difference?

It could, depending on what you do with the data later. If you take
more than 32 instructions in cache it won't make any difference at all,
but if you do this in a long loop of less than 32 instructions then
you can go a lot faster.

If you do dual ram access in one instruction then putting the data in pm
rather than dm can be helpful. If you're not needing that kind of memory
access, then staying in dm space is easier to think about.

Patience, persistence, truth,
Dr. mike




>No. Steve, you write assembler code like a c compiler (no offense :-).

Yah, I just cannot get my brain around parallel processing. Everything
looks linear to me until someone explains it. I need a brain transplant :D
Your example was just what I was looking for. Thanks. > > Should either the input or output array be in code memory space?
> > Would it make a difference?
>Yes. Try this (assume that the float array is in pm, i10 is the
>corresponding pointer and m9 = m1):
>
>r2 = dm(_l_NumPairs) ;
>r2=r2-1, r0 = dm(i4,m4) ;
>f1 = float r0 , r0 = dm(i4,m4);
>
>LCNTR=r2 , DO xfer UNTIL LCE ;
> f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;
>xfer: f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;
>
>f1 = float r0, pm(i10,m9) = f1 ;
>pm(i10,m9) = f1 ;
>
>This code should run three times faster than your original.
>
>Regards,
>Andor >_____________________________________
>Note: If you do a simple "reply" with your email client, only the author
>of this message will receive your answer. You need to do a "reply all" if
>you want your answer to be distributed to the entire group.
>
>_____________________________________
>About this discussion group:
>
>To Join: Send an email to
>
>To Post: Send an email to
>
>To Leave: Send an email to
>
>Archives: http://groups.yahoo.com/group/adsp
>
>Other Groups: http://www.dsprelated.com/groups.php3
>
>Yahoo! Groups Links >
>

Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT 59101



Hi,

Does your noise come from quantization, maybe? What
precision are you using? 16 bit fixed point, 32 bit
fixed point, 32 bit floating point?

Would a noise gate help?

JaaC --- ayyam perumal <> wrote:

>
>
> hai all,
>
> i am devoloping digital effect and recorder
> in one module.
> in that for 16 bit to 8 bit and vice versa
> conversion
> i had applied
> mu_law companding.
>
> when i am recording plain sound is good and
> delay,flange and
> chorous recording also very fine...but when i am
> recording reverb more
> noise adding (hissing noise).for this i had applied
> fir filter.hissing
> noise solved...but for low volume like end of guitar
> play more noise
> adding..
>
> is there any idea to solve this problem.kindly
> let
> me know.
>
> thanks in advance...
>
> with kind regards
> ayyams
________________________________________________________________________
> Yahoo! India Matrimony: Find your life partner
> online
> Go to: http://yahoo.shaadi.com/india-matrimony > _____________________________________
> Note: If you do a simple "reply" with your email
> client, only the author of this message will receive
> your answer. You need to do a "reply all" if you
> want your answer to be distributed to the entire
> group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to > To Post: Send an email to
>
> To Leave: Send an email to > Archives: http://groups.yahoo.com/group/adsp
>
> Other Groups: http://www.dsprelated.com/groups.php3
>
> Yahoo! Groups Links >


=====

Jaime Andr Aranguren Cardona

__________________________________________________







>Yes. Try this (assume that the float array is in pm, i10 is the
>corresponding pointer and m9 = m1):
>
>r2 = dm(_l_NumPairs) ;
>r2=r2-1, r0 = dm(i4,m4) ;
>f1 = float r0 , r0 = dm(i4,m4);
>
>LCNTR=r2 , DO xfer UNTIL LCE ;
> f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;
>xfer: f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;
>
>f1 = float r0, pm(i10,m9) = f1 ;
>pm(i10,m9) = f1 ;
>
>This code should run three times faster than your original.
>
>Regards,
>Andor

Is there a way to turn this around so that my float output arrays are in dm
and my integer input arrays are in pm?
>_____________________________________
>Note: If you do a simple "reply" with your email client, only the author
>of this message will receive your answer. You need to do a "reply all" if
>you want your answer to be distributed to the entire group.
>
>_____________________________________
>About this discussion group:
>
>To Join: Send an email to
>
>To Post: Send an email to
>
>To Leave: Send an email to
>
>Archives: http://groups.yahoo.com/group/adsp
>
>Other Groups: http://www.dsprelated.com/groups.php3
>
>Yahoo! Groups Links >
>

Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT 59101




I think I figured it out. Thanks for your help. Here's what I wound up with :
r12 = r12 -1, r0 = pm(i12,m12) ;
f1 = float r0, r0 = pm(i12,m12) ;
r2 = pm(i13,m11);
f4 = float r2, r2 = pm(i13,m11) ;

LCNTR=r12, DO xfer UNTIL LCE ;
f1 = float r0, dm(i4,m4) = f1, r0 = pm(i12,m12) ;
xfer: f4 = float r2, dm(i5,m4) = f4, r2 = pm(i13,m11) ;
dm(i4,m4) = f1 ;
dm(i5,m4) = f4 ; At 02:50 PM 10/20/2004, Steve Holle wrote:
> >Yes. Try this (assume that the float array is in pm, i10 is the
> >corresponding pointer and m9 = m1):
> >
> >r2 = dm(_l_NumPairs) ;
> >r2=r2-1, r0 = dm(i4,m4) ;
> >f1 = float r0 , r0 = dm(i4,m4);
> >
> >LCNTR=r2 , DO xfer UNTIL LCE ;
> > f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;
> >xfer: f1 = float r0, r0 = dm(i4,m4), pm(i10,m9) = f1 ;
> >
> >f1 = float r0, pm(i10,m9) = f1 ;
> >pm(i10,m9) = f1 ;
> >
> >This code should run three times faster than your original.
> >
> >Regards,
> >Andor
>
>Is there a way to turn this around so that my float output arrays are in dm
>and my integer input arrays are in pm? >
> >_____________________________________
> >Note: If you do a simple "reply" with your email client, only the author
> >of this message will receive your answer. You need to do a "reply all" if
> >you want your answer to be distributed to the entire group.
> >
> >_____________________________________
> >About this discussion group:
> >
> >To Join: Send an email to
> >
> >To Post: Send an email to
> >
> >To Leave: Send an email to
> >
> >Archives: http://groups.yahoo.com/group/adsp
> >
> >Other Groups: http://www.dsprelated.com/groups.php3
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
>
>Steve Holle
>Link Communications, Inc.
>1035 Cerise Rd.
>Billings, MT 59101 >
>
>_____________________________________
>Note: If you do a simple "reply" with your email client, only the author
>of this message will receive your answer. You need to do a "reply all" if
>you want your answer to be distributed to the entire group.
>
>_____________________________________
>About this discussion group:
>
>To Join: Send an email to
>
>To Post: Send an email to
>
>To Leave: Send an email to
>
>Archives: http://groups.yahoo.com/group/adsp
>
>Other Groups: http://www.dsprelated.com/groups.php3
>
>Yahoo! Groups Links >
>

Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT 59101



Hai,
noise is comming from quantization,i am using
16-bit fixed point (adsp2186)..

with good regards
ayyams

--- Jaime Andres Aranguren Cardona
<> wrote:
> Hi,
>
> Does your noise come from quantization, maybe? What
> precision are you using? 16 bit fixed point, 32 bit
> fixed point, 32 bit floating point?
>
> Would a noise gate help?
>
> JaaC
>

________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony





If the noise is coming from quantization at the analog-to-digital
stage, the way to reduce it is to make sure your signal is as
large as possible (without clipping). If the quantization is from
processing, then using double-precision math can help
considerably. When processing with 16-bit single precision, you
may also need to pay attention to internal scaling. For example
doing something that reduces the signal level considerably will
add quantization noise.

In either case I'm assuming that increasing the number of bits is
not possible due to hardware limitations.

--- ayyam perumal <> wrote:

> Hai,
> noise is comming from quantization,i am using
> 16-bit fixed point (adsp2186)..
>
> with good regards
> ayyams
>
> --- Jaime Andres Aranguren Cardona
> <> wrote:
> > Hi,
> >
> > Does your noise come from quantization, maybe? What
> > precision are you using? 16 bit fixed point, 32 bit
> > fixed point, 32 bit floating point?
> >
> > Would a noise gate help?
> >
> > JaaC

_______________________________