@@ -377,4 +377,14 @@ function Library (ronin) {
|
||||
console.log(`time taken: ${Date.now() - start}ms`)
|
||||
return result
|
||||
}
|
||||
|
||||
// osc
|
||||
|
||||
this.osc = (...args) => { // Returns a rect of the frame.
|
||||
if (args.length >= 1) {
|
||||
return ronin.getOsc()[args[0]]
|
||||
} else {
|
||||
return ronin.getOsc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
26
desktop/sources/scripts/osc.js
Normal file
26
desktop/sources/scripts/osc.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'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();
|
||||
ronin.log("osc started")
|
||||
}
|
||||
|
||||
this.onOscMsg = (oscMsg, timeTag, info) => {
|
||||
this.oscMsg[oscMsg.address] = oscMsg;
|
||||
ronin.log("An OSC message just arrived!", oscMsg)
|
||||
ronin.log("Remote info is: ", info);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ function Ronin () {
|
||||
this.surface = new Surface(this)
|
||||
this.library = new Library(this)
|
||||
this.interpreter = new Lisp(this.library, this.includes)
|
||||
|
||||
this.osc = new Osc(this)
|
||||
// Parameters
|
||||
|
||||
this.always = false
|
||||
@@ -46,7 +46,11 @@ function Ronin () {
|
||||
this.source.start()
|
||||
this.commander.start()
|
||||
this.surface.start()
|
||||
console.log('Ronin', 'Started')
|
||||
this.osc.start()
|
||||
}
|
||||
|
||||
this.getOsc = function() {
|
||||
return this.osc.oscMsg;
|
||||
}
|
||||
|
||||
this.reset = function () {
|
||||
|
||||
Reference in New Issue
Block a user