Bug in the Wavetable Synthesis tutorial

In the function “createWavetable” in the middle of the Wavetable Synthesis tutorial (also line 142 of WavetableSynthTutorial_04.h), there is the line:

auto angleDelta = MathConstants<double>::twoPi / (double) (tableSize - 1); // [4]

where in the description it states “Next, calculate the angle delta similarly to the previous section but this time using the table size and thus dividing the full 2pi cycle by 127.”

This line actually needs to be:

auto angleDelta = MathConstants<double>::twoPi / (double) tableSize;

Since the wavetable builds 128 samples into the table, the angleDelta has to be divided by 128 as well. I discovered this when I tried to implement this into my own code and it didn’t sound like a clean sine.

2 Likes