To try this demo, simply click with the left mouse button inside the gray square below and hold it while you drag your mouse around to draw. This should generate some typical FM synthesis sounds.
The calligraphy code is taken more or less directly from here, and this p5.js code snippet served as the starting point for the FM sound synthesis code.
This demo uses p5.js in this version, delivered via a content-delivery network (CDN), and what seems to be a since superseded version of its p5.sound.js library. I could not find it on any CDN, nor could I get the demo to work with more recent versions, which is why I added it locally here. Note that as of today, it seems to work in Firefox and other browsers, but not Chrome.
This demo should be generalized such as to also support touch screens, not just mice. One could also imagine a version for graphic tablets, where pen pressure is mapped to the modAmp parameter of the synthesizer. For regular mice or touch screens, one could adopt the JavaScript code that detects mouse speed (which in this version is only used for emulating the visual effect of a brush) to also control modAmp, or perhaps the color of the brush.