const int LUT_SIZE;
const int LUT[LUT_SIZE]; // waveform lookup table (typically 2^N, N >= 8)
Fixed index; // current index into LUT (integer + fraction)
Fixed delta; // delta controls output frequency
output_value = LUT[(int)index];
// NB: for higher quality use the fractional part of index to interpolate
// between LUT[(int)index] and LUT[(int)index + 1], rather than just
// truncating the index and using LUT[(int)index] only. Depends on both
// LUT_SIZE and required output quality.
index = (index + delta) % LUT_SIZE;
Note: to calculate delta for a given output frequency f and a sample rate Fs: