Re: Faster Frac() imlementation?
- From: buramu@xxxxxxxxx
- Date: Sat, 26 Jul 2008 02:02:02 -0700 (PDT)
Does something faster for Frac also exist?
Change all to integer-mathematics, than you don't need ceil or frac.
(my crystal ball is broken, show me the code ;-)
Here is my most simplified linear interpolation mechanism.
I don't see how floating point maths can be avoided.
//round the current pointer into my sample data up
p2 := ceil( fIndex );
// determine the previous sample index (and avoid going lower than
sample 0)
p1 := pred( p2 );
if p1 < 0 then p1 := 0;
// pointer is probably somewhere between samples.. determine where...
fract := frac( fIndex );
// get the 2 nearest samples from the sample data
h1 := sample[p1];
h2 := sample[p2];
// now calculate the interpolated value using the difference between
these two samples
delta := h2 - h1;
result := round( h1 + ( fract * delta ) );
.
- Follow-Ups:
- Re: Faster Frac() imlementation?
- From: Hubert Seidel
- Re: Faster Frac() imlementation?
- From: Hubert Seidel
- Re: Faster Frac() imlementation?
- References:
- Faster Frac() imlementation?
- From: buramu
- Re: Faster Frac() imlementation?
- From: Hubert Seidel
- Faster Frac() imlementation?
- Prev by Date: Re: Faster Frac() imlementation?
- Next by Date: Re: Faster Frac() imlementation?
- Previous by thread: Re: Faster Frac() imlementation?
- Next by thread: Re: Faster Frac() imlementation?
- Index(es):