27 lines
523 B
JavaScript
27 lines
523 B
JavaScript
var oscPort = new osc.WebSocketPort({
|
|
url: location.origin.replace(/https?/, 'ws'),
|
|
metadata: true
|
|
});
|
|
|
|
oscPort.open();
|
|
|
|
oscPort.on("ready", function () {
|
|
console.log("OSC listening!")
|
|
// Example send
|
|
/*
|
|
oscPort.send({
|
|
address: "/carrier/frequency",
|
|
args: [
|
|
{
|
|
type: "f",
|
|
value: 440
|
|
}
|
|
]
|
|
});
|
|
*/
|
|
oscPort.on("message", function (msg) {
|
|
//console.log("OSC message", msg.address, oscCallbacks);
|
|
oscCallbacks[msg.address].forEach(cb => cb(msg.args))
|
|
});
|
|
});
|