first osc msg tests

This commit is contained in:
ngradwohl
2019-07-20 16:02:51 +02:00
parent 3d4268fce0
commit e65f266aca
4 changed files with 39 additions and 1 deletions

View File

@@ -374,4 +374,11 @@ function Library (ronin) {
console.log(`time taken: ${Date.now() - start}ms`)
return result
}
// osc
this.osc = () => { // Returns a rect of the frame.
return ronin.getOsc()
}
}

View File

@@ -1,3 +1,5 @@
const osc = require('osc')
function Ronin () {
const defaultTheme = {
background: '#111',
@@ -20,6 +22,7 @@ function Ronin () {
this.surface = new Surface(this)
this.library = new Library(this)
this.oscMsg = {}
// Parameters
this.always = false
@@ -43,9 +46,31 @@ 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.getOsc = function() {
return this.oscMsg;
}
this.reset = function () {
this.theme.reset()
}