How to use a custom waveform to produce audio in javascript

I would like to create a program in javascript (html javascript, not nodejs) that allows me to play any arbitrary periodic function as sound. However, I cannot find any way to do so. According to this question, the best way to do that is to calculate the Fourier Series of the function and then use that to create a PeriodicWave object that could be played using an OscillatorNode, however I have absolutely no idea how to do anything with Fourier Series or Fourier Transforms. What I think would be the best method of achieving my goal is to somehow set the value of each sample manually, however as far as I can tell that is not possible, at least using the WebAudio API.
Any help in figuring this out would be greatly appreciated.

Read more here: Source link