{
  "name": "osc-min",
  "version": "0.0.5",
  "main": "lib/index",
  "author": {
    "name": "Russell McClellan",
    "email": "russell.mcclellan@gmail.com",
    "url": "http://www.ghostfact.com"
  },
  "description": "Simple utilities for open sound control in node.js",
  "keywords": [
    "open sound control",
    "OSC",
    "music control",
    "NIME"
  ],
  "repository": {
    "type": "git",
    "url": "http://github.com/ghostfact/node-osc-min.git"
  },
  "dependencies": {
    "binpack": "*",
    "coffee-script": "1.3.0"
  },
  "devDependencies": {
    "expresso": "*",
    "docket": ">=0.0.3"
  },
  "directories": {
    "lib": "lib",
    "examples": "examples"
  },
  "engines": {
    "node": ">=0.6.0"
  },
  "scripts": {
    "test": "cake test",
    "coverage": "cake coverage",
    "doc": "cake doc"
  },
  "readme": "# osc-min\n\n_simple utilities for open sound control in node.js_\n\nThis package provides some node.js utilities for working with \n[OSC](http://opensoundcontrol.org/), a format for sound and systems control.  \nHere we implement the [OSC 1.1][spec11] specification.  OSC is a transport-independent\nprotocol, so we don't provide any server objects, as you should be able to \nuse OSC over any transport you like.  The most common is probably udp, but tcp\nis not unheard of.\n\n[spec11]: http://opensoundcontrol.org/spec-1_1\n\n----\n## Installation\n \nThe easiest way to get osc-min is through [NPM](http://npmjs.org).\nAfter install npm, you can install osc-min in the current directory with\n \n```\nnpm install osc-min\n```\n \nIf you'd rather get osc-min through github (for example, if you're forking\nit), you still need npm to install dependencies, which you can do with\n \n```\nnpm install --dev\n```\n \nOnce you've got all the dependencies you should be able to run the unit\ntests with \n \n```\nnpm test\nnpm run-script coverage\n```\n\n----\n## Examples\n### A simple OSC printer\n```coffee-script\nsock = udp.createSocket \"udp4\", (msg, rinfo) ->\n    try\n        console.log osc.fromBuffer msg\n    catch error\n        console.log \"invalid OSC packet\"\nsock.bind inport\n\n```\n### Send a bunch of arguments every two seconds\n```coffee-script\nsendHeartbeat = () ->\n    buf = osc.toBuffer(\n        address : \"/heartbeat\"\n        arguments : [\n            12\n            \"sttttring\"\n            new Buffer \"beat\"\n            {type : \"integer\", value : 7}\n        ]\n    )\n    \n    udp.send buf, 0, buf.length, outport, \"localhost\"\n    \nsetInterval sendHeartbeat, 2000\n```\n### A simple OSC redirecter\n```coffee-script\nsock = udp.createSocket \"udp4\", (msg, rinfo) ->\n    try\n        redirected = osc.applyAddressTransform msg, (address) -> \"/redirect\" + address\n        sock.send(\n            redirected,\n            0,\n            redirected.length,\n            outport,\n            \"localhost\"\n        )\n    catch error\n        console.log \"error redirecting: \" + error\nsock.bind inport\n```\n\n\nmore examples are available in the `examples/` directory.\n\n----\n## Exported functions\n\n------\n### .fromBuffer(buffer, [strict])\ntakes a node.js Buffer of a complete _OSC Packet_ and \noutputs the javascript representation, or throws if the buffer is ill-formed.\n\n`strict` is an optional parameter that makes the function fail more often.\n\n----\n### .toBuffer(object, [strict])\ntakes a _OSC packet_ javascript representation as defined below and returns\na node.js Buffer, or throws if the representation is ill-formed.\n\n----\n### .toBuffer(address, arguments[], [strict])\nalternative syntax for above.  Assumes this is an _OSC Message_ as defined below, \nand `arguments` is an array of _OSC Arguments_ or single _OSC Argument_\n\n----\n### .applyAddressTransform(buffer, transform)\ntakes a callback that takes a string and outputs a string,\nand applies that to the address of the message encoded in the buffer,\nand outputs an encoded buffer.\n\nIf the buffer encodes an _OSC Bundle_, this applies the function to each address \nin the bundle.\n\nThere's two subtle reasons you'd want to use this function rather than \ncomposing `fromBuffer` and `toBuffer`:\n  - Future-proofing - if the OSC message uses an argument typecode that\n    we don't understand, calling `fromBuffer` will throw.  The only time\n    when `applyAddressTranform` might fail is if the address is malformed.\n  - Accuracy - javascript represents numbers as 64-bit floats, so some\n    OSC types will not be able to be represented accurately.  If accuracy\n    is important to you, then, you should never convert the OSC message to a\n    javascript representation.\n\n----\n### .applyMessageTransform(buffer, transform)\ntakes a function that takes and returns a javascript _OSC Message_ representation,\nand applies that to each message encoded in the buffer,\nand outputs a new buffer with the new address.\n\nIf the buffer encodes an osc-bundle, this applies the function to each message \nin the bundle.\n\nSee notes above for applyAddressTransform for why you might want to use this.\nWhile this does parse and re-pack the messages, the bundle timetags are left\nin their accurate and prestine state.\n\n----\n## Javascript representations of the OSC types.  \nSee the [spec][spec] for more information on the OSC types.\n\n+ An _OSC Packet_ is an _OSC Message_ or an _OSC Bundle_.\n\n+ An _OSC Message_:\n\n          {\n              oscType : \"message\"\n              address : \"/address/pattern/might/have/wildcards\"\n              arguments : [arg1,arg2]\n          }\n\n   Where arguments is an array of _OSC Arguments_.  `oscType` is optional.\n   `arguments` can be a single element.\n\n+ An _OSC Argument_ is represented as a javascript object with the following layout:\n\n          {\n              type : \"string\"\n              value : \"value\"\n          }\n\n   Where the `type` is one of the following:\n   + `string` - string value\n   + `float` - numeric value\n   + `integer` - numeric value\n   + `blob` - node.js Buffer value\n   + `true` - value is boolean true\n   + `false` - value is boolean false\n   + `null` - no value\n   + `bang` - no value (this is the `I` type tag)\n   + `timetag` - numeric value\n\n   Note that `type` is always a string - i.e. `\"true\"` rather than `true`.\n  \n   The following non-standard types are also supported:\n   + `double` - numeric value (encodes to a float64 value)\n\n   \n   For messages sent to the `toBuffer` function, `type` is optional.\n   If the argument is not an object, it will be interpreted as either\n   `string`, `float`, or `blob`, depending on its javascript type.\n\n+ An _OSC Bundle_ is represented as a javascript object with the following layout\n\n          {\n              oscType : \"bundle\"\n              timetag : 7\n              elements : [element1, element]\n          }\n\n  Where the timetag is a javascript-native numeric value of the timetag,\n  and elements is an array of either an _OSC Bundle_ or an _OSC Message_\n  The `oscType` field is optional, but is always returned by api functions.\n\n[spec]: http://opensoundcontrol.org/spec-1_0\n\n",
  "readmeFilename": "readme.md",
  "bugs": {
    "url": "https://github.com/ghostfact/node-osc-min/issues"
  },
  "_id": "osc-min@0.0.5",
  "dist": {
    "shasum": "b1c1fd098c1bad05cdf5716adccd322bf76c5c2a"
  },
  "_from": "osc-min@0.0.5",
  "_resolved": "https://registry.npmjs.org/osc-min/-/osc-min-0.0.5.tgz"
}
