- UMD Module running in Node.js, Electron, Chrome Apps, browser or any other JS environment
- Can be used with Webpack and Browserify
- No dependencies (except of
wsin Node.js or similar environments)
- Receive sender information from incoming messages
- Built-in UDP, WebSocket networking support as plugins
- Special bridge plugin for easy communication between UDP- and WebSocket clients
- Plugin API for custom network protocols
- Featuring all OSC 1.0 specifications
- OSC Address pattern matching
- Time-critical OSC Bundles with Timetags
Read more about osc-js and how to use it in the Wiki.
const osc =oscoscoscoscosc
Installation and Usage
Recommended installation via npm:
npm install osc-js --save or
yarn add osc-js.
Import the library
const OSC = require('osc-js') or add the script
lib/osc.min.js (minified version) for usage in a browser.
osc-js offers a plugin architecture for extending it's networking capabilities. The library comes with four built-in plugins. This is propably all you need for an OSC application:
DatagramPluginfor UDP network messaging
BridgePluginuseful Bridge between WebSocket- and UDP Clients
Configuration and examples of every plugin can be read here: Wiki.
Example: WebSocket Server
Register the plugin when creating the OSC instance:
const osc = plugin:osc // listening on 'ws://localhost:8080'
Example: OSC between MaxMSP/PD/SC etc. and your browser
- Write a simple webpage. The library will use a WebSocket client by default.
- Write a Node app (the "bridge" between your UDP and WebSocket clients).
const OSC =const config = udpClient: port: 9129const osc = plugin: configosc // start a WebSocket server on port 8080
- Create your Max/MSP patch (or PD, or SuperCollider or whatever you need).
[udpreceive 9129] // incoming '/test/random' messages with random number
Custom solutions with Plugin API
It is possible to write more sophisticated solutions for OSC applications without loosing the osc-js interface (including it's message handling etc.). Read the Plugin API documentation for further information.
// ... read docs for implementation detailsconst osc = plugin:oscosc
Usage without plugins
The library can be used without the mentioned features in case you need to write and read binary OSC data. See this example below for using the Low-Level API (even though the library already has a solution for handling UDP like in this example):
const dgram =const OSC =const socket = dgram// send a messsage via udpconst message = '/some/path' 21const binary = messagesocket// receive a message via UDPsocket
Clone the repository and install all dependencies:
git clone firstname.lastname@example.org:adzialocha/osc-js.git cd osc-js npm install
npm run test for running the test suites.
npm run test:watch for running specs during development. Check your style guide violations with
npm run lint.
npm run build for creating all UMD modules in
npm run docs for generating a
docs folder with HTML files documenting the library. Read them online here: https://doc.esdoc.org/github.com/adzialocha/osc-js/