Skip to content

PureData & MaxMSP

Andreas Dzialocha edited this page Jan 12, 2017 · 2 revisions

Bridge Server Example

This method is useful for building a link between applications inside the browser and other applications who are not capable of WebSocket networking (for example like Max/MSP). With the help of a WebSocket/UDP "bridge" inbetween the the browser this can be made possible.

  1. Write a simple webpage. The library will use a WebSocket client by default.
<button id="send">Send Message</button>
<script type="text/javascript" src="dist/osc.min.js"></script>
<script type="text/javascript">
  var osc = new OSC();
  osc.open(); // connect by default to ws://localhost:8080

  document.getElementById('send').addEventListener('click', function() {
    var message = new OSC.Message('/test/random', Math.random());
    osc.send(message);
  });
</script>
  1. Write a Node app (the "bridge" between your UDP and WebSocket clients).
const OSC = require('osc-js')

const config = { udpClient: { port: 9129 } }
const osc = new OSC({ plugin: new OSC.BridgePlugin(config) })

osc.open() // start a WebSocket server on port 8080
  1. Create your Max/MSP patch (or PD, or SuperCollider or whatever you need).
[udpreceive 9129] // incoming '/test/random' messages with random number