diff --git a/desktop/main.js b/desktop/main.js index 33934bd..d0cfba2 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -1,6 +1,7 @@ const { app, BrowserWindow, webFrame, Menu } = require('electron') const path = require('path') const url = require('url') +const osc = require('osc') const shell = require('electron').shell let isShown = true diff --git a/desktop/package.json b/desktop/package.json index fd78a06..b846576 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -4,6 +4,7 @@ "main": "main.js", "scripts": { "start": "electron .", + "install": "electron-rebuild", "clean": "rm -r ~/Desktop/Ronin-darwin-x64/ ; rm -r ~/Desktop/Ronin-linux-x64/ ; rm -r ~/Desktop/Ronin-win32-x64/ ; echo 'cleaned build location'", "build_osx": "electron-packager . Ronin --platform=darwin --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.icns ; echo 'Built for OSX'", "build_linux": "electron-packager . Ronin --platform=linux --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'", @@ -16,8 +17,12 @@ "push_status": "~/butler status hundredrabbits/ronin", "push": "npm run build ; npm run push_theme ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status" }, + "dependencies": { + "osc": "^2.3.1" + }, "devDependencies": { "electron": "^5.0.6", - "electron-packager": "^13.1.1" + "electron-packager": "^13.1.1", + "electron-rebuild": "^1.8.5" } } diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index ea3483a..39167f9 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -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() + } + } diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index 1e229c7..b492a9c 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -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() }