arbitrary wavetables

The “Latest version” of “High Quality (no alias) Tone generator” has examples of generating tones from custom wavetables.
https://forum.audacityteam.org/t/high-quality-no-alias-tone-generator/20889/1

Example: In the “square-wav” function, a waveform “wave” is built (line 35) using “build-harmonic”, and then converted to a wavetable and used to generate the tone in line 36.

(Line 37 just applies a bit of filtering to reduce overshoot of the waveform to make it look more “square”,
Line 38 trims the start so that the tone starts cleanly.
Line 39 Normalizes and amplifies to the required peak level.)