I am sampling a sine wave at 48 kHz, the frequency range of my sine wave can vary from 0 to 20000 Hz with a step of about 100 Hz. I am using a lookup table approach. So I genera
Very good answer, this is classic software DDS. Facing the same problem these days. There is no need to use floats
UInt16 f = 400; // Hz, up to 16384 :)
UInt16 delta = (UInt16)(((UInt32)f * LUT_SIZE ) / fmt_SamplesPerSec);
UInt16 phase = 0;
for (int i = 0; i < BUFF_SIZE; ++i)
{
buff[i] = LUT[phase];
phase += delta;
phase &= LUT_SIZE-1;
}
Let phase wraparound LUT size as mask. And don't care about using quadrants since for my purpose I have a huge MIPS for this requirements already.