- = [O] = -

Sat Mar 19
Thu Dec 30

Apple Store Mac iPod iPhone iPad iTunes Support


 
 Search only in coreaudio-api list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 8.24-bit Fixed point Math

Subject: Re: 8.24-bit Fixed point Math
From: David Duncan
Date: Sat, 08 Nov 2008 08:34:28 -0800
Delivered-to: email@hidden
Delivered-to: email@hidden
On Nov 8, 2008, at 2:28 AM, Mark’s Studio wrote:

I am porting an AU to the iPhone,
and since the canonical format is 8.24 on the device,
i thought it might be better to do the processing in that format.


I presume you mean as a part of your application…

Fixed point math is reasonably simple, you just have to know a few details to get it right.

Addition and subtraction are the same as always (8.24 + 8.24 => 8.24). The only thing you have to worry about is standard integer overflow.

Multiplication is a little complicated however, as you get a double precision result (8.24 * 8.24 => 16.48). Thus you need to worry about both clipping and you have to shift back by the number of fractional bits (i.e. right shift by 24 after the multiplication.

Division is the opposite problem, as you divide away all the fractional bits, so you need to shift back again. Division tends to be rare in performance code anyway, but a left shift by 24 after a division gets you more or less what you need.

For most other operations you can just treat it like the underlying operation. Conversion from Int to Fixed (and back) are just bit shifts, and conversion to/from Float is multiplication/division by the shift value (1
References:  
  >8.24-bit Fixed point Math (From: Mark’s Studio )
  >Re: 8.24-bit Fixed point Math (From: philippe wicker )
  >Re: 8.24-bit Fixed point Math (From: Mark’s Studio )

Prev by Date: Re: Midi Note Length
Next by Date: IPhone: Recorded audio echoes through receiver during play and record audio session
Previous by thread: Re: 8.24-bit Fixed point Math
Next by thread: Re: 8.24-bit Fixed point Math
Index(es):
Date
Thread

fixed point math

sint32 sample =(sint32) 16777216.f * sample

Sat Nov 6
Sat Oct 23
Wed Oct 13
Sun Oct 10
Tue Oct 5
Sun Oct 3
Fri Oct 1