synthdef-json-formatter

1.0.0 • Public • Published

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":[{"name":"amp","index":0,"length":1},{"name":"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":[{"name":"alpha","values":[0.25,880]},{"name":"beta","values":[0.5,1760]}]
};
 
console.log(formatter.format(synthdef));
{
  "name": "sine",
  "consts": [ 0 ],
  "paramValues": [ 0.5, 440 ],
  "paramIndices": [
    { "name": "amp" , "index": 0, "length": 1 },
    { "name": "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": [
    { "name": "alpha", "values": [ 0.25,  880 ] },
    { "name": "beta" , "values": [  0.5, 1760 ] }
  ]
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i synthdef-json-formatter

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mohayonao