I have generated a sine wave using a 257-point look-up table that covers only one quadrant (4th quadrant). The entries in the table are in fixed point format (Q1.15) [o,.....,-32768]. linear interpolation is used for finding unknown values in the table. I came across an example in which linear interpolation is implemented and used the same logic. The index and delta are calculated as:
x -> phase in Q1.15 entries in look up table = 2^8 + 1 = 257
n = 8;
if (x > 0)
{
sign_flag = 1;
x = ~(x);
}
if (x < -16384)
{
x = -32768 - x;
}
x = ~(x);
index = x >> (14-n);
delta = (x & ((1 << (14 - n)) - 1)) << (1 + n);
z = table[index];
y = ((table[index+1] - table[index]) * delta) >> 15;
y = z + y;`
- what is the logic behind index and delta ?
- If delta is calculated using x (phase) in float, how to calculate delta without using shift operation?