>> WARNING: The slider lets you add up to 75 additional harmonics, but it's computationally intensive to calculate and render all these waves! If you're on a slower device, it may make the page slow / unresponsive if you climb up too high.
How would that help? The IFFT would left you quickly synthesize the total waveform From the frequency spectrum, but the whole point of the visualization is to be able to show all the frequency components and interpolate between the individual components and the resulting waveform. The IFFT doesn't help you there.
No matter how you do it, rendering 75 independent waves will take more computation than rendering 2.
The complexity of a (i)FFT scales with O(n·log(n)), whereas a naive, direct fourier transform scales with O(n·m) where `n` is the number of samples and m is the number of channels. Therefore for any `m > log(n)` the direct method wastes a lot of computational power.
The base of the logarithm depends on the radix of the FFT implementation, but in the end it comes out as a constant factor anyway, and for most FFTs out there it's a base in the range of 2…5, so it's at most a factor of about log(5)/log(2) =~= 2.32
Say you're synthezising a waveform of 1024 samples, then the break even between a fast against a direct fourier transform comes it at around 10 channels. For small numbers of channels the direct method is better. Prime example: Quadratur demodulators where you operate on just a single frequency with the real and imaginary parts.
But when you want to do simple additive synthesis, just put your amplitudes and phases at the right places in the spectrum and to a Inverse fourier transform. It's almost always going to beat any other method. Also it's numerically more stable (although the amplitudes in audio synthesis are never going to be so spread out that precision is going to be a problem).
I understand the complexity and function of the FFT. However, the sluggishness of this demo is not due to the actual synthesis of the final wave, it is due to calculating and render each individual waves. I agree you could easily synthesize the final wave with the IFFT, but the point of the demo is to display all the components. The IFFT wouldn't help with this.
ugh just use a (i)FFT, dammit.