Keith William Horwood has written a dynamic waveform audio synthesizer in Javascript. It implements a number of different waveforms (Piano, Organ, EDM and Karplus-Strong string synthesis) and includes ADSR envelop under the hood. It's quite a remarkable piece of engineering:

This keyboard works by generating Waveform Audio file data dynamically, converting it into a base64-encoded dataURI, and subsequently playing it using the HTML5 audio element from within your web browser.

Source.