Giter Site home page Giter Site logo

code-music-studio's Introduction

code-music-studio

design musical algorithms

live demo at studio.substack.net

screenshot

usage

code-music-studio

  Run the code-music-studio http server.

  -p PORT      Listen on this port.
  -d DATADIR   Use this directory to store songs.
  -i           Read lines of json from stdin to set state variables.
  --state.VAR  Set initial variables individually.

install

With npm do:

npm install -g code-music-studio

run

Just type:

code-music-studio PORT

to start the server on PORT.

songs

Songs look like:

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

The returned function gets run 44000 times per second and returns a floating point number between -1 and 1 representing the amplitude.

input

If -i is given, stdin is parsed as newline-separated json. Each line of json updates the current state.

For example, the left column is the input and the right column is the value of the current state:

input           state

{"x":3}         {x:3}
{"y":4}         {x:3,y:4}
{"x":5}         {x:5,y:4}
{"y":8,"z":2}   {x:5,y:8,z:2}

You can set the initial state value with --state:

code-music-studio -i --state.x=5 --state.y=3

You can get at the state variables in the second argument to the function:

return function (t, state) {
  return sin(440 * state.x)
  function sin (x) { return Math.sin(2 * Math.PI * t * x) }
}

license

MIT

code-music-studio's People

Contributors

skratchdot avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.