diff --git a/desktop/sources/index.html b/desktop/sources/index.html index 955ce4b..ce0e6c2 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -9,6 +9,8 @@ + + diff --git a/desktop/sources/scripts/osc.js b/desktop/sources/scripts/osc.js new file mode 100644 index 0000000..21e87d2 --- /dev/null +++ b/desktop/sources/scripts/osc.js @@ -0,0 +1,27 @@ +'use strict' + +function Osc (ronin) { + const osc = require('osc') + + this.oscMsg = {} + + this.start = function () { + var udpPort = new osc.UDPPort({ + localAddress: "0.0.0.0", + localPort: 12940, + metadata: true + }); + + udpPort.on("message", this.onOscMsg) + + udpPort.open(); + this.ronin.log("osc started") + } + + + this.onOscMsg = (oscMsg, timeTag, info) => { + this.oscMsg = oscMsg; + this.ronin.log("An OSC message just arrived!", oscMsg) + this.ronin.log("Remote info is: ", info); + } +} diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index b492a9c..7f13811 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -1,5 +1,3 @@ -const osc = require('osc') - function Ronin () { const defaultTheme = { background: '#111', @@ -21,6 +19,7 @@ function Ronin () { this.commander = new Commander(this) this.surface = new Surface(this) this.library = new Library(this) + this.osc = new Osc(this) this.oscMsg = {} // Parameters @@ -46,29 +45,11 @@ function Ronin () { this.source.start() this.commander.start() this.surface.start() - - var udpPort = new osc.UDPPort({ - localAddress: "0.0.0.0", - localPort: 57121, - metadata: true - }); - - udpPort.on("message", this.onOscMsg) - - udpPort.open(); - this.log("started") - - console.log('Ronin', 'Started') - } - - this.onOscMsg = (oscMsg, timeTag, info) => { - this.oscMsg = oscMsg; - console.log("An OSC message just arrived!", oscMsg) - this.log("Remote info is: ", info); + this.osc.start() } this.getOsc = function() { - return this.oscMsg; + return this.osc.oscMsg; } this.reset = function () {