No description, website, or topics provided.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.babelrc
.eslintrc
.gitignore
.travis.yml
README.md
package.json

README.md

synthdef-json-formatter

Build Status NPM Version License

formatter for SuperCollider Synth Definition File Format

Installation

npm install synthdef-json-formatter

API

  • format(json: object): string

Example

const formatter = require("synthdef-json-formatter");

const synthdef = {
  "name":"sine",
  "consts":[0],
  "paramValues":[0.5,440],
  "paramIndices":{"amp":{"index":0,"length":1},"freq":{"index":1,"length":1}},
  "units":[["Control",1,0,[],[1,1]],["SinOsc",2,0,[[0,1],[-1,0]],[2]],["BinaryOpUGen",2,2,[[1,0],[0,0]],[2]],["Out",2,0,[[-1,0],[2,0],[2,0]],[]]],
  "variants":{"alpha":[0.25,880],"beta":[0.5,1760]}
};

console.log(formatter.format(synthdef));
{
  "name": "sine",
  "consts": [ 0 ],
  "paramValues": [ 0.5, 440 ],
  "paramIndices": {
    "amp" : { "index": 0, "length": 1 },
    "freq": { "index": 1, "length": 1 }
  },
  "units": [
    [ "Control"     , 1, 0, [                                ], [ 1, 1 ] ],
    [ "SinOsc"      , 2, 0, [ [  0, 1 ], [ -1, 0 ]           ], [ 2    ] ],
    [ "BinaryOpUGen", 2, 2, [ [  1, 0 ], [  0, 0 ]           ], [ 2    ] ],
    [ "Out"         , 2, 0, [ [ -1, 0 ], [  2, 0 ], [ 2, 0 ] ], [      ] ]
  ],
  "variants": {
    "alpha": [ 0.25,  880 ],
    "beta" : [  0.5, 1760 ]
  }
}

License

MIT