![](http://habrastorage.org/getpro/habr/avatars/f95/117/e36/f95117e36dd518ddde2d23fc2d5e1f6a.jpg)
Writing Music in JavaScript
![image](https://habrastorage.org/getpro/habr/post_images/6b7/0e1/fd0/6b70e1fd0db13c4de450a0e41da7bd95.png)
I invite all lovers of electronic music and programming to play in the synthesis of tunes using Code Music Studio .
The bottom line is:
You need to create a function that takes a time argument and returns an amplitude in the range from -1 to 1, for example:
var n = 0;
return function (t) {
var x = Math.sin(t * 256 + Math.sin(n));
n += Math.sin(t);
return x;
}
[listen]You can take as a basis something from studio.substack.net/-/recent
for example polytropon , SuperMario .
Under the hood:
github.com/substack/code-music-studio
Uses the baudio audio API .
Graphics - SVG, rendered using the amplitude-viewer module .
As the http server NodeJS http API , and ecstatic for statics.
And finally, a little video (in English):