I need to create a specific custom waveform for an oscillator for use with Web Audio API.
I have a Javascript function to output the desired waveform (calculating a y between -1 and 1 for any given x), and the plotted result looks like this:
However the Web Audio API documentation only lets you create custom wavetables based on harmonic tables via the createPeriodicWave
function, which can then be used to configure a custom oscillator via setPeriodicWave
. Is there a generic technique that can be used to compute the harmonic tables based on my waveform function?