Highly recommend checking out the WebAudio API[1] for anyone interested in this kind of thing.
It’s got some obvious shortcomings and wild browser inconsistencies, but lets you go through much of the same design process in making your own synth.
1] https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_A...