diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 658c34a..48aa1e5 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -72,7 +72,7 @@ function Commander (ronin) { // Logs if (msg && msg !== this._log.textContent) { this._log.textContent = `${msg}` - console.log(msg) + // console.log(msg) } // Source const _source = `${ronin.source} ${this._input.value.split('\n').length} lines` diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 5aea1ea..34dfcc8 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -7,7 +7,7 @@ function Library (ronin) { this.export = (path, format = 'image/png', quality = 1.0) => { // Exports a graphic file with format. 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,/, '') fs.writeFileSync(path, data, 'base64') return path @@ -350,6 +350,11 @@ function Library (ronin) { return arg } + this.log = (arg) => { + console.log(arg) + return arg + } + this.time = (rate = 1) => { // Returns timestamp in milliseconds. return (Date.now() * rate) } @@ -378,13 +383,9 @@ function Library (ronin) { return result } - // osc + // IO - this.osc = (...args) => { // Returns a rect of the frame. - if (args.length >= 1) { - return ronin.getOsc()[args[0]] - } else { - return ronin.getOsc() - } + this.osc = (path) => { // Returns the latest osc message at path + return path ? ronin.osc.msg[path] : ronin.osc.msg } } diff --git a/desktop/sources/scripts/osc.js b/desktop/sources/scripts/osc.js index 08b609f..6202be2 100644 --- a/desktop/sources/scripts/osc.js +++ b/desktop/sources/scripts/osc.js @@ -3,24 +3,21 @@ function Osc (ronin) { const osc = require('osc') - this.oscMsg = {} + this.msg = {} this.start = function () { - var udpPort = new osc.UDPPort({ + const udpPort = new osc.UDPPort({ localAddress: '0.0.0.0', localPort: 49162, metadata: true }) - - udpPort.on('message', this.onOscMsg) - + udpPort.on('message', this.onMsg) udpPort.open() - ronin.log('osc started') + 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) + this.onMsg = (msg, timeTag, info) => { + this.msg[msg.address] = msg.args + // ronin.log(`${info.address}:${info.port} > ${msg.args}`, info) } } diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index 0124172..8d247ee 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -49,10 +49,6 @@ function Ronin () { this.osc.start() } - this.getOsc = function () { - return this.osc.oscMsg - } - this.reset = function () { this.theme.reset() } diff --git a/examples/orca.lisp b/examples/orca.lisp new file mode 100644 index 0000000..16ee567 --- /dev/null +++ b/examples/orca.lisp @@ -0,0 +1 @@ +(log (of (osc "/a") 0 "value")) \ No newline at end of file