DailyJS

Browser Synths with Code Studio

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

audio node modules

Browser Synths with Code Studio

Posted by Alex R. Young on .
Featured

audio node modules

Browser Synths with Code Studio

Posted by Alex R. Young on .
Code Studio running polytropon.

Code Studio (GitHub: substack / code-music-studio, License: MIT, npm: code-music-studio) by substack is a tool for "designing musical algorithms". It provides a browser-based interface that allows you to return functions that manipulate amplitudes. You can experiment and share sounds using studio.substack.net, or install it with npm and run it locally.

If you want to find some code to play with, look at substack's Twitter account, or /-/recent.

The audio API is based on baudio, which works by accepting a function that takes a time value and returns an amplitude value between -1 and 1.

That means you can generate a sound just by running something like this:

return function(t) {  
  return sin(441);
  function sin(x) { return Math.sin(2 * Math.PI * t * x); }
}

That example creates a function called sin that generates values for a given pitch. Code Studio will render an oscilloscope so you can visualise the output as well as hear it. The waveform is rendered using amplitude-viewer, another module by substack that creates graphs with SVG.

If you're interested in the server-side portion of the code, then take a look at bin/cmd.js. This uses Node's http module, and ecstatic for static assets.

I think my favourite example so far is polytropon. It has a function called Moog, so you can't go wrong!