Improving OSC reading
This commit is contained in:
parent
07ff69e14a
commit
76994ad373
@ -72,7 +72,7 @@ function Commander (ronin) {
|
|||||||
// Logs
|
// Logs
|
||||||
if (msg && msg !== this._log.textContent) {
|
if (msg && msg !== this._log.textContent) {
|
||||||
this._log.textContent = `${msg}`
|
this._log.textContent = `${msg}`
|
||||||
console.log(msg)
|
// console.log(msg)
|
||||||
}
|
}
|
||||||
// Source
|
// Source
|
||||||
const _source = `${ronin.source} ${this._input.value.split('\n').length} lines`
|
const _source = `${ronin.source} ${this._input.value.split('\n').length} lines`
|
||||||
|
@ -7,7 +7,7 @@ function Library (ronin) {
|
|||||||
|
|
||||||
this.export = (path, format = 'image/png', quality = 1.0) => { // Exports a graphic file with format.
|
this.export = (path, format = 'image/png', quality = 1.0) => { // Exports a graphic file with format.
|
||||||
if (!path) { console.warn('Missing export path'); return path }
|
if (!path) { console.warn('Missing export path'); return path }
|
||||||
var dataUrl = ronin.surface.el.toDataURL(format, quality)
|
const dataUrl = ronin.surface.el.toDataURL(format, quality)
|
||||||
const data = dataUrl.replace(/^data:image\/png;base64,/, '').replace(/^data:image\/jpeg;base64,/, '')
|
const data = dataUrl.replace(/^data:image\/png;base64,/, '').replace(/^data:image\/jpeg;base64,/, '')
|
||||||
fs.writeFileSync(path, data, 'base64')
|
fs.writeFileSync(path, data, 'base64')
|
||||||
return path
|
return path
|
||||||
@ -350,6 +350,11 @@ function Library (ronin) {
|
|||||||
return arg
|
return arg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.log = (arg) => {
|
||||||
|
console.log(arg)
|
||||||
|
return arg
|
||||||
|
}
|
||||||
|
|
||||||
this.time = (rate = 1) => { // Returns timestamp in milliseconds.
|
this.time = (rate = 1) => { // Returns timestamp in milliseconds.
|
||||||
return (Date.now() * rate)
|
return (Date.now() * rate)
|
||||||
}
|
}
|
||||||
@ -378,13 +383,9 @@ function Library (ronin) {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// osc
|
// IO
|
||||||
|
|
||||||
this.osc = (...args) => { // Returns a rect of the frame.
|
this.osc = (path) => { // Returns the latest osc message at path
|
||||||
if (args.length >= 1) {
|
return path ? ronin.osc.msg[path] : ronin.osc.msg
|
||||||
return ronin.getOsc()[args[0]]
|
|
||||||
} else {
|
|
||||||
return ronin.getOsc()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,24 +3,21 @@
|
|||||||
function Osc (ronin) {
|
function Osc (ronin) {
|
||||||
const osc = require('osc')
|
const osc = require('osc')
|
||||||
|
|
||||||
this.oscMsg = {}
|
this.msg = {}
|
||||||
|
|
||||||
this.start = function () {
|
this.start = function () {
|
||||||
var udpPort = new osc.UDPPort({
|
const udpPort = new osc.UDPPort({
|
||||||
localAddress: '0.0.0.0',
|
localAddress: '0.0.0.0',
|
||||||
localPort: 49162,
|
localPort: 49162,
|
||||||
metadata: true
|
metadata: true
|
||||||
})
|
})
|
||||||
|
udpPort.on('message', this.onMsg)
|
||||||
udpPort.on('message', this.onOscMsg)
|
|
||||||
|
|
||||||
udpPort.open()
|
udpPort.open()
|
||||||
ronin.log('osc started')
|
ronin.log('OSC','Started.')
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onOscMsg = (oscMsg, timeTag, info) => {
|
this.onMsg = (msg, timeTag, info) => {
|
||||||
this.oscMsg[oscMsg.address] = oscMsg
|
this.msg[msg.address] = msg.args
|
||||||
ronin.log('An OSC message just arrived!', oscMsg)
|
// ronin.log(`${info.address}:${info.port} > ${msg.args}`, info)
|
||||||
ronin.log('Remote info is: ', info)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,6 @@ function Ronin () {
|
|||||||
this.osc.start()
|
this.osc.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getOsc = function () {
|
|
||||||
return this.osc.oscMsg
|
|
||||||
}
|
|
||||||
|
|
||||||
this.reset = function () {
|
this.reset = function () {
|
||||||
this.theme.reset()
|
this.theme.reset()
|
||||||
}
|
}
|
||||||
|
1
examples/orca.lisp
Normal file
1
examples/orca.lisp
Normal file
@ -0,0 +1 @@
|
|||||||
|
(log (of (osc "/a") 0 "value"))
|
Loading…
x
Reference in New Issue
Block a user